Update all the models to take in context as user prompt

This commit is contained in:
Waleed Latif
2025-01-19 23:50:02 -08:00
parent f23350e6b4
commit 1075f8367f
4 changed files with 62 additions and 15 deletions
+14 -3
View File
@@ -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<ChatParams, ChatResponse> = {
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<ChatParams, ChatResponse> = {
'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,
+20 -6
View File
@@ -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<ChatParams, ChatResponse> = {
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<ChatParams, ChatResponse> = {
'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,
+14 -3
View File
@@ -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<ChatParams, ChatResponse> = {
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<ChatParams, ChatResponse> = {
'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,
+14 -3
View File
@@ -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<ChatParams, ChatResponse> = {
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<ChatParams, ChatResponse> = {
'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,