feat(providers): support OpenAI-compatible / Azure / Google Gemini endpoints (closes #16)
The hosted-API BYOK fallback was hard-wired to api.anthropic.com. Issue #16 asks for Azure (Microsoft OpenAI hosting Anthropic-style models) but the same plumbing unlocks every common BYOK target — OpenRouter, LiteLLM, DeepSeek, Groq, Together, Mistral, plus Google Gemini direct. Provider model: - New `provider: 'anthropic' | 'openai' | 'azure' | 'google'` discriminator on AppConfig (defaults to 'anthropic' so existing localStorage configs migrate seamlessly). - src/providers/model.ts routes to one of four streaming clients: anthropic.ts (existing SDK path), openai.ts (new SSE pump shared with azure.ts), azure.ts (deployment URL + api-key header), google.ts (Generative Language streamGenerateContent). - src/providers/presets.ts ships per-provider defaults (baseUrl, model suggestions, api-key placeholder, Azure api-version flag) so the UI can stay declarative. UI: - SettingsDialog now shows a provider picker on the Hosted-API tab and surfaces an Azure-only api-version field. Provider switches preserve any non-empty user values. - EntryView / AvatarMenu env meta line shows the active provider label. - en + zh-CN locales updated; README + README.zh-CN document every provider, with explicit guidance to reach AWS Bedrock / GCP Vertex Anthropic models via a server-side LiteLLM proxy (signing belongs on the server, not the browser). Why an OpenAI-compatible adapter rather than a native Bedrock/Vertex client: AWS SigV4 and GCP service-account JWTs aren't safe to do from a browser holding long-lived BYOK credentials. LiteLLM (or any Anthropic/OpenAI-compatible proxy) sidesteps that and is the same path lobe-chat uses for Bedrock/Vertex.
This commit is contained in:
@@ -1,10 +1,25 @@
|
||||
export type ExecMode = 'daemon' | 'api';
|
||||
|
||||
// Which BYOK model endpoint to talk to in `mode === 'api'`. Each provider
|
||||
// has its own request shape — see src/providers/{anthropic,openai,azure,
|
||||
// google}.ts for the wire details. AWS Bedrock and Google Vertex are
|
||||
// reached via the `anthropic` provider pointed at an Anthropic-compatible
|
||||
// proxy (e.g. LiteLLM), which keeps signing on the server where the
|
||||
// long-lived AWS / GCP credentials belong.
|
||||
export type ModelProvider = 'anthropic' | 'openai' | 'azure' | 'google';
|
||||
|
||||
export interface AppConfig {
|
||||
mode: ExecMode;
|
||||
// Active provider when `mode === 'api'`. Older configs that predate the
|
||||
// multi-provider rework default to 'anthropic' on load.
|
||||
provider: ModelProvider;
|
||||
apiKey: string;
|
||||
baseUrl: string;
|
||||
model: string;
|
||||
// Azure OpenAI only — the api-version query string the Azure REST
|
||||
// surface requires (e.g. '2024-08-01-preview'). Ignored by every other
|
||||
// provider so the same config can round-trip through localStorage.
|
||||
apiVersion?: string;
|
||||
agentId: string | null;
|
||||
skillId: string | null;
|
||||
designSystemId: string | null;
|
||||
|
||||
Reference in New Issue
Block a user