mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
feat(providers): removed providers from tools directory, added cerebras sdk
This commit is contained in:
@@ -1,112 +0,0 @@
|
||||
import { ToolConfig, ToolResponse } from '../types'
|
||||
|
||||
export interface ChatParams {
|
||||
apiKey: string
|
||||
systemPrompt: string
|
||||
context?: string
|
||||
model?: string
|
||||
temperature?: number
|
||||
maxTokens?: number
|
||||
topP?: number
|
||||
stream?: boolean
|
||||
}
|
||||
|
||||
export interface ChatResponse extends ToolResponse {
|
||||
output: {
|
||||
content: string
|
||||
model: string
|
||||
tokens?: number
|
||||
}
|
||||
}
|
||||
|
||||
export const chatTool: ToolConfig<ChatParams, ChatResponse> = {
|
||||
id: 'anthropic_chat',
|
||||
name: 'Anthropic Chat',
|
||||
description:
|
||||
"Interact with Anthropic's Claude models for advanced language understanding, reasoning, and generation tasks. Supports system prompts, context management, and configurable parameters for response generation.",
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Anthropic API key',
|
||||
},
|
||||
systemPrompt: {
|
||||
type: 'string',
|
||||
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-7-sonnet-20250219',
|
||||
description: 'Model to use',
|
||||
},
|
||||
temperature: {
|
||||
type: 'number',
|
||||
default: 0.7,
|
||||
description: 'Controls randomness in the response',
|
||||
},
|
||||
maxTokens: {
|
||||
type: 'number',
|
||||
default: 4096,
|
||||
description: 'Maximum number of tokens to generate',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: 'https://api.anthropic.com/v1/messages',
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
'Content-Type': 'application/json',
|
||||
'x-api-key': params.apiKey,
|
||||
'anthropic-version': '2023-06-01',
|
||||
}),
|
||||
body: (params) => {
|
||||
const messages = []
|
||||
|
||||
// Add user message if context is provided
|
||||
if (params.context) {
|
||||
messages.push({
|
||||
role: 'user',
|
||||
content: params.context,
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
model: params.model || 'claude-3-7-sonnet-20250219',
|
||||
messages,
|
||||
system: params.systemPrompt,
|
||||
temperature: params.temperature || 0.7,
|
||||
max_tokens: params.maxTokens || 4096,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
if (!data.content) {
|
||||
throw new Error('Unable to extract content from Anthropic API response')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content: data.content[0].text,
|
||||
model: data.model,
|
||||
tokens: data.usage?.input_tokens + data.usage?.output_tokens,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
transformError: (error) => {
|
||||
const message = error.error?.message || error.message
|
||||
const code = error.error?.type || error.code
|
||||
return `${message} (${code})`
|
||||
},
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
import { ToolConfig, ToolResponse } from '../types'
|
||||
|
||||
interface Message {
|
||||
role: 'system' | 'user' | 'assistant'
|
||||
content: string
|
||||
}
|
||||
|
||||
export interface ChatParams {
|
||||
apiKey: string
|
||||
systemPrompt?: string
|
||||
context?: string
|
||||
model?: string
|
||||
temperature?: number
|
||||
responseFormat?: string
|
||||
}
|
||||
|
||||
export interface ChatResponse extends ToolResponse {
|
||||
output: {
|
||||
content: string
|
||||
model: string
|
||||
tokens?: number
|
||||
}
|
||||
}
|
||||
|
||||
export const chatTool: ToolConfig<ChatParams, ChatResponse> = {
|
||||
id: 'deepseek_chat',
|
||||
name: 'DeepSeek Chat',
|
||||
description:
|
||||
"Interact with DeepSeek's advanced language models optimized for code understanding and generation. Supports system prompts, context-aware responses, and configurable output formats.",
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'DeepSeek API key',
|
||||
},
|
||||
systemPrompt: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'System prompt to guide the model',
|
||||
},
|
||||
context: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'User input context',
|
||||
},
|
||||
model: {
|
||||
type: 'string',
|
||||
default: 'deepseek-chat',
|
||||
description: 'Model to use',
|
||||
},
|
||||
temperature: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
default: 0.7,
|
||||
description: 'Sampling temperature',
|
||||
},
|
||||
responseFormat: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Response format specification',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: 'https://api.deepseek.com/v1/chat/completions',
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
}),
|
||||
body: (params) => {
|
||||
const messages: Message[] = []
|
||||
|
||||
if (params.systemPrompt) {
|
||||
messages.push({
|
||||
role: 'system',
|
||||
content: params.systemPrompt,
|
||||
})
|
||||
}
|
||||
|
||||
if (params.context) {
|
||||
messages.push({
|
||||
role: 'user',
|
||||
content: params.context,
|
||||
})
|
||||
}
|
||||
|
||||
const body: any = {
|
||||
model: 'deepseek-chat',
|
||||
messages,
|
||||
temperature: params.temperature,
|
||||
}
|
||||
|
||||
if (params.responseFormat === 'json') {
|
||||
body.response_format = { type: 'json_object' }
|
||||
}
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
async transformResponse(response: Response): Promise<ChatResponse> {
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
throw new Error(`DeepSeek API error: ${error.message || response.statusText}`)
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content: data.choices[0].message.content,
|
||||
model: data.model,
|
||||
tokens: data.usage?.total_tokens,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
transformError(error: any): string {
|
||||
const message = error.error?.message || error.message
|
||||
const code = error.error?.type || error.code
|
||||
return `${message} (${code})`
|
||||
},
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
import { ToolConfig, ToolResponse } from '../types'
|
||||
|
||||
interface Message {
|
||||
role: 'system' | 'user' | 'assistant'
|
||||
content: string
|
||||
}
|
||||
|
||||
export interface ChatParams {
|
||||
apiKey: string
|
||||
systemPrompt?: string
|
||||
context?: string
|
||||
model?: string
|
||||
temperature?: number
|
||||
}
|
||||
|
||||
export interface ChatResponse extends ToolResponse {
|
||||
output: {
|
||||
content: string
|
||||
model: string
|
||||
tokens?: number
|
||||
}
|
||||
}
|
||||
|
||||
export const reasonerTool: ToolConfig<ChatParams, ChatResponse> = {
|
||||
id: 'deepseek_reasoner',
|
||||
name: 'DeepSeek Reasoner',
|
||||
description:
|
||||
"Leverage DeepSeek's specialized reasoning model for complex problem-solving, logical analysis, and step-by-step deduction. Optimized for tasks requiring structured thinking and detailed explanations.",
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'DeepSeek API key',
|
||||
},
|
||||
systemPrompt: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'System prompt to guide the model',
|
||||
},
|
||||
context: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'User input context',
|
||||
},
|
||||
model: {
|
||||
type: 'string',
|
||||
default: 'deepseek-reasoner',
|
||||
description: 'Model to use',
|
||||
},
|
||||
temperature: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
description: 'Temperature (has no effect on reasoner)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: 'https://api.deepseek.com/v1/chat/completions',
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
}),
|
||||
body: (params) => {
|
||||
const messages: Message[] = []
|
||||
|
||||
if (params.systemPrompt) {
|
||||
messages.push({
|
||||
role: 'system',
|
||||
content: params.systemPrompt,
|
||||
})
|
||||
}
|
||||
|
||||
// Always ensure the last message is a user message
|
||||
if (params.context) {
|
||||
messages.push({
|
||||
role: 'user',
|
||||
content: params.context,
|
||||
})
|
||||
} else if (params.systemPrompt) {
|
||||
// If we have a system prompt but no context, add an empty user message
|
||||
messages.push({
|
||||
role: 'user',
|
||||
content: 'Please respond.',
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
model: 'deepseek-reasoner',
|
||||
messages,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
async transformResponse(response: Response): Promise<ChatResponse> {
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
throw new Error(`DeepSeek API error: ${error.message || response.statusText}`)
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content: data.choices[0].message.content,
|
||||
model: data.model,
|
||||
tokens: data.usage?.total_tokens,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
transformError(error: any): string {
|
||||
const message = error.error?.message || error.message
|
||||
const code = error.error?.type || error.code
|
||||
return `${message} (${code})`
|
||||
},
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
import { ToolConfig, ToolResponse } from '../types'
|
||||
|
||||
export interface ChatParams {
|
||||
apiKey: string
|
||||
systemPrompt: string
|
||||
context?: string
|
||||
model?: string
|
||||
temperature?: number
|
||||
maxTokens?: number
|
||||
topP?: number
|
||||
topK?: number
|
||||
}
|
||||
|
||||
export interface ChatResponse extends ToolResponse {
|
||||
output: {
|
||||
content: string
|
||||
model: string
|
||||
tokens?: number
|
||||
safetyRatings?: any[]
|
||||
}
|
||||
}
|
||||
|
||||
export const chatTool: ToolConfig<ChatParams, ChatResponse> = {
|
||||
id: 'google_chat',
|
||||
name: 'Google Chat',
|
||||
description:
|
||||
"Interact with Google's Gemini models for advanced language tasks with built-in safety ratings. Supports system prompts, context management, and fine-tuned generation parameters including top-k and top-p sampling.",
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Google API key',
|
||||
},
|
||||
systemPrompt: {
|
||||
type: 'string',
|
||||
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-2.0-flash-001',
|
||||
description: 'Model to use',
|
||||
},
|
||||
temperature: {
|
||||
type: 'number',
|
||||
default: 0.7,
|
||||
description: 'Controls randomness in the response',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: 'https://generativelanguage.googleapis.com/v1/models/gemini-2.0-flash-001:generateContent',
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
'Content-Type': 'application/json',
|
||||
'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,
|
||||
generationConfig: {
|
||||
temperature: params.temperature,
|
||||
maxOutputTokens: params.maxTokens,
|
||||
topP: params.topP,
|
||||
topK: params.topK,
|
||||
},
|
||||
}
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content: data.candidates[0].content.parts[0].text,
|
||||
model: data.model,
|
||||
tokens: data.usage?.totalTokens,
|
||||
safetyRatings: data.candidates[0].safetyRatings,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
transformError: (error) => {
|
||||
const message = error.error?.message || error.message
|
||||
const code = error.error?.status || error.code
|
||||
return `${message} (${code})`
|
||||
},
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
import { chatTool as anthropicChat } from './anthropic/chat'
|
||||
import { visionTool as crewAIVision } from './crewai/vision'
|
||||
import { chatTool as deepseekChat } from './deepseek/chat'
|
||||
import { reasonerTool as deepseekReasoner } from './deepseek/reasoner'
|
||||
import { scrapeTool } from './firecrawl/scrape'
|
||||
import { functionExecuteTool as functionExecute } from './function/execute'
|
||||
import { commentTool } from './github/comment'
|
||||
@@ -10,13 +7,11 @@ import { repoInfoTool } from './github/repo'
|
||||
import { gmailReadTool } from './gmail/read'
|
||||
import { gmailSearchTool } from './gmail/search'
|
||||
import { gmailSendTool } from './gmail/send'
|
||||
import { chatTool as googleChat } from './google/chat'
|
||||
import { requestTool as httpRequest } from './http/request'
|
||||
import { contactsTool as hubspotContacts } from './hubspot/contacts'
|
||||
import { readUrlTool } from './jina/reader'
|
||||
import { notionReadTool } from './notion/read'
|
||||
import { notionWriteTool } from './notion/write'
|
||||
import { chatTool as openAIChat } from './openai/chat'
|
||||
import { embeddingsTool as openAIEmbeddings } from './openai/embeddings'
|
||||
import { fetchTool as pineconeFetchTool } from './pinecone/fetch'
|
||||
import { generateEmbeddingsTool as pineconeGenerateEmbeddingsTool } from './pinecone/generate'
|
||||
@@ -33,18 +28,11 @@ import { readTool as xRead } from './x/read'
|
||||
import { searchTool as xSearch } from './x/search'
|
||||
import { userTool as xUser } from './x/user'
|
||||
import { writeTool as xWrite } from './x/write'
|
||||
import { chatTool as xaiChat } from './xai/chat'
|
||||
import { youtubeSearchTool } from './youtube/search'
|
||||
|
||||
// Registry of all available tools
|
||||
export const tools: Record<string, ToolConfig> = {
|
||||
openai_chat: openAIChat,
|
||||
openai_embeddings: openAIEmbeddings,
|
||||
anthropic_chat: anthropicChat,
|
||||
google_chat: googleChat,
|
||||
xai_chat: xaiChat,
|
||||
deepseek_chat: deepseekChat,
|
||||
deepseek_reasoner: deepseekReasoner,
|
||||
http_request: httpRequest,
|
||||
hubspot_contacts: hubspotContacts,
|
||||
salesforce_opportunities: salesforceOpportunities,
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
import { ToolConfig, ToolResponse } from '../types'
|
||||
|
||||
interface ChatParams {
|
||||
apiKey: string
|
||||
systemPrompt: string
|
||||
context?: string
|
||||
model?: string
|
||||
temperature?: number
|
||||
maxTokens?: number
|
||||
maxCompletionTokens?: number
|
||||
topP?: number
|
||||
frequencyPenalty?: number
|
||||
presencePenalty?: number
|
||||
stream?: boolean
|
||||
}
|
||||
|
||||
export interface ChatResponse extends ToolResponse {
|
||||
output: {
|
||||
content: string
|
||||
model: string
|
||||
tokens?: number
|
||||
reasoning_tokens?: number
|
||||
}
|
||||
}
|
||||
|
||||
export const chatTool: ToolConfig<ChatParams, ChatResponse> = {
|
||||
id: 'openai_chat',
|
||||
name: 'OpenAI Chat',
|
||||
description:
|
||||
"Interact with OpenAI's GPT models for natural language processing and generation. Supports system prompts, context management, and fine-tuned response parameters including temperature and token control.",
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'OpenAI API key',
|
||||
},
|
||||
systemPrompt: {
|
||||
type: 'string',
|
||||
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',
|
||||
description: 'Model to use (gpt-4o, o1, o1-mini)',
|
||||
},
|
||||
temperature: {
|
||||
type: 'number',
|
||||
default: 0.7,
|
||||
description: 'Controls randomness in the response (not supported by o1 models)',
|
||||
},
|
||||
maxCompletionTokens: {
|
||||
type: 'number',
|
||||
description:
|
||||
'Maximum number of tokens to generate (including reasoning tokens) for o1 models',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: 'https://api.openai.com/v1/chat/completions',
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
}),
|
||||
body: (params) => {
|
||||
const isO1Model = params.model?.startsWith('o1')
|
||||
const messages = []
|
||||
|
||||
// For o1-mini, we need to use 'user' role instead of 'system'
|
||||
if (params.model === 'o1-mini') {
|
||||
messages.push({ role: 'user', content: params.systemPrompt })
|
||||
} else {
|
||||
messages.push({ role: 'system', content: params.systemPrompt })
|
||||
}
|
||||
|
||||
if (params.context) {
|
||||
messages.push({ role: 'user', content: params.context })
|
||||
}
|
||||
|
||||
const body: any = {
|
||||
model: params.model || 'gpt-4o',
|
||||
messages,
|
||||
}
|
||||
|
||||
// Only add parameters supported by the model type
|
||||
if (!isO1Model) {
|
||||
body.temperature = params.temperature
|
||||
body.max_tokens = params.maxTokens
|
||||
body.top_p = params.topP
|
||||
body.frequency_penalty = params.frequencyPenalty
|
||||
body.presence_penalty = params.presencePenalty
|
||||
} else if (params.maxCompletionTokens) {
|
||||
body.max_completion_tokens = params.maxCompletionTokens
|
||||
}
|
||||
|
||||
body.stream = params.stream
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
if (data.choices?.[0]?.delta?.content) {
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content: data.choices[0].delta.content,
|
||||
model: data.model,
|
||||
},
|
||||
}
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content: data.choices[0].message.content,
|
||||
model: data.model,
|
||||
tokens: data.usage?.total_tokens,
|
||||
reasoning_tokens: data.usage?.completion_tokens_details?.reasoning_tokens,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
transformError: (error) => {
|
||||
const message = error.error?.message || error.message
|
||||
const code = error.error?.type || error.code
|
||||
return `${message} (${code})`
|
||||
},
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
import { ToolConfig, ToolResponse } from '../types'
|
||||
|
||||
export interface ChatParams {
|
||||
apiKey: string
|
||||
systemPrompt: string
|
||||
context?: string
|
||||
model?: string
|
||||
temperature?: number
|
||||
maxTokens?: number
|
||||
topP?: number
|
||||
frequencyPenalty?: number
|
||||
presencePenalty?: number
|
||||
}
|
||||
|
||||
export interface ChatResponse extends ToolResponse {
|
||||
output: {
|
||||
content: string
|
||||
model: string
|
||||
tokens?: number
|
||||
reasoning?: string
|
||||
}
|
||||
}
|
||||
|
||||
export const chatTool: ToolConfig<ChatParams, ChatResponse> = {
|
||||
id: 'xai_chat',
|
||||
name: 'xAI Chat',
|
||||
description:
|
||||
"Interact with xAI's Grok models featuring advanced reasoning capabilities. Supports system prompts, context management, and provides detailed reasoning paths alongside responses.",
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'xAI API key',
|
||||
},
|
||||
systemPrompt: {
|
||||
type: 'string',
|
||||
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',
|
||||
description: 'Model to use',
|
||||
},
|
||||
temperature: {
|
||||
type: 'number',
|
||||
default: 0.7,
|
||||
description: 'Controls randomness in the response',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: 'https://api.x.ai/v1/chat/completions',
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
'Content-Type': 'application/json',
|
||||
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,
|
||||
temperature: params.temperature,
|
||||
max_tokens: params.maxTokens,
|
||||
top_p: params.topP,
|
||||
frequency_penalty: params.frequencyPenalty,
|
||||
presence_penalty: params.presencePenalty,
|
||||
}
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content: data.choices[0].message.content,
|
||||
model: data.model,
|
||||
tokens: data.usage?.total_tokens,
|
||||
reasoning: data.choices[0]?.reasoning,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
transformError: (error) => {
|
||||
const message = error.error?.message || error.message
|
||||
const code = error.error?.type || error.code
|
||||
return `${message} (${code})`
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user