MCPcopy Create free account
hub / github.com/echoVic/blade-code / streamChat

Method streamChat

src/agent/LLMManager.ts:161–180  ·  view source on GitHub ↗

* 流式聊天

(
    messages: LLMMessage[],
    onChunk: (chunk: string) => void
  )

Source from the content-addressed store, hash-verified

159 * 流式聊天
160 */
161 public async streamChat(
162 messages: LLMMessage[],
163 onChunk: (chunk: string) => void
164 ): Promise<string> {
165 this.ensureLLMAvailable();
166
167 if (this.llm instanceof QwenLLM && this.llm.streamChat) {
168 this.log('开始流式对话...');
169 const response = await this.llm.streamChat({ messages }, onChunk);
170 this.log('流式对话完成');
171 return response.content;
172 } else {
173 // 降级到普通聊天
174 this.log('流式聊天不支持,降级到普通聊天');
175 const request: LLMRequest = { messages };
176 const response = await this.llm!.chat(request);
177 onChunk(response.content);
178 return response.content;
179 }
180 }
181
182 /**
183 * 系统提示词聊天

Callers

nothing calls this directly

Calls 3

ensureLLMAvailableMethod · 0.95
logMethod · 0.95
chatMethod · 0.45

Tested by

no test coverage detected