MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / callTogether

Function callTogether

packages/baseai/src/dev/llms/call-together.ts:10–42  ·  view source on GitHub ↗
({
	pipe,
	messages,
	llmApiKey,
	stream,
	paramsTools
}: {
	pipe: Pipe;
	llmApiKey: string;
	stream: boolean;
	messages: Message[];
	paramsTools: PipeTool[] | undefined;
})

Source from the content-addressed store, hash-verified

8import type { PipeTool } from 'types/tools';
9
10export 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
44function buildModelParams(
45 pipe: Pipe,

Callers 1

callLLMFunction · 0.90

Calls 5

applyJsonModeIfEnabledFunction · 0.90
addToolsToParamsFunction · 0.90
dlogFunction · 0.90
handleLlmErrorFunction · 0.90
buildModelParamsFunction · 0.70

Tested by

no test coverage detected