MCPcopy Create free account
hub / github.com/experdot/pointer / fetchStreamingResponse

Method fetchStreamingResponse

src/main/aiHandler.ts:172–193  ·  view source on GitHub ↗

* 创建并发送 API 请求

(
    request: AIRequest,
    apiMessages: ChatMessage[],
    modelConfig: ModelConfig,
    abortController: AbortController
  )

Source from the content-addressed store, hash-verified

170 * 创建并发送 API 请求
171 */
172 private async fetchStreamingResponse(
173 request: AIRequest,
174 apiMessages: ChatMessage[],
175 modelConfig: ModelConfig,
176 abortController: AbortController
177 ): Promise<Response> {
178 return await fetch(`${request.llmConfig.apiHost.replace(/\/$/, '')}/chat/completions`, {
179 method: 'POST',
180 headers: {
181 'Content-Type': 'application/json',
182 Authorization: `Bearer ${request.llmConfig.apiKey}`
183 },
184 body: JSON.stringify({
185 model: request.llmConfig.modelName,
186 messages: apiMessages,
187 temperature: modelConfig.temperature,
188 top_p: modelConfig.topP,
189 stream: true
190 }),
191 signal: abortController.signal
192 })
193 }
194
195 /**
196 * 创建 SSE 事件解析器

Callers 1

sendMessageStreamingMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected