Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add claude models #515

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/shinkai-desktop/src/components/chat/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export const streamingSupportedModels = [
Models.Exo,
Models.Gemini,
Models.OpenRouter,
Models.Claude,
];
6 changes: 6 additions & 0 deletions apps/shinkai-desktop/src/pages/create-agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ const modelOptions: { value: Models; label: string }[] = [
value: Models.Exo,
label: 'Exo',
},
{
value: Models.Claude,
label: 'Claude',
},
];

export const getModelObject = (
Expand All @@ -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 } };
}
Expand Down
2 changes: 2 additions & 0 deletions apps/shinkai-visor/src/components/agents/add-agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 } };
}
Expand Down
2 changes: 2 additions & 0 deletions libs/shinkai-message-ts/src/api/jobs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,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}`;
Expand Down
5 changes: 5 additions & 0 deletions libs/shinkai-message-ts/src/api/jobs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export type LLMProviderInterface = {
Exo?: Exo;
Groq?: Groq;
OpenRouter?: OpenRouter;
Claude?: Claude;
} & {
[model: string]: ModelType;
};
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions libs/shinkai-message-ts/src/models/SchemaTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export type AgentAPIModel = {
Ollama?: Ollama;
Gemini?: Gemini;
Exo?: Exo;
Claude?: Claude;
} & {
[model: string]: ModelType;
};
Expand Down Expand Up @@ -303,6 +304,10 @@ export interface Exo {
model_type: string;
}

export interface Claude {
model_type: string;
}

export interface APIAddAgentRequest {
agent: SerializedLLMProvider;
}
Expand Down
22 changes: 22 additions & 0 deletions libs/shinkai-node-state/src/lib/utils/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum Models {
Exo = 'exo',
Groq = 'groq',
OpenRouter = 'openrouter',
Claude = 'claude',
}

export const modelsConfig = {
Expand Down Expand Up @@ -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',
},
],
},
};