mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 11:20:07 +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 {
|
||||
if (!toolCall) return undefined
|
||||
if (!mcpTools) return undefined
|
||||
const tool = mcpTools.find((tool) => tool.id === toolCall.name || tool.name === toolCall.name)
|
||||
if (!tool) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const toolName = toolCall.name || toolCall.id
|
||||
if (!toolName) return undefined
|
||||
|
||||
const tool = mcpTools.find((tool) => tool.id.includes(toolName) || tool.name.includes(toolName))
|
||||
|
||||
return tool
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user