mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-26 21:28:50 +01:00
feat: EModelEndpoint.bedrock
This commit is contained in:
parent
f08a4226e8
commit
120a6a55fb
4 changed files with 37 additions and 17 deletions
|
|
@ -500,6 +500,7 @@ export const configSchema = z.object({
|
|||
[EModelEndpoint.assistants]: assistantEndpointSchema.optional(),
|
||||
[EModelEndpoint.agents]: agentsEndpointSChema.optional(),
|
||||
[EModelEndpoint.custom]: z.array(endpointSchema.partial()).optional(),
|
||||
[EModelEndpoint.bedrock]: baseEndpointSchema.optional(),
|
||||
})
|
||||
.strict()
|
||||
.refine((data) => Object.keys(data).length > 0, {
|
||||
|
|
@ -552,6 +553,7 @@ export const defaultEndpoints: EModelEndpoint[] = [
|
|||
EModelEndpoint.google,
|
||||
EModelEndpoint.anthropic,
|
||||
EModelEndpoint.custom,
|
||||
EModelEndpoint.bedrock,
|
||||
];
|
||||
|
||||
export const alternateName = {
|
||||
|
|
@ -566,6 +568,7 @@ export const alternateName = {
|
|||
[EModelEndpoint.google]: 'Google',
|
||||
[EModelEndpoint.anthropic]: 'Anthropic',
|
||||
[EModelEndpoint.custom]: 'Custom',
|
||||
[EModelEndpoint.bedrock]: 'Bedrock',
|
||||
};
|
||||
|
||||
const sharedOpenAIModels = [
|
||||
|
|
@ -588,6 +591,20 @@ const sharedOpenAIModels = [
|
|||
'gpt-3.5-turbo-0613',
|
||||
];
|
||||
|
||||
const sharedAnthropicModels = [
|
||||
'claude-3-5-sonnet-20240620',
|
||||
'claude-3-opus-20240229',
|
||||
'claude-3-sonnet-20240229',
|
||||
'claude-3-haiku-20240307',
|
||||
'claude-2.1',
|
||||
'claude-2',
|
||||
'claude-1.2',
|
||||
'claude-1',
|
||||
'claude-1-100k',
|
||||
'claude-instant-1',
|
||||
'claude-instant-1-100k',
|
||||
];
|
||||
|
||||
export const defaultModels = {
|
||||
[EModelEndpoint.azureAssistants]: sharedOpenAIModels,
|
||||
[EModelEndpoint.assistants]: ['chatgpt-4o-latest', ...sharedOpenAIModels],
|
||||
|
|
@ -606,19 +623,7 @@ export const defaultModels = {
|
|||
'code-bison',
|
||||
'code-bison-32k',
|
||||
],
|
||||
[EModelEndpoint.anthropic]: [
|
||||
'claude-3-5-sonnet-20240620',
|
||||
'claude-3-opus-20240229',
|
||||
'claude-3-sonnet-20240229',
|
||||
'claude-3-haiku-20240307',
|
||||
'claude-2.1',
|
||||
'claude-2',
|
||||
'claude-1.2',
|
||||
'claude-1',
|
||||
'claude-1-100k',
|
||||
'claude-instant-1',
|
||||
'claude-instant-1-100k',
|
||||
],
|
||||
[EModelEndpoint.anthropic]: sharedAnthropicModels,
|
||||
[EModelEndpoint.openAI]: [
|
||||
'chatgpt-4o-latest',
|
||||
...sharedOpenAIModels,
|
||||
|
|
@ -626,6 +631,7 @@ export const defaultModels = {
|
|||
'gpt-3.5-turbo-instruct-0914',
|
||||
'gpt-3.5-turbo-instruct',
|
||||
],
|
||||
[EModelEndpoint.bedrock]: sharedAnthropicModels,
|
||||
};
|
||||
|
||||
const fitlerAssistantModels = (str: string) => {
|
||||
|
|
@ -645,6 +651,7 @@ export const initialModelsConfig: TModelsConfig = {
|
|||
[EModelEndpoint.chatGPTBrowser]: ['text-davinci-002-render-sha'],
|
||||
[EModelEndpoint.google]: defaultModels[EModelEndpoint.google],
|
||||
[EModelEndpoint.anthropic]: defaultModels[EModelEndpoint.anthropic],
|
||||
[EModelEndpoint.bedrock]: defaultModels[EModelEndpoint.bedrock],
|
||||
};
|
||||
|
||||
export const EndpointURLs: { [key in EModelEndpoint]: string } = {
|
||||
|
|
@ -658,7 +665,8 @@ export const EndpointURLs: { [key in EModelEndpoint]: string } = {
|
|||
[EModelEndpoint.chatGPTBrowser]: `/api/ask/${EModelEndpoint.chatGPTBrowser}`,
|
||||
[EModelEndpoint.azureAssistants]: '/api/assistants/v1/chat',
|
||||
[EModelEndpoint.assistants]: '/api/assistants/v2/chat',
|
||||
[EModelEndpoint.agents]: '/api/agents/chat',
|
||||
[EModelEndpoint.agents]: `/api/${EModelEndpoint.agents}/chat`,
|
||||
[EModelEndpoint.bedrock]: `/api/${EModelEndpoint.bedrock}/chat`,
|
||||
};
|
||||
|
||||
export const modularEndpoints = new Set<EModelEndpoint | string>([
|
||||
|
|
@ -668,6 +676,8 @@ export const modularEndpoints = new Set<EModelEndpoint | string>([
|
|||
EModelEndpoint.openAI,
|
||||
EModelEndpoint.azureOpenAI,
|
||||
EModelEndpoint.custom,
|
||||
EModelEndpoint.agents,
|
||||
EModelEndpoint.bedrock,
|
||||
]);
|
||||
|
||||
export const supportsBalanceCheck = {
|
||||
|
|
@ -679,6 +689,7 @@ export const supportsBalanceCheck = {
|
|||
[EModelEndpoint.agents]: true,
|
||||
[EModelEndpoint.azureAssistants]: true,
|
||||
[EModelEndpoint.azureOpenAI]: true,
|
||||
[EModelEndpoint.bedrock]: true,
|
||||
};
|
||||
|
||||
export const visionModels = [
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ export const supportsFiles = {
|
|||
[EModelEndpoint.azureOpenAI]: true,
|
||||
[EModelEndpoint.anthropic]: true,
|
||||
[EModelEndpoint.custom]: true,
|
||||
[EModelEndpoint.bedrock]: true,
|
||||
};
|
||||
|
||||
export const excelFileTypes = [
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ type EndpointSchema =
|
|||
| typeof chatGPTBrowserSchema
|
||||
| typeof gptPluginsSchema
|
||||
| typeof assistantSchema
|
||||
| typeof compactAgentsSchema
|
||||
| typeof compactAgentsSchema;
|
||||
|
||||
const endpointSchemas: Record<EModelEndpoint, EndpointSchema> = {
|
||||
|
|
@ -45,6 +46,7 @@ const endpointSchemas: Record<EModelEndpoint, EndpointSchema> = {
|
|||
[EModelEndpoint.assistants]: assistantSchema,
|
||||
[EModelEndpoint.azureAssistants]: assistantSchema,
|
||||
[EModelEndpoint.agents]: compactAgentsSchema,
|
||||
[EModelEndpoint.bedrock]: compactAgentsSchema,
|
||||
};
|
||||
|
||||
// const schemaCreators: Record<EModelEndpoint, (customSchema: DefaultSchemaValues) => EndpointSchema> = {
|
||||
|
|
@ -64,6 +66,7 @@ export function getEnabledEndpoints() {
|
|||
EModelEndpoint.chatGPTBrowser,
|
||||
EModelEndpoint.gptPlugins,
|
||||
EModelEndpoint.anthropic,
|
||||
EModelEndpoint.bedrock,
|
||||
];
|
||||
|
||||
const endpointsEnv = process.env.ENDPOINTS ?? '';
|
||||
|
|
@ -231,6 +234,8 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
|
|||
return 'GPT-3.5';
|
||||
} else if (model && model.includes('gpt-4')) {
|
||||
return 'GPT-4';
|
||||
} else if (model && model.includes('gpt-4o')) {
|
||||
return 'GPT-4o';
|
||||
} else if (model && model.includes('mistral')) {
|
||||
return 'Mistral';
|
||||
}
|
||||
|
|
@ -238,7 +243,7 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
|
|||
}
|
||||
|
||||
if (endpoint === EModelEndpoint.bingAI) {
|
||||
return jailbreak ? 'Sydney' : 'BingAI';
|
||||
return jailbreak === true ? 'Sydney' : 'BingAI';
|
||||
}
|
||||
|
||||
if (endpoint === EModelEndpoint.anthropic) {
|
||||
|
|
@ -296,6 +301,7 @@ const compactEndpointSchemas: Record<string, CompactEndpointSchema> = {
|
|||
[EModelEndpoint.azureAssistants]: compactAssistantSchema,
|
||||
[EModelEndpoint.agents]: compactAgentsSchema,
|
||||
[EModelEndpoint.google]: compactGoogleSchema,
|
||||
[EModelEndpoint.bedrock]: compactAgentsSchema,
|
||||
/* BingAI needs all fields */
|
||||
[EModelEndpoint.bingAI]: bingAISchema,
|
||||
[EModelEndpoint.anthropic]: compactAnthropicSchema,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ export enum EModelEndpoint {
|
|||
azureAssistants = 'azureAssistants',
|
||||
agents = 'agents',
|
||||
custom = 'custom',
|
||||
bedrock = 'bedrock',
|
||||
}
|
||||
|
||||
export type AssistantsEndpoint = EModelEndpoint.assistants | EModelEndpoint.azureAssistants;
|
||||
|
|
@ -295,6 +296,7 @@ export const endpointSettings = {
|
|||
[EModelEndpoint.google]: googleSettings,
|
||||
[EModelEndpoint.anthropic]: anthropicSettings,
|
||||
[EModelEndpoint.agents]: agentsSettings,
|
||||
[EModelEndpoint.bedrock]: agentsSettings,
|
||||
};
|
||||
|
||||
const google = endpointSettings[EModelEndpoint.google];
|
||||
|
|
@ -618,7 +620,7 @@ export const openAISchema = tConversationSchema
|
|||
max_tokens: obj.max_tokens ?? undefined,
|
||||
};
|
||||
|
||||
if (obj.modelLabel) {
|
||||
if (obj.modelLabel != null && obj.modelLabel !== '') {
|
||||
result.modelLabel = null;
|
||||
}
|
||||
|
||||
|
|
@ -836,7 +838,7 @@ export const gptPluginsSchema = tConversationSchema
|
|||
maxContextTokens: obj.maxContextTokens ?? undefined,
|
||||
};
|
||||
|
||||
if (obj.modelLabel) {
|
||||
if (obj.modelLabel != null && obj.modelLabel !== '') {
|
||||
result.modelLabel = null;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue