Documentation
¶
Overview ¶
httpclient implements an API client for Ollama's web search and web fetch https://docs.ollama.com/capabilities/web-search
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func New ¶
New returns a client for Ollama's web search and web fetch with the API key. The endpoint can be replaced with client.OptEndpoint, for example for testing.
func (*Client) Fetch ¶
func (c *Client) Fetch(ctx context.Context, req *FetchRequest) (FetchResponse, error)
Fetch returns the title, main content and links of the web page with the URL in the request
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, req *SearchRequest) (SearchResponse, error)
Search returns the results of searching the web for the query in the request
type FetchRequest ¶
type FetchRequest struct {
URL string `json:"url" help:"URL of the web page to fetch"`
}
FetchRequest is a request to fetch a web page
type FetchResponse ¶
type FetchResponse struct {
Title string `json:"title"`
Content string `json:"content"` // The page's main content
Links []string `json:"links,omitempty"`
}
FetchResponse is a fetched web page
func (FetchResponse) String ¶
func (r FetchResponse) String() string
type SearchRequest ¶
type SearchRequest struct {
Query string `json:"query" help:"Search query"`
MaxResults int `json:"max_results,omitempty" help:"Maximum number of results to return (1-10)" min:"1" max:"10" default:"5"`
}
SearchRequest is a request to search the web
type SearchResponse ¶
type SearchResponse struct {
Results []SearchResult `json:"results"`
}
SearchResponse is the results of searching the web
func (SearchResponse) String ¶
func (r SearchResponse) String() string
type SearchResult ¶
type SearchResult struct {
Title string `json:"title"`
URL string `json:"url"`
Content string `json:"content"` // A snippet of the page's content
}
SearchResult is a web page which matched the search query