From 7901b842e4215876c9c117410f816adf50a6da29 Mon Sep 17 00:00:00 2001 From: benolt Date: Wed, 30 Oct 2024 09:49:16 +0100 Subject: [PATCH] feat: add claude models --- .../src/components/chat/constants.ts | 1 + .../src/pages/create-agent.tsx | 6 +++++ .../src/components/agents/add-agent.tsx | 2 ++ libs/shinkai-message-ts/src/api/jobs/index.ts | 2 ++ libs/shinkai-message-ts/src/api/jobs/types.ts | 5 +++++ .../src/models/SchemaTypes.ts | 5 +++++ .../src/lib/utils/models.ts | 22 +++++++++++++++++++ 7 files changed, 43 insertions(+) diff --git a/apps/shinkai-desktop/src/components/chat/constants.ts b/apps/shinkai-desktop/src/components/chat/constants.ts index a73c7653f..8d64299d9 100644 --- a/apps/shinkai-desktop/src/components/chat/constants.ts +++ b/apps/shinkai-desktop/src/components/chat/constants.ts @@ -5,4 +5,5 @@ export const streamingSupportedModels = [ Models.Exo, Models.Gemini, Models.OpenRouter, + Models.Claude, ]; diff --git a/apps/shinkai-desktop/src/pages/create-agent.tsx b/apps/shinkai-desktop/src/pages/create-agent.tsx index a44af7175..f4d6718e9 100644 --- a/apps/shinkai-desktop/src/pages/create-agent.tsx +++ b/apps/shinkai-desktop/src/pages/create-agent.tsx @@ -67,6 +67,10 @@ const modelOptions: { value: Models; label: string }[] = [ value: Models.Exo, label: 'Exo', }, + { + value: Models.Claude, + label: 'Claude', + }, ]; export const getModelObject = ( @@ -84,6 +88,8 @@ export const getModelObject = ( return { Gemini: { model_type: modelType } }; case Models.Exo: return { Exo: { model_type: modelType } }; + case Models.Claude: + return { Claude: { model_type: modelType } }; default: return { [model]: { model_type: modelType } }; } diff --git a/apps/shinkai-visor/src/components/agents/add-agent.tsx b/apps/shinkai-visor/src/components/agents/add-agent.tsx index 128e247f6..347205abd 100644 --- a/apps/shinkai-visor/src/components/agents/add-agent.tsx +++ b/apps/shinkai-visor/src/components/agents/add-agent.tsx @@ -51,6 +51,8 @@ export const getModelObject = ( return { Groq: { model_type: modelType } }; case Models.OpenRouter: return { OpenRouter: { model_type: modelType } }; + case Models.Claude: + return { Claude: { model_type: modelType } }; default: return { [model]: { model_type: modelType } }; } diff --git a/libs/shinkai-message-ts/src/api/jobs/index.ts b/libs/shinkai-message-ts/src/api/jobs/index.ts index f7f591be4..163a2d3ff 100644 --- a/libs/shinkai-message-ts/src/api/jobs/index.ts +++ b/libs/shinkai-message-ts/src/api/jobs/index.ts @@ -215,6 +215,8 @@ function getModelString(model: LLMProviderInterface): string { return 'openrouter:' + model.OpenRouter.model_type; } else if (model?.Exo?.model_type) { return 'exo:' + model.Exo.model_type; + } else if (model?.Claude?.model_type) { + return 'claude:' + model.Claude.model_type; } else if (Object.keys(model).length > 0) { const customModelProvider = Object.keys(model)[0]; return `${customModelProvider}:${model[customModelProvider].model_type}`; diff --git a/libs/shinkai-message-ts/src/api/jobs/types.ts b/libs/shinkai-message-ts/src/api/jobs/types.ts index ac1911c93..63e050546 100644 --- a/libs/shinkai-message-ts/src/api/jobs/types.ts +++ b/libs/shinkai-message-ts/src/api/jobs/types.ts @@ -184,6 +184,7 @@ export type LLMProviderInterface = { Exo?: Exo; Groq?: Groq; OpenRouter?: OpenRouter; + Claude?: Claude; } & { [model: string]: ModelType; }; @@ -219,6 +220,10 @@ export interface Exo { model_type: string; } +export interface Claude { + model_type: string; +} + export type SerializedLLMProvider = { id: string; full_identity_name: string; diff --git a/libs/shinkai-message-ts/src/models/SchemaTypes.ts b/libs/shinkai-message-ts/src/models/SchemaTypes.ts index 448aff8b5..47171ccdd 100644 --- a/libs/shinkai-message-ts/src/models/SchemaTypes.ts +++ b/libs/shinkai-message-ts/src/models/SchemaTypes.ts @@ -268,6 +268,7 @@ export type AgentAPIModel = { Ollama?: Ollama; Gemini?: Gemini; Exo?: Exo; + Claude?: Claude; } & { [model: string]: ModelType; }; @@ -303,6 +304,10 @@ export interface Exo { model_type: string; } +export interface Claude { + model_type: string; +} + export interface APIAddAgentRequest { agent: SerializedLLMProvider; } diff --git a/libs/shinkai-node-state/src/lib/utils/models.ts b/libs/shinkai-node-state/src/lib/utils/models.ts index dd28ea69f..90a30b981 100644 --- a/libs/shinkai-node-state/src/lib/utils/models.ts +++ b/libs/shinkai-node-state/src/lib/utils/models.ts @@ -6,6 +6,7 @@ export enum Models { Exo = 'exo', Groq = 'groq', OpenRouter = 'openrouter', + Claude = 'claude', } export const modelsConfig = { @@ -107,4 +108,25 @@ export const modelsConfig = { apiUrl: 'https://openrouter.ai', modelTypes: [], }, + [Models.Claude]: { + apiUrl: 'https://api.anthropic.com', + modelTypes: [ + { + name: 'Claude 3.5 Sonnet', + value: 'claude-3-5-sonnet-latest', + }, + { + name: 'Claude 3 Opus', + value: 'claude-3-opus-latest', + }, + { + name: 'Claude 3 Sonnet', + value: 'claude-3-sonnet-20240229', + }, + { + name: 'Claude 3 Haiku', + value: 'claude-3-haiku-20240307', + }, + ], + }, };