MCPcopy Index your code
hub / github.com/simstudioai/sim / createInitialState

Function createInitialState

apps/sim/providers/gemini/core.ts:50–89  ·  view source on GitHub ↗

* Creates initial execution state

(
  contents: Content[],
  initialUsage: GeminiUsage,
  firstResponseTime: number,
  initialCallTime: number,
  model: string,
  toolConfig: ToolConfig | undefined
)

Source from the content-addressed store, hash-verified

48 * Creates initial execution state
49 */
50function createInitialState(
51 contents: Content[],
52 initialUsage: GeminiUsage,
53 firstResponseTime: number,
54 initialCallTime: number,
55 model: string,
56 toolConfig: ToolConfig | undefined
57): ExecutionState {
58 const initialCost = calculateCost(
59 model,
60 initialUsage.promptTokenCount,
61 initialUsage.candidatesTokenCount
62 )
63
64 return {
65 contents,
66 tokens: {
67 input: initialUsage.promptTokenCount,
68 output: initialUsage.candidatesTokenCount,
69 total: initialUsage.totalTokenCount,
70 },
71 cost: initialCost,
72 toolCalls: [],
73 toolResults: [],
74 iterationCount: 0,
75 modelTime: firstResponseTime,
76 toolsTime: 0,
77 timeSegments: [
78 {
79 type: 'model',
80 name: model,
81 startTime: initialCallTime,
82 endTime: initialCallTime + firstResponseTime,
83 duration: firstResponseTime,
84 },
85 ],
86 usedForcedTools: [],
87 currentToolConfig: toolConfig,
88 }
89}
90
91/**
92 * Executes multiple tool calls in parallel and updates state.

Callers 1

executeGeminiRequestFunction · 0.85

Calls 1

calculateCostFunction · 0.90

Tested by

no test coverage detected