({
pipe,
messages,
llmApiKey,
stream,
paramsTools
}: {
pipe: Pipe;
llmApiKey: string;
stream: boolean;
messages: Message[];
paramsTools: PipeTool[] | undefined;
})
| 8 | import type { PipeTool } from 'types/tools'; |
| 9 | |
| 10 | export async function callTogether({ |
| 11 | pipe, |
| 12 | messages, |
| 13 | llmApiKey, |
| 14 | stream, |
| 15 | paramsTools |
| 16 | }: { |
| 17 | pipe: Pipe; |
| 18 | llmApiKey: string; |
| 19 | stream: boolean; |
| 20 | messages: Message[]; |
| 21 | paramsTools: PipeTool[] | undefined; |
| 22 | }) { |
| 23 | try { |
| 24 | const modelParams = buildModelParams(pipe, stream, messages); |
| 25 | |
| 26 | // LLM. |
| 27 | const together = new OpenAI({ |
| 28 | apiKey: llmApiKey, |
| 29 | baseURL: 'https://api.together.xyz/v1' |
| 30 | }); |
| 31 | |
| 32 | // Together behaves weirdly with stop value. Omitting it. |
| 33 | delete modelParams['stop']; |
| 34 | applyJsonModeIfEnabled(modelParams, pipe); |
| 35 | addToolsToParams(modelParams, pipe, paramsTools); |
| 36 | dlog('modelParams', modelParams); |
| 37 | |
| 38 | return await together.chat.completions.create(modelParams as any); |
| 39 | } catch (error: any) { |
| 40 | handleLlmError({ error, provider: GROQ }); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | function buildModelParams( |
| 45 | pipe: Pipe, |
no test coverage detected