httpclient

package
v1.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

type Client struct {
	*client.Client
}

func New

func New(apiKey string, opts ...client.ClientOpt) (*Client, error)

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

func (*FetchResponse) Unmarshal

func (r *FetchResponse) Unmarshal(_ http.Header, body io.Reader) error

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

func (*SearchResponse) Unmarshal

func (r *SearchResponse) Unmarshal(_ http.Header, body io.Reader) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL