* 函数调用(Qwen 支持函数调用)
(
messages: any[],
functions: any[],
options?: Partial<LLMRequest>
)
| 290 | * 函数调用(Qwen 支持函数调用) |
| 291 | */ |
| 292 | public async functionCall( |
| 293 | messages: any[], |
| 294 | functions: any[], |
| 295 | options?: Partial<LLMRequest> |
| 296 | ): Promise<any> { |
| 297 | try { |
| 298 | const completion = await this.client.chat.completions.create({ |
| 299 | model: options?.model || this.defaultModel, |
| 300 | messages: messages, |
| 301 | functions: functions, |
| 302 | function_call: 'auto', |
| 303 | temperature: options?.temperature || 0.7, |
| 304 | max_tokens: options?.maxTokens || 2048, |
| 305 | } as any); |
| 306 | |
| 307 | return completion; |
| 308 | } catch (error) { |
| 309 | if (error instanceof Error) { |
| 310 | throw new Error(`Qwen function call error: ${error.message}`); |
| 311 | } |
| 312 | throw error; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | /** |
| 317 | * 现代 Tools 格式的函数调用(推荐使用) |
no outgoing calls
no test coverage detected