fix link + add gemini tool id if empty

This commit is contained in:
Andrew Pareles
2025-05-10 16:28:54 -07:00
parent 991059d3e7
commit 1d3ddeb4c7
2 changed files with 9 additions and 5 deletions
@@ -146,10 +146,12 @@ const CodespanWithLink = ({ text, rawText, chatMessageLocation }: { text: string
}
const onClick = () => {
if (!link || !link.selection) return;
if (!link) return;
// Use the updated voidOpenFileFn to open the file and handle selection
voidOpenFileFn(link.uri, accessor, [link.selection.startLineNumber, link.selection.endLineNumber]);
if (link.selection)
voidOpenFileFn(link.uri, accessor, [link.selection.startLineNumber, link.selection.endLineNumber]);
else
voidOpenFileFn(link.uri, accessor);
}
return <Codespan
@@ -732,6 +732,7 @@ const sendGeminiChat = async ({
let toolName = ''
let toolParamsStr = ''
let toolId = ''
genAI.models.generateContentStream({
@@ -758,6 +759,7 @@ const sendGeminiChat = async ({
const functionCall = functionCalls[0] // Get the first function call
toolName = functionCall.name ?? ''
toolParamsStr = JSON.stringify(functionCall.args ?? {})
toolId += functionCall.id ?? ''
}
// (do not handle reasoning yet)
@@ -766,7 +768,7 @@ const sendGeminiChat = async ({
onText({
fullText: fullTextSoFar,
fullReasoning: fullReasoningSoFar,
toolCall: isAToolName(toolName) ? { name: toolName, rawParams: {}, isDone: false, doneParams: [], id: 'dummy' } : undefined,
toolCall: isAToolName(toolName) ? { name: toolName, rawParams: {}, isDone: false, doneParams: [], id: toolId } : undefined,
})
}
@@ -774,7 +776,7 @@ const sendGeminiChat = async ({
if (!fullTextSoFar && !fullReasoningSoFar && !toolName) {
onError({ message: 'Void: Response from model was empty.', fullError: null })
} else {
const toolId = generateUuid() // gemini does not generate tool IDs. Generate one
if (!toolId) toolId = generateUuid() // ids are empty, but other providers might expect an id
const toolCall = rawToolCallObjOf(toolName, toolParamsStr, toolId)
const toolCallObj = toolCall ? { toolCall } : {}
onFinalMessage({ fullText: fullTextSoFar, fullReasoning: fullReasoningSoFar, anthropicReasoning: null, ...toolCallObj });