MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / buildMoonshotRequestBody

Function buildMoonshotRequestBody

web/src/llm-api/moonshot.ts:112–138  ·  view source on GitHub ↗
(
  body: ChatCompletionRequestBody,
  originalModel: string,
)

Source from the content-addressed store, hash-verified

110}
111
112export function buildMoonshotRequestBody(
113 body: ChatCompletionRequestBody,
114 originalModel: string,
115): Record<string, unknown> {
116 const moonshotCompatibleBody = addKimiToolCompatibilityFields(body)
117 const moonshotBody: Record<string, unknown> = {
118 ...moonshotCompatibleBody,
119 messages: normalizeMoonshotMessages(moonshotCompatibleBody.messages ?? []),
120 tools: moonshotCompatibleBody.tools?.map(normalizeMoonshotTool),
121 model: getMoonshotModelId(originalModel),
122 }
123
124 moonshotBody.thinking = createMoonshotThinking(moonshotBody)
125
126 delete moonshotBody.reasoning
127 delete moonshotBody.reasoning_effort
128 delete moonshotBody.provider
129 delete moonshotBody.transforms
130 delete moonshotBody.codebuff_metadata
131 delete moonshotBody.usage
132
133 if (moonshotBody.stream) {
134 moonshotBody.stream_options = { include_usage: true }
135 }
136
137 return moonshotBody
138}
139
140function createMoonshotThinking(
141 moonshotBody: Record<string, unknown>,

Callers 2

buildBodyFunction · 0.90
createMoonshotRequestFunction · 0.85

Calls 4

getMoonshotModelIdFunction · 0.85
createMoonshotThinkingFunction · 0.85

Tested by 1

buildBodyFunction · 0.72