Documentation ¶
Overview ¶
Package ccatapi represents a library used to call the Cheshire Cat AI API.
See the README.md for more details.
You can find more info about the project at https://cheshirecat.ai
Example ¶
package main import ( "fmt" "log" ccatapi "github.com/saniales/ccat-api" ) func main() { // Create a new Cheshire Cat API client. client := ccatapi.NewClient( ccatapi.WithBaseURL("https://examplecat.ai"), ) // Call the Cheshire Cat API err := client.Status() if err != nil { log.Fatal("Cheshire API is not OK") } // Use Settings API getSettingsParams := ccatapi.GetSettingsParams{ Search: "example", } getSettingsResponse, err := client.Settings.GetSettings(getSettingsParams) if err != nil { log.Fatal("Cannot get settings", err) } fmt.Println(getSettingsResponse.Settings) // Use LLMs API getAllLLMsSettingsResponse, err := client.LLMs.GetAllLLMsSettings() if err != nil { log.Fatal("Cannot get LLMs settings", err) } fmt.Println(getAllLLMsSettingsResponse.Settings) // Use Embedders API getAllEmbeddersSettingsResponse, err := client.Embedders.GetAllEmbeddersSettings() if err != nil { log.Fatal("Cannot get Embedders settings", err) } fmt.Println(getAllEmbeddersSettingsResponse.Settings) }
Output:
Index ¶
- func WithAuthKey(authKey string) option
- func WithBaseURL(baseURL string) option
- func WithHTTPClient(httpClient *http.Client) option
- func WithMarshalFunc(marshalFunc func(v any) ([]byte, error)) option
- func WithUnmarshalFunc(unmarshalFunc func(data []byte, v any) error) option
- func WithUserAgent(userAgent string) option
- func WithUserID(userID string) option
- type APIError
- type APIErrorText
- type APIErrorsResponse
- type Client
- type CreateSettingPayload
- type CreateSettingResponse
- type EmbedderSetting
- type EmbedderSettingSchema
- type GetAllEmbeddersSettingsResponse
- type GetAllLLMsSettingsResponse
- type GetSettingsParams
- type LLMSetting
- type LLMSettingSchema
- type Setting
- type SettingsResponse
- type UpdateSettingPayload
- type UpdateSettingResponse
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithAuthKey ¶
func WithAuthKey(authKey string) option
WithAuthKey returns an option function that sets the auth key for the Client.
func WithBaseURL ¶
func WithBaseURL(baseURL string) option
WithBaseURL returns an option function that sets the base URL of a Client.
func WithHTTPClient ¶
WithHTTPClient returns an option function that sets the HTTP client for the Client.
func WithMarshalFunc ¶
WithMarshalFunc returns an option function that sets the marshal function for the Client.
if marshalFunc is nil, its default value is json.Marshal.
func WithUnmarshalFunc ¶
WithUnmarshalFunc returns an option function that sets the unmarshal function for the Client.
if unmarshalFunc is nil, its default value is json.Unmarshal.
func WithUserAgent ¶
func WithUserAgent(userAgent string) option
WithUserAgent returns an option function that sets the user agent for the Client.
func WithUserID ¶
func WithUserID(userID string) option
WithUserID returns an option function that sets the user ID for the Client.
Types ¶
type APIError ¶
type APIErrorText ¶
type APIErrorText struct {
ErrorMessage string `json:"error"`
}
func (APIErrorText) Error ¶
func (err APIErrorText) Error() string
type APIErrorsResponse ¶
type APIErrorsResponse struct {
Errors []APIError `json:"error"`
}
func (APIErrorsResponse) Error ¶
func (err APIErrorsResponse) Error() string
type Client ¶
type Client struct { Settings *settingsClient LLMs *llmsClient Embedders *embeddersClient // contains filtered or unexported fields }
Client is a Cheshire Cat API client.
func NewClient ¶
func NewClient(opts ...option) *Client
NewClient creates a new client with the provided Options.
Example (Defaults) ¶
package main import ( "fmt" ccatapi "github.com/saniales/ccat-api" ) func main() { // Create a new Cheshire Cat API client with only the default values. client := ccatapi.NewClient() // Call the Cheshire Cat API fmt.Println(client.Status()) }
Output:
Example (Options) ¶
package main import ( "fmt" "net/http" ccatapi "github.com/saniales/ccat-api" ) func main() { // Create a new Cheshire Cat API client by changing the defaults using // options. client := ccatapi.NewClient( ccatapi.WithHTTPClient(&http.Client{}), ccatapi.WithBaseURL("https://localhost:1865"), ccatapi.WithUserAgent("cheshire-gopher-api"), ccatapi.WithUserID("my_user"), ) // Call the Cheshire Cat API with new settings fmt.Println(client.Status()) }
Output:
func (*Client) Status ¶
Status returns the status of the Cheshire Cat API.
Example ¶
package main import ( "fmt" ccatapi "github.com/saniales/ccat-api" ) func main() { // Create a new Cheshire Cat API client. client := ccatapi.NewClient() // Call the Cheshire Cat API fmt.Println(client.Status()) }
Output:
type CreateSettingPayload ¶
type CreateSettingPayload struct { Name string `json:"name"` Value map[string]any `json:"value"` Category string `json:"category"` }
CreateSettingPayload contains the payload for the CreateSetting method.
type CreateSettingResponse ¶
type CreateSettingResponse Setting
CreateSettingResponse contains the response of the CreateSetting method.
type EmbedderSetting ¶
type EmbedderSetting struct { Name string `json:"name"` Value map[string]any `json:"value"` Schema EmbedderSettingSchema `json:"schema"` }
EmbedderSetting contains the data about a single embedder setting.
type EmbedderSettingSchema ¶
type EmbedderSettingSchema struct { LanguageEmbedderName string `json:"languageEmbedderName"` // contains filtered or unexported fields }
EmbedderSettingSchema contains the JSON schema about a single embedder setting.
type GetAllEmbeddersSettingsResponse ¶
type GetAllEmbeddersSettingsResponse struct {
Settings []EmbedderSetting `json:"settings"`
}
GetAllEmbeddersSettingsResponse contains the response of the GetAllEmbeddersSettings method.
type GetAllLLMsSettingsResponse ¶
type GetAllLLMsSettingsResponse struct {
Settings []LLMSetting `json:"settings"`
}
type GetSettingsParams ¶
type GetSettingsParams struct {
Search string `url:"search,omitempty"`
}
GetSettingsParams contains the parameters for the GetSettings method.
type LLMSetting ¶
type LLMSetting struct { Name string `json:"name"` Value map[string]any `json:"value"` Schema LLMSettingSchema `json:"schema"` }
LLMSetting contains the data about a single LLM setting.
type LLMSettingSchema ¶
type LLMSettingSchema struct { LanguageModelName string `json:"languageModelName"` // contains filtered or unexported fields }
LLMSettingSchema contains the data about a single LLM setting schema.
type Setting ¶
type Setting struct { Name string `json:"name"` Value map[string]any `json:"value"` Category string `json:"category"` SettingID string `json:"setting_id"` UpdatedAt int64 `json:"updated_at"` }
SettingResponse contains the data about a single setting.
type SettingsResponse ¶
type SettingsResponse struct {
Settings []Setting `json:"settings"`
}
SettingsResponse contains the response of the GetSettings method.
type UpdateSettingPayload ¶
type UpdateSettingPayload struct { Name *string `json:"name,omitempty"` Value any `json:"value,omitempty"` Category *string `json:"category,omitempty"` }
UpdateSettingPayload contains the payload for the UpdateSetting method.
type UpdateSettingResponse ¶
type UpdateSettingResponse Setting
UpdateSettingResponse contains the response of the UpdateSetting method.