(
model: Model<any>,
systemPrompt: string,
conversation: Array<{ role: 'user' | 'assistant'; content: string }>,
options?: SimpleStreamOptions
)
| 260 | } |
| 261 | |
| 262 | export function callLLMSimple( |
| 263 | model: Model<any>, |
| 264 | systemPrompt: string, |
| 265 | conversation: Array<{ role: 'user' | 'assistant'; content: string }>, |
| 266 | options?: SimpleStreamOptions |
| 267 | ): string | null { |
| 268 | const context: Context = { |
| 269 | systemPrompt, |
| 270 | messages: conversation.map(msg => { |
| 271 | const contentBlock = { type: 'text' as const, text: msg.content }; |
| 272 | |
| 273 | if (msg.role === 'user') { |
| 274 | return { |
| 275 | role: 'user' as const, |
| 276 | content: [contentBlock], |
| 277 | } as UserMessage; |
| 278 | } else { |
| 279 | return { |
| 280 | role: 'assistant' as const, |
| 281 | content: [contentBlock], |
| 282 | } as AssistantMessage; |
| 283 | } |
| 284 | }), |
| 285 | }; |
| 286 | const response = callLLMSync({ |
| 287 | model, |
| 288 | context, |
| 289 | options |
| 290 | }); |
| 291 | |
| 292 | if (!response || !response.content) { |
| 293 | getLogger().error('[WorkerManager] LLM call response is empty'); |
| 294 | return null; |
| 295 | } |
| 296 | |
| 297 | if (typeof response.content === 'string') { |
| 298 | return response.content; |
| 299 | } |
| 300 | |
| 301 | if (Array.isArray(response.content)) { |
| 302 | const textContent = response.content.find((c) => c.type === 'text'); |
| 303 | return textContent && 'text' in textContent ? (textContent as { text: string }).text : null; |
| 304 | } |
| 305 | |
| 306 | return null; |
| 307 | } |
no test coverage detected