Documentation
¶
Overview ¶
Package ai provides an interface for interacting with AI providers.
Index ¶
Constants ¶
View Source
const ( ProviderOpenAI string = "openai" ProviderAnthropic string = "anthropic" ProviderDatadog string = "datadog" )
List of supported AI providers.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider interface {
// Name returns the name of the provider.
Name() string
// Do performs a single API request to the provider's API, returning a
// response for the provided Request.
//
// Do should attempt to interpret the response from the provider and return
// it as streaming strings to ctx.App.Writer if successful.
Do(ctx *cli.Context, req *Request) error
}
Provider represents an LLM provider such as OpenAI, Anthropic, Mistral, etc.
type Request ¶
type Request struct {
// Context is a string that provides additional context for the request. It
// is only used if Content is a base64-encoded image.
Context string
// Model is the full name of the LLM model to use for the request, e.g.
// "gpt-4o-mini" or "claude-3-5-sonnet-20240620".
Model string
// SystemPrompt is a set of instructions for the AI model to follow when
// generating a response.
SystemPrompt string
// UserPrompt is a second set of instructions for the AI model to follow
// when generating a response.
//
// This prompt is sent to the AI provider after the system prompt and can be
// used to provide additional context or constraints for the response.
UserPrompt string
// Text represents content that is sent to the AI provider together with the
// user prompt for generating a response.
Text []byte
// Image represents an image attachment that is sent to the AI provider
// together with the user prompt for generating a response.
Image []byte
// Temperature is a float between 0 and 1 that controls the randomness of
// the response. A value of 0 will always return the most likely token,
// while a value of 1 will sample from the distribution of tokens.
Temperature float32
}
Request represents an HTTP request to an AI provider's API.
func NewRequest ¶
NewRequest returns a new Request instance for a text-based user prompt.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package anthropic provides a client wrapper for the Anthropic API that complies with the ai.Provider interface.
|
Package anthropic provides a client wrapper for the Anthropic API that complies with the ai.Provider interface. |
|
Package datadog provides a client wrapper for the Datadog AI proxy API that complies with the ai.Provider interface.
|
Package datadog provides a client wrapper for the Datadog AI proxy API that complies with the ai.Provider interface. |
|
Package openai provides a client wrapper for the OpenAI API that complies with the ai.Provider interface.
|
Package openai provides a client wrapper for the OpenAI API that complies with the ai.Provider interface. |
Click to show internal directories.
Click to hide internal directories.