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

Function generateWithAI

src/renderer/src/services/titleService.ts:146–171  ·  view source on GitHub ↗

* 使用 AI 生成文本(简化的非流式调用)

(
  prompt: string,
  llmConfig: LLMConfig,
  modelConfig: ModelConfig | undefined
)

Source from the content-addressed store, hash-verified

144 * 使用 AI 生成文本(简化的非流式调用)
145 */
146async function generateWithAI(
147 prompt: string,
148 llmConfig: LLMConfig,
149 modelConfig: ModelConfig | undefined
150): Promise<string> {
151 return new Promise((resolve, reject) => {
152 const aiService = createAIService(llmConfig, modelConfig)
153
154 let fullResponse = ''
155
156 aiService.sendMessage(
157 [{ id: 'system', role: 'user', content: prompt, createdAt: Date.now() }],
158 {
159 onChunk: (chunk) => {
160 fullResponse += chunk
161 },
162 onComplete: () => {
163 resolve(fullResponse.trim())
164 },
165 onError: (error) => {
166 reject(error)
167 }
168 }
169 )
170 })
171}
172
173// ==================== 导出函数 ====================
174

Callers 9

generateMessageTitleFunction · 0.85
generateTopicTitleFunction · 0.85
suggestNewTopicFunction · 0.85
analyzeTopicSegmentsFunction · 0.85
generateSessionTitleFunction · 0.85

Calls 2

createAIServiceFunction · 0.90
sendMessageMethod · 0.80

Tested by

no test coverage detected