|
| 1 | +import type { LLMConfig, LLMProvider } from '$lib/types'; |
| 2 | +import availableModels from '$lib/config/available-models'; |
| 3 | + |
| 4 | +const llmConfigs: Record<LLMProvider, LLMConfig> = { |
| 5 | + [availableModels['claude-3-5-sonnet']]: { |
| 6 | + endpoint: 'https://api.anthropic.com/v1/messages', |
| 7 | + headers: (apiKey) => ({ |
| 8 | + 'Content-Type': 'application/json', |
| 9 | + 'x-api-key': apiKey, |
| 10 | + 'anthropic-version': '2023-06-01', |
| 11 | + 'anthropic-dangerous-direct-browser-access': 'true' |
| 12 | + }), |
| 13 | + buildBody: (messages) => ({ |
| 14 | + max_tokens: 4096, |
| 15 | + messages, |
| 16 | + model: availableModels['claude-3-5-sonnet'] |
| 17 | + }), |
| 18 | + extractResponse: (data) => { |
| 19 | + return { content: data.content?.[0].text, role: data?.role }; |
| 20 | + } |
| 21 | + }, |
| 22 | + |
| 23 | + [availableModels['gpt-4o']]: { |
| 24 | + endpoint: 'https://api.openai.com/v1/chat/completions', |
| 25 | + headers: (apiKey) => ({ |
| 26 | + 'Content-Type': 'application/json', |
| 27 | + Authorization: `Bearer ${apiKey}` |
| 28 | + }), |
| 29 | + buildBody: (messages) => ({ |
| 30 | + max_tokens: 4000, |
| 31 | + messages, |
| 32 | + model: availableModels['gpt-4o'], |
| 33 | + temperature: 0.7 |
| 34 | + }), |
| 35 | + extractResponse: (data) => { |
| 36 | + return { |
| 37 | + content: data?.choices?.[0]?.message.content ?? '', |
| 38 | + role: data?.choices?.[0]?.message.role |
| 39 | + }; |
| 40 | + } |
| 41 | + }, |
| 42 | + |
| 43 | + [availableModels['gemini-1.5-pro']]: { |
| 44 | + endpoint: `https://generativelanguage.googleapis.com/v1beta/openai/chat/completions`, |
| 45 | + headers: (apiKey) => ({ |
| 46 | + 'Content-Type': 'application/json', |
| 47 | + Authorization: `Bearer ${apiKey}` |
| 48 | + }), |
| 49 | + buildBody: (messages) => ({ |
| 50 | + max_tokens: 4000, |
| 51 | + messages, |
| 52 | + model: availableModels['gemini-1.5-pro'], |
| 53 | + temperature: 0.7 |
| 54 | + }), |
| 55 | + extractResponse: (data) => { |
| 56 | + return { |
| 57 | + content: data?.choices?.[0]?.message.content ?? '', |
| 58 | + role: data?.choices?.[0]?.message.role |
| 59 | + }; |
| 60 | + } |
| 61 | + } |
| 62 | +}; |
| 63 | + |
| 64 | +export default llmConfigs; |
0 commit comments