feat: implement ResolveToolMetadata function and update tool metadata resolution across the codebase
This commit is contained in:
@@ -16,6 +16,13 @@ type ToolSpec struct {
|
||||
Appendix string
|
||||
}
|
||||
|
||||
type ToolMetadata struct {
|
||||
ToolCode string
|
||||
ServerCode string
|
||||
ToolName string
|
||||
SourceType string
|
||||
}
|
||||
|
||||
var (
|
||||
BuiltinToolSearch = ToolSpec{
|
||||
Code: "builtin/tool_search",
|
||||
@@ -310,6 +317,24 @@ func BuildToolMetadata(toolCode string) (serverCode, toolName, sourceType string
|
||||
return spec.ServerCode, spec.Name, spec.SourceType, true
|
||||
}
|
||||
|
||||
func ResolveToolMetadata(toolCode string, fallbackName string) ToolMetadata {
|
||||
toolCode = NormalizeToolCodeAlias(strings.TrimSpace(toolCode))
|
||||
fallbackName = strings.TrimSpace(fallbackName)
|
||||
serverCode, toolName, sourceType, ok := BuildToolMetadata(toolCode)
|
||||
if !ok && toolName == "" {
|
||||
toolName = fallbackName
|
||||
}
|
||||
if toolName == "" {
|
||||
toolName = fallbackName
|
||||
}
|
||||
return ToolMetadata{
|
||||
ToolCode: toolCode,
|
||||
ServerCode: strings.TrimSpace(serverCode),
|
||||
ToolName: strings.TrimSpace(toolName),
|
||||
SourceType: strings.TrimSpace(sourceType),
|
||||
}
|
||||
}
|
||||
|
||||
func IsAlwaysAllowedToolCode(toolCode string) bool {
|
||||
return NormalizeToolCodeAlias(strings.TrimSpace(toolCode)) == GraphHandoffConversation.Code
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user