const DEFAULT_TIMEOUT_NS
pub const DEFAULT_TIMEOUT_NS = 60000000000Purpose
Constant DEFAULT_TIMEOUT_NS, defining protocol or algorithm parameters.
#github.com/xulang-org/packages/cohereExternal package `cohere #github.com/xulang-org/packages/cohere`, provided by github.com/xulang-org/packages.
github.com/xulang-org/packages · 1.17.2 · Install and use
const DEFAULT_TIMEOUT_NSpub const DEFAULT_TIMEOUT_NS = 60000000000Constant DEFAULT_TIMEOUT_NS, defining protocol or algorithm parameters.
const DEFAULT_BASE_URLpub const DEFAULT_BASE_URL = "https:Constant DEFAULT_BASE_URL, defining protocol or algorithm parameters.
struct Clientpub struct Client {
pub base_url string
pub api_key string
pub timeout_ns int
pub max_retries int
pub extra_headers []string
}Cohere Client session maintaining connection and operations.
base_url stringapi_key stringtimeout_ns intmax_retries intextra_headers []stringstruct ChatMessagepub struct ChatMessage {
pub role string
pub content string
}Structure encapsulating role, content.
role stringcontent stringstruct ChatResponsepub struct ChatResponse {
pub id string
pub text string
pub finish_reason string
pub input_tokens int
pub output_tokens int
}Cohere Server response payload containing status, headers, and body.
id stringtext stringfinish_reason stringinput_tokens intoutput_tokens intstruct EmbedResponsepub struct EmbedResponse {
pub id string
pub embeddings [][]f64
}Cohere Server response payload containing status, headers, and body.
id stringembeddings [][]f64struct RerankResultpub struct RerankResult {
pub index int
pub relevance_score f64
pub document string
}Structure encapsulating index, relevance_score, document.
index intrelevance_score f64document stringnew_clientpub fn new_client(api_key string) ClientConstruct client.
api_key stringClient — a value of this type
new_client_with_basepub fn new_client_with_base(base_url string, api_key string) ClientConstruct client with base.
base_url stringapi_key stringClient — a value of this type
($&Client) set_max_retriespub fn (c $&Client) set_max_retries(n int)Operation on $&Client: set max retries.
c $&ClientClient instance used by this call (exclusive borrow).n intThis call does not return a value.
($&Client) add_headerpub fn (c $&Client) add_header(name string, value string)Operation on $&Client: add header.
c $&ClientClient instance used by this call (exclusive borrow).name stringvalue stringThis call does not return a value.
(&Client) clone_clientpub fn (c &Client) clone_client() ClientOperation on &Client: clone client.
c &ClientClient instance used by this call (borrow).Client — a value of this type
messagepub fn message(role string, content string) ChatMessageExecute message.
role stringcontent stringChatMessage — a value of this type
(&Client) chatpub fn (c &Client) chat(model string, messages &[]ChatMessage, max_tokens int, temperature f64) ChatResponseExecute chat on &Client. Throws on failure; handle the error or propagate it to the caller.
c &ClientClient instance used by this call (borrow).model stringmessages &[]ChatMessagemax_tokens inttemperature f64ChatResponse — a value of this type
(&Client) embedpub fn (c &Client) embed(model string, texts &[]string, input_type string) EmbedResponseExecute embed on &Client. Throws on failure; handle the error or propagate it to the caller.
c &ClientClient instance used by this call (borrow).model stringtexts &[]stringinput_type stringEmbedResponse — a value of this type
(&Client) rerankpub fn (c &Client) rerank(model string, query string, documents &[]string, top_n int) []RerankResultExecute rerank on &Client. Throws on failure; handle the error or propagate it to the caller.
c &ClientClient instance used by this call (borrow).model stringquery stringdocuments &[]stringtop_n int[]RerankResult — slice result