Documentation ¶
Overview ¶
// Package metaphor contains an implementation of the tool interface with the metaphor search api client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API defines a tool implementation for the Metaphor API.
func NewClient ¶
NewClient initializes a new API client.
It retrieves the API key from the environment variable "METAPHOR_API_KEY" and creates a new client using the retrieved API key. If the API key is not set or an error occurs during client creation, an error is returned.
Returns a pointer to the created API client and an error, if any.
func (*API) Call ¶
Call is a function that takes a context and an input string and returns a string and an error.
The function expects a JSON string as input and unmarshals it into a ToolInput struct. It then performs different operations based on the value of the Operation field in the ToolInput struct. The supported operations are "Search", "FindSimilar", and "GetContents".
If the Operation is "Search", the function calls the performSearch method passing the context and the ToolInput struct. If the Operation is "FindSimilar", the function calls the findSimilar method passing the context and the ToolInput struct. If the Operation is "GetContents", the function calls the getContents method passing the context and the ToolInput struct.
The function returns the result of the respective operation or an empty string and nil if the Operation is not supported.
func (*API) Description ¶
Description returns the Description of the tool. Description contains a short instruction how to use the tool with the Metaphor API
No parameters. Returns a string.
type Documents ¶
type Documents struct {
// contains filtered or unexported fields
}
Documents defines a tool implementation for the Metaphor Web scrapper.
func NewDocuments ¶
NewDocuments creates a new instance of the Documents struct.
The function takes in optional metaphorm.ClientOptions as parameters. It returns a pointer to a Documents struct and an error.
func (*Documents) Call ¶
Call calls the Documents API with the given input and returns the formatted contents.
The input is a string that contains a comma-separated list of IDs.
It returns a string which represents the formatted contents and an error if any.
func (*Documents) Description ¶
Description returns the contents of web pages based on a list of ID strings.
It is designed to be used with Metaphor Search and/or Metaphor Links Search Tool. The expected input format is a list of ID strings obtained from either Metaphor Search or Metaphor Search Links tool. The function returns a string.
func (*Documents) Name ¶
Name returns the name of the Documents tool.
It does not take any parameters. It returns a string, which is the name of the tool.
func (*Documents) SetOptions ¶
func (tool *Documents) SetOptions(options ...metaphor.ClientOptions)
SetOptions sets the options for the Documents struct.
It takes in variadic parameter(s) of type `metaphor.ClientOptions`.
type LinksSearch ¶
type LinksSearch struct {
// contains filtered or unexported fields
}
LinksSearch defines a tool implementation for the Metaphor Find Similar Links.
func NewLinksSearch ¶
func NewLinksSearch(options ...metaphor.ClientOptions) (*LinksSearch, error)
NewLinksSearch creates a new metaphor Search instance, that can be used to find similar links.
It accepts an optional list of ClientOptions as parameters. It returns a pointer to a LinksSearch instance and an error.
func (*LinksSearch) Call ¶
Call searches for similar links using the LinksSearch tool.
ctx - the context in which the function is called. input - the string input used to find similar links, i.e. the url. Returns a string containing the formatted links and an error if any occurred.
func (*LinksSearch) Description ¶
func (tool *LinksSearch) Description() string
Description returns the description of the LinksSearch tool.
This function does not take any parameters. It returns a string that describes the purpose of the LinksSearch tool.
func (*LinksSearch) Name ¶
func (tool *LinksSearch) Name() string
Name returns the name of the LinksSearch tool.
No parameters. Returns a string.
func (*LinksSearch) SetOptions ¶
func (tool *LinksSearch) SetOptions(options ...metaphor.ClientOptions)
SetOptions sets the options for the LinksSearch tool.
It takes in one or more ClientOptions parameters and assigns them to the tool's options field.
type Search ¶
type Search struct {
// contains filtered or unexported fields
}
Search defines a tool implementation for the Metaphor Search.
func NewSearch ¶
NewSearch creates a new Metaphot Search instance.
It accepts an optional variadic parameter of type metaphor.ClientOptions. The function returns a pointer to a Search instance and an error.
func (*Search) Call ¶
Call performs a search using the Search client.
It takes a context.Context and a search query as string input as parameters. It returns a string and an error.
func (*Search) Description ¶
Description returns the description of the Search tool.
This function does not take any parameters. It returns a string that contains the description of the Search tool.
func (*Search) Name ¶
Name returns the name of the Search tool.
This function takes no parameters. It returns a string.
func (*Search) SetOptions ¶
func (tool *Search) SetOptions(options ...metaphor.ClientOptions)
SetOptions sets the options for the Search tool.
options is a variadic parameter of type metaphor.ClientOptions.