diff --git a/tools/anthropic/chat.ts b/tools/anthropic/chat.ts index 1de27e47a2..6ca18fef86 100644 --- a/tools/anthropic/chat.ts +++ b/tools/anthropic/chat.ts @@ -3,6 +3,7 @@ import { ToolConfig, ToolResponse } from '../types'; interface ChatParams { apiKey: string; systemPrompt: string; + context?: string; model?: string; temperature?: number; maxTokens?: number; @@ -32,6 +33,10 @@ export const chatTool: ToolConfig = { required: true, description: 'System prompt to send to the model' }, + context: { + type: 'string', + description: 'User message/context to send to the model' + }, model: { type: 'string', default: 'claude-3-5-sonnet-20241022', @@ -53,11 +58,17 @@ export const chatTool: ToolConfig = { 'anthropic-version': '2023-06-01' }), body: (params) => { + const messages = [ + { role: 'user', content: params.systemPrompt } + ]; + + if (params.context) { + messages.push({ role: 'user', content: params.context }); + } + const body = { model: params.model || 'claude-3-5-sonnet-20241022', - messages: [ - { role: 'user', content: params.systemPrompt } - ], + messages, temperature: params.temperature, max_tokens: params.maxTokens, top_p: params.topP, diff --git a/tools/google/chat.ts b/tools/google/chat.ts index 9f6cce6cc4..d3637d0d2e 100644 --- a/tools/google/chat.ts +++ b/tools/google/chat.ts @@ -3,6 +3,7 @@ import { ToolConfig, ToolResponse } from '../types'; interface ChatParams { apiKey: string; systemPrompt: string; + context?: string; model?: string; temperature?: number; maxTokens?: number; @@ -33,6 +34,10 @@ export const chatTool: ToolConfig = { required: true, description: 'System prompt to send to the model' }, + context: { + type: 'string', + description: 'User message/context to send to the model' + }, model: { type: 'string', default: 'gemini-pro', @@ -53,13 +58,22 @@ export const chatTool: ToolConfig = { 'x-goog-api-key': params.apiKey }), body: (params) => { + const contents = [ + { + role: 'model', + parts: [{ text: params.systemPrompt }] + } + ]; + + if (params.context) { + contents.push({ + role: 'user', + parts: [{ text: params.context }] + }); + } + const body = { - contents: [ - { - role: 'user', - parts: [{ text: params.systemPrompt }] - } - ], + contents, generationConfig: { temperature: params.temperature, maxOutputTokens: params.maxTokens, diff --git a/tools/openai/chat.ts b/tools/openai/chat.ts index ce050180bc..c65b12c36a 100644 --- a/tools/openai/chat.ts +++ b/tools/openai/chat.ts @@ -3,6 +3,7 @@ import { ToolConfig, ToolResponse } from '../types'; interface ChatParams { apiKey: string; systemPrompt: string; + context?: string; model?: string; temperature?: number; maxTokens?: number; @@ -34,6 +35,10 @@ export const chatTool: ToolConfig = { required: true, description: 'System prompt to send to the model' }, + context: { + type: 'string', + description: 'User message/context to send to the model' + }, model: { type: 'string', default: 'gpt-4o', @@ -54,11 +59,17 @@ export const chatTool: ToolConfig = { 'Authorization': `Bearer ${params.apiKey}` }), body: (params) => { + const messages = [ + { role: 'system', content: params.systemPrompt } + ]; + + if (params.context) { + messages.push({ role: 'user', content: params.context }); + } + const body = { model: params.model || 'gpt-4o', - messages: [ - { role: 'system', content: params.systemPrompt } - ], + messages, temperature: params.temperature, max_tokens: params.maxTokens, top_p: params.topP, diff --git a/tools/xai/chat.ts b/tools/xai/chat.ts index 151673f76f..cb6927668a 100644 --- a/tools/xai/chat.ts +++ b/tools/xai/chat.ts @@ -3,6 +3,7 @@ import { ToolConfig, ToolResponse } from '../types'; interface ChatParams { apiKey: string; systemPrompt: string; + context?: string; model?: string; temperature?: number; maxTokens?: number; @@ -34,6 +35,10 @@ export const chatTool: ToolConfig = { required: true, description: 'System prompt to send to the model' }, + context: { + type: 'string', + description: 'User message/context to send to the model' + }, model: { type: 'string', default: 'grok-2-latest', @@ -54,11 +59,17 @@ export const chatTool: ToolConfig = { 'Authorization': `Bearer ${params.apiKey}` }), body: (params) => { + const messages = [ + { role: 'system', content: params.systemPrompt } + ]; + + if (params.context) { + messages.push({ role: 'user', content: params.context }); + } + const body = { model: params.model || 'grok-2-latest', - messages: [ - { role: 'system', content: params.systemPrompt } - ], + messages, temperature: params.temperature, max_tokens: params.maxTokens, top_p: params.topP,