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)
}
Index ¶
- Variables
- 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 DeletePluginResponse
- type EmbedderSetting
- type EmbedderSettingSchema
- type GetAllEmbeddersSettingsResponse
- type GetAllLLMsSettingsResponse
- type GetAllowedMIMETypesResponse
- type GetConversationHistoryResponse
- type GetMemoryCollectionsResponse
- type GetPluginsSettingsResponse
- type GetSettingsParams
- type InstalledPlugin
- type InstalledPluginHookData
- type InstalledPluginToolData
- type LLMSetting
- type LLMSettingSchema
- type Memory
- type MemoryCollection
- type Plugin
- type PluginSetting
- type PluginSettingSchema
- type PluginsResponse
- type RecallMemoriesResponse
- type RegistryPlugin
- type Setting
- type SettingsResponse
- type TogglePluginResponse
- type UpdateSettingPayload
- type UpdateSettingResponse
- type UploadFromURLPayload
- type UploadFromURLResponse
- type UploadMemoryResponse
- type UploadPayload
- type UploadPluginFromRegistryPayload
- type UploadPluginResponse
- type UploadResponse
- type WipeConversationHistoryResponse
- type WipeMemoryCollectionPointResponse
- type WipeMemoryCollectionsResponse
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrUploadMissingFile = fmt.Errorf("missing file, cannot upload")
)
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
Plugins *pluginsClient
Memory *memoryClient
RabbitHole *rabbitHoleClient
// 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())
}
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())
}
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 DeletePluginResponse ¶
type DeletePluginResponse struct {
// The name of the deleted plugin.
Deleted string `json:"deleted"`
}
DeletePluginResponse contains the information about the deleted plugin.
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 GetAllowedMIMETypesResponse ¶
type GetAllowedMIMETypesResponse struct {
Allowed []string `json:"allowed"`
}
GetAllowedMIMETypesResponse represents the response from the GetAllowedMIMETypes call.
type GetConversationHistoryResponse ¶
type GetConversationHistoryResponse struct {
History []conversationMessage `json:"history"`
}
type GetMemoryCollectionsResponse ¶
type GetMemoryCollectionsResponse struct {
// The available collections
Collections []MemoryCollection `json:"collections"`
}
GetMemoryCollectionsResponse contains the response of a GetMemoryCollections call.
type GetPluginsSettingsResponse ¶
type GetPluginsSettingsResponse struct {
Settings []PluginSetting `json:"settings"`
}
type GetSettingsParams ¶
type GetSettingsParams struct {
Search string `url:"search,omitempty"`
}
GetSettingsParams contains the parameters for the GetSettings method.
type InstalledPlugin ¶
type InstalledPlugin struct {
ID string `json:"id"`
Active bool `json:"active"`
Upgrade *string `json:"upgrade"`
Hooks []InstalledPluginHookData `json:"hooks"`
Tools []InstalledPluginToolData `json:"tools"`
// contains filtered or unexported fields
}
InstalledPlugin contains the data about an installed plugin.
type InstalledPluginHookData ¶
InstalledPluginHookData contains the data about an installed plugin hook.
type InstalledPluginToolData ¶
type InstalledPluginToolData struct {
Name string `json:"name"`
}
InstalledPluginToolData contains the data about an installed plugin tool.
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 MemoryCollection ¶
type MemoryCollection struct {
// The name of the collection
Name string `json:"name"`
// The number of vectors in the collection
VectorsCount uint `json:"vectors_count"`
}
MemoryCollection contains the data about a single memory collection.
type PluginSetting ¶
type PluginSetting struct {
Name string `json:"name"`
Value map[string]any `json:"value"`
Schema PluginSettingSchema `json:"schema"`
}
PluginSetting contains the data about a single plugin setting.
type PluginSettingSchema ¶
type PluginSettingSchema struct {
// contains filtered or unexported fields
}
PluginSettingSchema contains the JSON schema about a single plugin setting.
type PluginsResponse ¶
type PluginsResponse struct {
Filters pluginResponseFilters `json:"filters"`
Installed []InstalledPlugin `json:"installed"`
Registry []RegistryPlugin `json:"registry"`
}
PluginsResponse contains the response data about a plugin.
type RecallMemoriesResponse ¶
type RecallMemoriesResponse struct {
Query recallMemoriesResponseQuery `json:"query"`
Vectors recallMemoriesResponseVectors `json:"vectors"`
}
type RegistryPlugin ¶
type RegistryPlugin struct {
URL string `json:"url"`
// contains filtered or unexported fields
}
RegistryPlugin contains the data about a registry plugin.
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 TogglePluginResponse ¶
type TogglePluginResponse struct {
Info string `json:"info"`
}
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.
type UploadFromURLPayload ¶
type UploadFromURLPayload struct {
URL string `json:"url"`
ChunkSize int `json:"chunk_size"`
ChunkOverlap int `json:"chunk_overlap"`
}
UploadFromURLPayload is the payload for the UploadFromURL endpoint.
type UploadFromURLResponse ¶
UploadFromURLResponse is the response for the UploadFromURL endpoint.
type UploadMemoryResponse ¶
type UploadMemoryResponse struct {
File string `json:"file"`
}
UploadMemoryResponse represents the response from the UploadMemory call.
type UploadPayload ¶
type UploadPayload struct {
File *os.File `json:"file"`
ChunkSize int `json:"chunk_size"`
ChunkOverlap int `json:"chunk_overlap"`
}
UploadPayload is the payload for the upload endpoint.
type UploadPluginFromRegistryPayload ¶
type UploadPluginFromRegistryPayload struct {
URL string `json:"url"`
}
type UploadPluginResponse ¶
type UploadPluginResponse struct {
FileName string `json:"file_name"`
ContentType string `json:"content_type"`
Info string `json:"info"`
}
UploadPluginResponse contains the information about the uploaded plugin.
type UploadResponse ¶
UploadResponse is the response for the upload endpoint.
type WipeConversationHistoryResponse ¶
type WipeConversationHistoryResponse struct {
Deleted bool `json:"deleted"`
}
WipeConversationHistoryResponse contains the response of a WipeConversationHistory call.
type WipeMemoryCollectionPointResponse ¶
type WipeMemoryCollectionPointResponse struct {
// The ID of the collected point
Deleted string `json:"deleted"`
}
WipeMemoryCollectionPointResponse contains the response of a WipeMemoryCollectionPoint call.
type WipeMemoryCollectionsResponse ¶
type WipeMemoryCollectionsResponse struct {
Episodic bool `json:"episodic,omitempty"`
Declarative bool `json:"declarative,omitempty"`
Procedural bool `json:"procedural,omitempty"`
}
WipeMemoryCollectionsResponse contains the response of a WipeMemoryCollections call.