File tree Expand file tree Collapse file tree 5 files changed +12
-4
lines changed
src/main/presenter/llmProviderPresenter Expand file tree Collapse file tree 5 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ export interface ChatMessage {
1717}
1818
1919export abstract class BaseLLMProvider {
20+ // 最大工具调用次数限制
21+ protected static readonly MAX_TOOL_CALLS = 10
22+
2023 protected provider : LLM_PROVIDER
2124 protected models : MODEL_META [ ] = [ ]
2225 protected customModels : MODEL_META [ ] = [ ]
@@ -28,6 +31,11 @@ export abstract class BaseLLMProvider {
2831 this . configPresenter = configPresenter
2932 }
3033
34+ // 获取最大工具调用次数
35+ public static getMaxToolCalls ( ) : number {
36+ return BaseLLMProvider . MAX_TOOL_CALLS
37+ }
38+
3139 protected async init ( ) {
3240 if ( this . provider . enable ) {
3341 try {
Original file line number Diff line number Diff line change @@ -431,7 +431,7 @@ ${context}
431431
432432 // 添加工具调用计数
433433 let toolCallCount = 0
434- const MAX_TOOL_CALLS = 25 // 最大工具调用次数限制
434+ const MAX_TOOL_CALLS = BaseLLMProvider . MAX_TOOL_CALLS // 最大工具调用次数限制
435435
436436 // 维护消息上下文
437437 const currentMessages = [ ...messages ]
Original file line number Diff line number Diff line change @@ -504,7 +504,7 @@ export class GeminiProvider extends BaseLLMProvider {
504504
505505 // 添加工具调用计数
506506 let toolCallCount = 0
507- const MAX_TOOL_CALLS = 25 // 最大工具调用次数限制
507+ const MAX_TOOL_CALLS = BaseLLMProvider . MAX_TOOL_CALLS // 最大工具调用次数限制
508508
509509 // 维护消息上下文
510510 const conversationMessages : ChatMessage [ ] = [ ...messages ]
Original file line number Diff line number Diff line change @@ -262,7 +262,7 @@ export class OllamaProvider extends BaseLLMProvider {
262262
263263 // 添加工具调用计数
264264 let toolCallCount = 0
265- const MAX_TOOL_CALLS = 25 // 最大工具调用次数限制
265+ const MAX_TOOL_CALLS = BaseLLMProvider . MAX_TOOL_CALLS // 最大工具调用次数限制
266266
267267 // 启动初始流
268268 let stream = await this . ollama . chat ( {
Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ export class OpenAICompatibleProvider extends BaseLLMProvider {
153153
154154 // 添加工具调用计数
155155 let toolCallCount = 0
156- const MAX_TOOL_CALLS = 25 // 最大工具调用次数限制
156+ const MAX_TOOL_CALLS = BaseLLMProvider . MAX_TOOL_CALLS // 最大工具调用次数限制
157157
158158 // 创建基本请求参数
159159 const requestParams : OpenAI . Chat . ChatCompletionCreateParams = {
You can’t perform that action at this time.
0 commit comments