Documentation
¶
Index ¶
- func GenerateRandomSchema(schema map[string]interface{}) interface{}
- func InterfaceToString(i interface{}) (string, error)
- func ListMcpTools(mcpserver *mcpserversse.McpServerSse) (res *mcp.ListToolsResult, err error)
- func NewMcpClientCache(mcpServerSse *mcpserversse.McpServerSse) (*mcpClientCache, error)
- func ToOpenAITool(tool Tool) map[string]interface{}
- func ToOpenAIToolPB(tool Tool) *openai.FunctionToolParam
- func ToOpenAITools(tools []Tool) []map[string]interface{}
- type FunctionTool
- func (t *FunctionTool) Execute(ctx context.Context, params map[string]interface{}) (interface{}, error)
- func (t *FunctionTool) GetDescription() string
- func (t *FunctionTool) GetName() string
- func (t *FunctionTool) GetParametersSchema() map[string]interface{}
- func (m *FunctionTool) GetTimeout() time.Duration
- func (t *FunctionTool) ResultToString(output interface{}) string
- func (m *FunctionTool) SetTimeout(t time.Duration)
- func (t *FunctionTool) WithDescription(description string) *FunctionTool
- func (t *FunctionTool) WithName(name string) *FunctionTool
- func (t *FunctionTool) WithSchema(schema map[string]interface{}) *FunctionTool
- type McpTool
- func (m *McpTool) Execute(ctx context.Context, params map[string]interface{}) (interface{}, error)
- func (m *McpTool) GetDescription() string
- func (m *McpTool) GetName() string
- func (m *McpTool) GetParametersSchema() map[string]interface{}
- func (m *McpTool) GetTimeout() time.Duration
- func (m *McpTool) ResultToString(output interface{}) string
- func (m *McpTool) SetTimeout(t time.Duration)
- type Tool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomSchema ¶
func GenerateRandomSchema(schema map[string]interface{}) interface{}
GenerateRandomData 根据 map 结构的 Schema 生成随机数据
func InterfaceToString ¶
InterfaceToString 转换成 string
func ListMcpTools ¶
func ListMcpTools(mcpserver *mcpserversse.McpServerSse) (res *mcp.ListToolsResult, err error)
ListMcpTools 获取 mcp 工具列表
func NewMcpClientCache ¶ added in v1.0.2
func NewMcpClientCache(mcpServerSse *mcpserversse.McpServerSse) (*mcpClientCache, error)
构建一个新的 mcp client cache
func ToOpenAITool ¶
ToOpenAITool converts a Tool to the OpenAI tool format
func ToOpenAIToolPB ¶
func ToOpenAIToolPB(tool Tool) *openai.FunctionToolParam
ToOpenAITool converts a Tool to the OpenAI tool format
func ToOpenAITools ¶
ToOpenAITools converts a slice of Tools to the OpenAI tool format
Types ¶
type FunctionTool ¶
type FunctionTool struct {
// contains filtered or unexported fields
}
FunctionTool is a tool implemented as a Go function
func NewFunctionTool ¶
func NewFunctionTool(name, description string, fn interface{}, schema map[string]interface{}) ( *FunctionTool, error)
NewFunctionTool creates a new function tool
func (*FunctionTool) Execute ¶
func (t *FunctionTool) Execute(ctx context.Context, params map[string]interface{}) (interface{}, error)
Execute executes the tool with the given parameters
func (*FunctionTool) GetDescription ¶
func (t *FunctionTool) GetDescription() string
GetDescription returns the description of the tool
func (*FunctionTool) GetName ¶
func (t *FunctionTool) GetName() string
GetName returns the name of the tool
func (*FunctionTool) GetParametersSchema ¶
func (t *FunctionTool) GetParametersSchema() map[string]interface{}
GetParametersSchema returns the JSON schema for the tool parameters
func (*FunctionTool) GetTimeout ¶
func (m *FunctionTool) GetTimeout() time.Duration
GetTimeout 获取超时时间
func (*FunctionTool) ResultToString ¶
func (t *FunctionTool) ResultToString(output interface{}) string
ResultToString ...
func (*FunctionTool) SetTimeout ¶
func (m *FunctionTool) SetTimeout(t time.Duration)
SetTimeout 工具输出结果转换成 string
func (*FunctionTool) WithDescription ¶
func (t *FunctionTool) WithDescription(description string) *FunctionTool
WithDescription updates the description of the tool
func (*FunctionTool) WithName ¶
func (t *FunctionTool) WithName(name string) *FunctionTool
WithName updates the name of the tool
func (*FunctionTool) WithSchema ¶
func (t *FunctionTool) WithSchema(schema map[string]interface{}) *FunctionTool
WithSchema sets a custom schema for the tool parameters
type McpTool ¶
McpTool ...
func (*McpTool) GetDescription ¶
GetDescription returns the description of the tool
func (*McpTool) GetParametersSchema ¶
GetParametersSchema returns the JSON schema for the tool parameters
func (*McpTool) ResultToString ¶
ResultToString ...
func (*McpTool) SetTimeout ¶
SetTimeout 工具输出结果转换成 string
type Tool ¶
type Tool interface { // GetName returns the name of the tool GetName() string // GetDescription returns the description of the tool GetDescription() string // GetParametersSchema returns the JSON schema for the tool parameters GetParametersSchema() map[string]interface{} // Execute executes the tool with the given parameters Execute(ctx context.Context, params map[string]interface{}) (interface{}, error) // ResultToString 工具输出结果转换成 string ResultToString(result interface{}) string // GetTimeout 获取超时时间 GetTimeout() time.Duration // SetTimeout 配置工具超时时间 SetTimeout(t time.Duration) }
Tool represents a capability that can be used by an agent