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

Method sendMessage

src/renderer/src/services/aiService.ts:37–80  ·  view source on GitHub ↗
(messages: ChatMessage[], callbacks: StreamingResponse)

Source from the content-addressed store, hash-verified

35 }
36
37 async sendMessage(messages: ChatMessage[], callbacks: StreamingResponse): Promise<void> {
38 if (this.isAborted) {
39 callbacks.onError(new Error('Request was aborted'))
40 return
41 }
42
43 try {
44 // 直接调用新接口,传递回调函数对象
45 await window.api.ai.sendMessageStreaming(
46 {
47 requestId: this.requestId,
48 llmConfig: this.llmConfig,
49 modelConfig: this.modelConfig,
50 messages: messages
51 },
52 {
53 onChunk: (chunk: string) => {
54 if (!this.isAborted) {
55 callbacks.onChunk(chunk)
56 }
57 },
58 onReasoning: (reasoning: string) => {
59 if (!this.isAborted) {
60 callbacks.onReasoning?.(reasoning)
61 }
62 },
63 onComplete: (fullResponse: string, reasoning?: string) => {
64 if (!this.isAborted) {
65 callbacks.onComplete(fullResponse, reasoning)
66 }
67 },
68 onError: (error: string) => {
69 if (!this.isAborted) {
70 callbacks.onError(new Error(error))
71 }
72 }
73 }
74 )
75 } catch (error) {
76 if (!this.isAborted) {
77 callbacks.onError(error as Error)
78 }
79 }
80 }
81
82 async testConnection(): Promise<boolean> {
83 try {

Callers 3

generateWithAIFunction · 0.80
useChatFunction · 0.80
useChatStreamingFunction · 0.80

Calls 1

sendMessageStreamingMethod · 0.80

Tested by

no test coverage detected