feat: add OpenRouter provider support and enhance context generation
Added support for OpenRouter as an alternative LLM provider with new settings for API key, model selection, and app metadata configuration. Enhanced context generation with improved settings management and updated worker service APIs. Includes UI updates for context settings and new observation type configurations.
This commit is contained in:
@@ -436,10 +436,11 @@ export function ContextSettingsModal({
|
||||
>
|
||||
<option value="claude">Claude (uses your Claude account)</option>
|
||||
<option value="gemini">Gemini (uses API key)</option>
|
||||
<option value="openrouter">OpenRouter (multi-model)</option>
|
||||
</select>
|
||||
</FormField>
|
||||
|
||||
{formState.CLAUDE_MEM_PROVIDER === 'claude' ? (
|
||||
{formState.CLAUDE_MEM_PROVIDER === 'claude' && (
|
||||
<FormField
|
||||
label="Claude Model"
|
||||
tooltip="Claude model used for generating observations"
|
||||
@@ -453,7 +454,9 @@ export function ContextSettingsModal({
|
||||
<option value="opus">opus (highest quality)</option>
|
||||
</select>
|
||||
</FormField>
|
||||
) : (
|
||||
)}
|
||||
|
||||
{formState.CLAUDE_MEM_PROVIDER === 'gemini' && (
|
||||
<>
|
||||
<FormField
|
||||
label="Gemini API Key"
|
||||
@@ -491,6 +494,55 @@ export function ContextSettingsModal({
|
||||
</>
|
||||
)}
|
||||
|
||||
{formState.CLAUDE_MEM_PROVIDER === 'openrouter' && (
|
||||
<>
|
||||
<FormField
|
||||
label="OpenRouter API Key"
|
||||
tooltip="Your OpenRouter API key from openrouter.ai (or set OPENROUTER_API_KEY env var)"
|
||||
>
|
||||
<input
|
||||
type="password"
|
||||
value={formState.CLAUDE_MEM_OPENROUTER_API_KEY || ''}
|
||||
onChange={(e) => updateSetting('CLAUDE_MEM_OPENROUTER_API_KEY', e.target.value)}
|
||||
placeholder="Enter OpenRouter API key..."
|
||||
/>
|
||||
</FormField>
|
||||
<FormField
|
||||
label="OpenRouter Model"
|
||||
tooltip="Model identifier from OpenRouter (e.g., anthropic/claude-3.5-sonnet, google/gemini-2.0-flash-thinking-exp)"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
value={formState.CLAUDE_MEM_OPENROUTER_MODEL || 'anthropic/claude-3.5-sonnet'}
|
||||
onChange={(e) => updateSetting('CLAUDE_MEM_OPENROUTER_MODEL', e.target.value)}
|
||||
placeholder="e.g., anthropic/claude-3.5-sonnet"
|
||||
/>
|
||||
</FormField>
|
||||
<FormField
|
||||
label="Site URL (Optional)"
|
||||
tooltip="Your site URL for OpenRouter analytics (optional)"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
value={formState.CLAUDE_MEM_OPENROUTER_SITE_URL || ''}
|
||||
onChange={(e) => updateSetting('CLAUDE_MEM_OPENROUTER_SITE_URL', e.target.value)}
|
||||
placeholder="https://yoursite.com"
|
||||
/>
|
||||
</FormField>
|
||||
<FormField
|
||||
label="App Name (Optional)"
|
||||
tooltip="Your app name for OpenRouter analytics (optional)"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
value={formState.CLAUDE_MEM_OPENROUTER_APP_NAME || 'claude-mem'}
|
||||
onChange={(e) => updateSetting('CLAUDE_MEM_OPENROUTER_APP_NAME', e.target.value)}
|
||||
placeholder="claude-mem"
|
||||
/>
|
||||
</FormField>
|
||||
</>
|
||||
)}
|
||||
|
||||
<FormField
|
||||
label="Worker Port"
|
||||
tooltip="Port for the background worker service"
|
||||
|
||||
@@ -12,6 +12,10 @@ export const DEFAULT_SETTINGS = {
|
||||
CLAUDE_MEM_PROVIDER: 'claude',
|
||||
CLAUDE_MEM_GEMINI_API_KEY: '',
|
||||
CLAUDE_MEM_GEMINI_MODEL: 'gemini-2.5-flash-lite',
|
||||
CLAUDE_MEM_OPENROUTER_API_KEY: '',
|
||||
CLAUDE_MEM_OPENROUTER_MODEL: 'anthropic/claude-3.5-sonnet',
|
||||
CLAUDE_MEM_OPENROUTER_SITE_URL: '',
|
||||
CLAUDE_MEM_OPENROUTER_APP_NAME: 'claude-mem',
|
||||
CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED: 'true',
|
||||
|
||||
// Token Economics (all true for backwards compatibility)
|
||||
|
||||
@@ -61,10 +61,14 @@ export interface Settings {
|
||||
CLAUDE_MEM_WORKER_HOST: string;
|
||||
|
||||
// AI Provider Configuration
|
||||
CLAUDE_MEM_PROVIDER?: string; // 'claude' | 'gemini'
|
||||
CLAUDE_MEM_PROVIDER?: string; // 'claude' | 'gemini' | 'openrouter'
|
||||
CLAUDE_MEM_GEMINI_API_KEY?: string;
|
||||
CLAUDE_MEM_GEMINI_MODEL?: string; // 'gemini-2.5-flash-lite' | 'gemini-2.5-flash' | 'gemini-3-flash'
|
||||
CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED?: string; // 'true' | 'false'
|
||||
CLAUDE_MEM_OPENROUTER_API_KEY?: string;
|
||||
CLAUDE_MEM_OPENROUTER_MODEL?: string;
|
||||
CLAUDE_MEM_OPENROUTER_SITE_URL?: string;
|
||||
CLAUDE_MEM_OPENROUTER_APP_NAME?: string;
|
||||
|
||||
// Token Economics Display
|
||||
CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS?: string;
|
||||
|
||||
Reference in New Issue
Block a user