MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / llmComplete

Function llmComplete

apps/desktop/main/ai/summary/index.ts:56–75  ·  view source on GitHub ↗
(systemPrompt, userPrompt, options)

Source from the content-addressed store, hash-verified

54 },
55
56 async llmComplete(systemPrompt, userPrompt, options) {
57 const fastConfig = getFastModelConfig()
58 if (!fastConfig) throw new Error(t('llm.notConfigured'))
59
60 const piModel = buildPiModel(fastConfig)
61 const result = await completeSimple(
62 piModel,
63 { systemPrompt, messages: [{ role: 'user', content: userPrompt, timestamp: Date.now() }] },
64 { apiKey: fastConfig.apiKey, temperature: options?.temperature, maxTokens: options?.maxTokens }
65 )
66
67 if (result.stopReason === 'error' || result.stopReason === 'aborted') {
68 throw new Error(result.errorMessage || t('llm.callFailed'))
69 }
70
71 return result.content
72 .filter((item): item is PiTextContent => item.type === 'text')
73 .map((item) => item.text)
74 .join('')
75 },
76
77 t,
78 logger: aiLogger,

Callers

nothing calls this directly

Calls 4

getFastModelConfigFunction · 0.90
tFunction · 0.90
buildPiModelFunction · 0.90
nowMethod · 0.45

Tested by

no test coverage detected