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

Function callGoogle

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

Source from the content-addressed store, hash-verified

9import type { PipeTool } from 'types/tools';
10
11export async function callGoogle({
12 pipe,
13 messages,
14 llmApiKey,
15 stream,
16 paramsTools
17}: {
18 pipe: Pipe;
19 stream: boolean;
20 llmApiKey: string;
21 messages: Message[];
22 paramsTools: PipeTool[] | undefined;
23}) {
24 try {
25 const modelParams = buildModelParams(pipe, stream, messages);
26 addToolsToParams(modelParams, pipe, paramsTools);
27
28 // Transform params according to provider's format
29 const transformedRequestParams = transformToProviderRequest({
30 provider: GOOGLE,
31 params: modelParams,
32 fn: 'chatComplete'
33 });
34
35 applyJsonModeIfEnabledForGoogle(transformedRequestParams, pipe);
36
37 dlog('Google request params', transformedRequestParams);
38
39 const providerOptions = { provider: GOOGLE, llmApiKey };
40
41 return await handleProviderRequest({
42 providerOptions,
43 inputParams: modelParams,
44 endpoint: 'chatComplete',
45 transformedRequestParams
46 });
47 } catch (error: any) {
48 improveGoogleErrorMessage(error);
49 handleLlmError({ error, provider: GOOGLE });
50 }
51}
52
53function buildModelParams(
54 pipe: Pipe,

Callers 1

callLLMFunction · 0.90

Calls 8

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

Tested by

no test coverage detected