You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(gemini): Improve tool call processing and error handling
- Enhance the tool call processing in GeminiLLM to better handle function results and planning.
- Update the prompt construction to include plan information when available.
- Implement retry mechanism with user prompt for failed function calls with fallback to Groq.
- Add timeout mechanism for generateContentWithTools and fallback to Groq on timeout.
- Change the default CodeBuddy mode to Ask.
userQuery=`Tool result: ${JSON.stringify(functionResult)} \n. Based on these plans, Plans: ${this.planSteps} from the tool result \n What is your next step?`;
207
+
}else{
208
+
userQuery=`Tool result: ${JSON.stringify(functionResult)}. What is your next step?`;
209
+
this.planSteps=[];
210
+
}
219
211
}
220
212
}else{
221
213
userQuery=`Tool result: ${JSON.stringify(functionResult)}. What is your next step?`;
222
214
}
223
-
}
224
-
225
-
awaitthis.buildChatHistory(
226
-
userQuery,
227
-
functionCall.name,
228
-
functionResult,
229
-
undefined,
230
-
false,
231
-
);
232
215
233
-
constsnapShot=this.createSnapShot({
234
-
lastQuery: userQuery,
235
-
lastCall: functionCall.name,
236
-
lastResult: functionResult,
237
-
currentStepIndex: this.currentStepIndex,
238
-
planSteps: this.planSteps,
239
-
});
240
-
Memory.set(COMMON.GEMINI_SNAPSHOT,snapShot);
241
-
callCount++;
242
-
}catch(error: any){
243
-
console.error("Error processing function call",error);
244
-
245
-
constretry=awaitvscode.window.showErrorMessage(
246
-
`Function call failed: ${error.message}. Retry or abort?`,
247
-
"Retry",
248
-
"Abort",
249
-
);
250
-
251
-
if(retry==="Retry"){
252
-
continue;// Retry the current function call
253
-
}else{
254
-
finalResult=`Function call error: ${error.message}. Falling back to last response.`;
255
-
break;// Exit the loop and return the error result
216
+
awaitthis.buildChatHistory(
217
+
userQuery,
218
+
functionCall.name,
219
+
functionResult,
220
+
undefined,
221
+
false
222
+
);
223
+
224
+
constsnapShot=this.createSnapShot({
225
+
lastQuery: userQuery,
226
+
lastCall: functionCall.name,
227
+
lastResult: functionResult,
228
+
currentStepIndex: this.currentStepIndex,
229
+
planSteps: this.planSteps,
230
+
});
231
+
Memory.set(COMMON.GEMINI_SNAPSHOT,snapShot);
232
+
callCount++;
233
+
}catch(error: any){
234
+
console.error("Error processing function call",error);
235
+
// Send this to the webview instead and let the user decide
236
+
constretry=awaitvscode.window.showErrorMessage(
237
+
`Function call failed: ${error.message}. Retry or abort?`,
238
+
"Retry",
239
+
"Abort"
240
+
);
241
+
242
+
if(retry==="Retry"){
243
+
continue;// Retry the current function call
244
+
}else{
245
+
finalResult=`Function call error: ${error.message}. Falling back to last response.`;
246
+
break;// Exit the loop and return the error result
0 commit comments