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

Function callFireworks

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

Source from the content-addressed store, hash-verified

8import type { Message, Pipe } from 'types/pipe';
9
10export async function callFireworks({
11 pipe,
12 messages,
13 llmApiKey,
14 stream
15}: {
16 pipe: Pipe;
17 llmApiKey: string;
18 stream: boolean;
19 messages: Message[];
20}) {
21 try {
22 const modelParams = buildModelParams(pipe, stream, messages);
23
24 // Transform params according to provider's format
25 const transformedRequestParams = transformToProviderRequest({
26 provider: FIREWORKS_AI,
27 params: modelParams,
28 fn: 'chatComplete'
29 });
30 dlog('Fireworks request params', transformedRequestParams);
31
32 // Fireworks llama-3.1 405b behaves weirdly with stop value. Bug on their side. Omitting it.
33 if (modelParams?.model === 'llama-v3p1-405b-instruct')
34 delete transformedRequestParams['stop'];
35
36 const providerOptions = { provider: FIREWORKS_AI, llmApiKey };
37
38 return await handleProviderRequest({
39 providerOptions,
40 inputParams: modelParams,
41 endpoint: 'chatComplete',
42 transformedRequestParams
43 });
44 } catch (error: any) {
45 handleLlmError({ error, provider: FIREWORKS_AI });
46 }
47}
48
49function buildModelParams(
50 pipe: Pipe,

Callers 1

callLLMFunction · 0.90

Calls 5

dlogFunction · 0.90
handleProviderRequestFunction · 0.90
handleLlmErrorFunction · 0.90
buildModelParamsFunction · 0.70

Tested by

no test coverage detected