mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-09 06:49:02 +08:00
fix(mcp-tools): enhance tool lookup logic to support partial matches (#8473)
* fix(mcp-tools): enhance tool lookup logic to support partial matches - Updated the tool lookup logic in `geminiFunctionCallToMcpTool` to include partial matches for both tool IDs and names, improving the flexibility of tool identification. * refactor(mcp-tools): simplify tool lookup logic for improved clarity - Refactored the tool lookup logic in `geminiFunctionCallToMcpTool` to streamline the identification process by consolidating checks for tool IDs and names into a single variable. This enhances readability and maintains functionality for partial matches.
This commit is contained in:
parent
4c0167cc03
commit
d8c5c31e61
@ -417,10 +417,12 @@ export function geminiFunctionCallToMcpTool(
|
|||||||
): MCPTool | undefined {
|
): MCPTool | undefined {
|
||||||
if (!toolCall) return undefined
|
if (!toolCall) return undefined
|
||||||
if (!mcpTools) return undefined
|
if (!mcpTools) return undefined
|
||||||
const tool = mcpTools.find((tool) => tool.id === toolCall.name || tool.name === toolCall.name)
|
|
||||||
if (!tool) {
|
const toolName = toolCall.name || toolCall.id
|
||||||
return undefined
|
if (!toolName) return undefined
|
||||||
}
|
|
||||||
|
const tool = mcpTools.find((tool) => tool.id.includes(toolName) || tool.name.includes(toolName))
|
||||||
|
|
||||||
return tool
|
return tool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user