Documentation
¶
Overview ¶
Package cohererank implements the rerank shape Cohere defined and almost every other vendor copied: POST {base}/rerank with {model, query, documents} answering {results: [{index, relevance_score, document}]}.
Jina, Zhipu, SiliconFlow, Qianfan, GPUStack, WeKnora Cloud and any OpenAI-compatible gateway that serves rerank all speak it. Their differences — which optional fields are accepted, where the endpoint sits, what the documented ceilings are — arrive as api.RerankSettings; this package contains no vendor names.
Index ¶
- type Client
- func (c *Client) AcceptsImages() bool
- func (c *Client) BuildImageRequestBody(query string, images []api.EmbedImage) (map[string]any, error)
- func (c *Client) BuildRequestBody(query string, documents []string) (map[string]any, error)
- func (c *Client) Rerank(ctx context.Context, query string, documents []string) ([]api.RerankResult, error)
- func (c *Client) RerankImages(ctx context.Context, query string, images []api.EmbedImage) ([]api.RerankResult, error)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks the Cohere rerank shape to one endpoint.
func (*Client) AcceptsImages ¶
AcceptsImages reports whether the vendor names an image field; without one a Cohere-shaped endpoint takes text documents only.
func (*Client) BuildImageRequestBody ¶
func (c *Client) BuildImageRequestBody(query string, images []api.EmbedImage) (map[string]any, error)
BuildImageRequestBody is the golden-test entry point for image documents. The shape has no standard image document; a vendor that extends it names the key of the object that carries one. Jina's reranker reference gives {"image": URL or base64} documents; it shows no base64 example, so the data URI its embeddings reference documents is used (unverified for rerank). The request carries images only, so text documents never change shape.
func (*Client) BuildRequestBody ¶
BuildRequestBody is the golden-test entry point: it returns the exact JSON object that would be sent.
func (*Client) Rerank ¶
func (c *Client) Rerank(ctx context.Context, query string, documents []string) ([]api.RerankResult, error)
Rerank scores documents against the query, in the order they were given.
func (*Client) RerankImages ¶
func (c *Client) RerankImages(ctx context.Context, query string, images []api.EmbedImage) ([]api.RerankResult, error)
RerankImages scores image documents against the query; indices refer to images.