Add custom OpenAI- and Anthropic-compatible providers
New 'Custom OpenAI-compatible' and 'Custom Anthropic-compatible' providers let an agent run against any compatible endpoint by base URL + key: the turn posts Chat Completions (/chat/completions) or Anthropic Messages (/v1/messages) at the configured base URL. Backfilled into existing orgs by migration 037.
This commit is contained in:
1 parent
937fdfa23f
commit
6c68836455
12 files changed
+170
-4
No files matched your search
@@ -5,14 +5,18 @@ import {
|
||||
parseAccessToken,
|
||||
parseAccountToken,
|
||||
parseApiKey,
|
||||
parseAnthropicCompatProfile,
|
||||
parseAzureProfile,
|
||||
parseBedrockProfile,
|
||||
parseOpenAiCompatProfile,
|
||||
parseVertexProfile,
|
||||
requireAccessTokenProfile,
|
||||
requireAccountTokenProfile,
|
||||
requireAnthropicCompatProfile,
|
||||
requireApiKeyProfile,
|
||||
requireAzureProfile,
|
||||
requireBedrockProfile,
|
||||
requireOpenAiCompatProfile,
|
||||
requireVertexProfile,
|
||||
type ProviderAuthProfile,
|
||||
} from "./provider-auth-profiles";
|
||||
@@ -330,6 +334,42 @@ export const providerAdapters: ProviderAdapterRegistry = {
|
||||
return healthy(null);
|
||||
},
|
||||
},
|
||||
"custom-openai": {
|
||||
providerKey: "custom-openai",
|
||||
authType: PROVIDER_AUTH_TYPE.CLOUD,
|
||||
authorize: authorizeWithParser(parseOpenAiCompatProfile),
|
||||
refresh: refreshUnsupported("Custom OpenAI-compatible endpoint"),
|
||||
revoke: revokeLocalProfile((profile) => { requireOpenAiCompatProfile(profile); }),
|
||||
parseAuthProfile: parseOpenAiCompatProfile,
|
||||
listModels: () => listStaticModels("custom-openai"),
|
||||
getRateLimitState: providerRateLimitUnknown,
|
||||
streamResponse: streamUnsupported("Custom OpenAI-compatible endpoint"),
|
||||
cancelResponse: cancelUnsupported("Custom OpenAI-compatible endpoint"),
|
||||
createBackgroundResponse: backgroundUnsupported("Custom OpenAI-compatible endpoint"),
|
||||
retrieveResponse: retrieveUnsupported("Custom OpenAI-compatible endpoint"),
|
||||
checkHealth: async (input) => {
|
||||
requireOpenAiCompatProfile(input.authProfile);
|
||||
return healthy(null);
|
||||
},
|
||||
},
|
||||
"custom-anthropic": {
|
||||
providerKey: "custom-anthropic",
|
||||
authType: PROVIDER_AUTH_TYPE.CLOUD,
|
||||
authorize: authorizeWithParser(parseAnthropicCompatProfile),
|
||||
refresh: refreshUnsupported("Custom Anthropic-compatible endpoint"),
|
||||
revoke: revokeLocalProfile((profile) => { requireAnthropicCompatProfile(profile); }),
|
||||
parseAuthProfile: parseAnthropicCompatProfile,
|
||||
listModels: () => listStaticModels("custom-anthropic"),
|
||||
getRateLimitState: providerRateLimitUnknown,
|
||||
streamResponse: streamUnsupported("Custom Anthropic-compatible endpoint"),
|
||||
cancelResponse: cancelUnsupported("Custom Anthropic-compatible endpoint"),
|
||||
createBackgroundResponse: backgroundUnsupported("Custom Anthropic-compatible endpoint"),
|
||||
retrieveResponse: retrieveUnsupported("Custom Anthropic-compatible endpoint"),
|
||||
checkHealth: async (input) => {
|
||||
requireAnthropicCompatProfile(input.authProfile);
|
||||
return healthy(null);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
function collectText(value: unknown): string[] {
|
||||
|
||||
Reference in new issue
Block a user