types

package
v0.0.0-...-ab17b8d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APiAccessOpsDatasourceAdd        = "datasource:add"
	APiAccessOpsDatasourceGet        = "datasource:get"
	APiAccessOpsDatasourceUpdate     = "datasource:update"
	APiAccessOpsDatasourceActivate   = "datasource:activate"
	APiAccessOpsDatasourceDeactivate = "datasource:deactivate"
	APiAccessOpsDatasourceDelete     = "datasource:delete"

	APiAccessOpsDocumentsGet = "documents:get"
	APiAccessOpsDocumentGet  = "document:get"

	APIAccessOpsEmbeddingProvidersGet       = "embedding_providers:get"
	APIAccessOpsEmbeddingProviderGet        = "embedding_provider:get"
	APIAccessOpsEmbeddingProviderDelete     = "embedding_provider:delete"
	APIAccessOpsEmbeddingProviderUpdate     = "embedding_provider:update"
	APIAccessOpsEmbeddingProviderActivate   = "embedding_provider:activate"
	APIAccessOpsEmbeddingProviderDeactivate = "embedding_provider:deactivate"

	APIAccessOpsLLMProvidersGet       = "llm_providers:get"
	APIAccessOpsLLMProviderGet        = "llm_provider:get"
	APIAccessOpsLLMProviderDelete     = "llm_provider:delete"
	APIAccessOpsLLMProviderUpdate     = "llm_provider:update"
	APIAccessOpsLLMProviderActivate   = "llm_provider:activate"
	APIAccessOpsLLMProviderDeactivate = "llm_provider:deactivate"

	APIAccessOpsInteractionCreate = "interaction:create"
	APIAccessOpsInteractionsGet   = "interactions:get"
	APIAccessOpsInteractionGet    = "interaction:get"
	APIAccessOpsMessageSend       = "message:send"

	APiAccessOpsSearchSearch = "search:search"

	APiAccessOpsSettingsGet    = "settings:get"
	APiAccessOpsSettingsUpdate = "settings:update"
)
View Source
const (
	DatasourceTypeSlack DatasourceType = "slack"

	DatasourceValidationMsgNameIsRequired       = "name is required"
	DatasourceValidationMsgSourceTypeIsRequired = "source_type is required"
)
View Source
const (
	LLMProviderTypeOpenAI LLMProviderType = "openai"
	LLMProviderTypeNoOps  LLMProviderType = "noop"

	InteractionRoleUser InteractionRole = "user"

	LLMProviderStatusActive   LLMProviderStatus = "active"
	LLMProviderStatusInactive LLMProviderStatus = "inactive"
)
View Source
const (
	UserStatusActive   UserStatus = "active"
	UserStatusInactive UserStatus = "inactive"

	UserRoleAdmin     UserRole = "admin"
	UserRoleUser      UserRole = "user"
	UserRoleDeveloper UserRole = "developer"

	AuthenticatedUserCtxKey            = "authenticated_user"
	UserDetailsCtxKey       ContextKey = "user_details"

	AnonymousUserUUID = "00000000-0000-0000-0000-000000000000"
)
View Source
const (
	DatasourceDeletedSuccessfullyMsg = "Datasource has been deleted successfully"
)
View Source
const DatasourceNotFoundMsg = "Datasource not found"
View Source
const FailedToSetDatasourceActiveMsg = "Failed to set datasource active"
View Source
const InvalidUUIDMessage = "Invalid UUID"

Variables

View Source
var ErrEmbeddingProviderNotFound = errors.New("embedding provider not found")
View Source
var ErrLLMProviderNotFound = errors.New("LLM provider not found")
View Source
var UserNotFoundError = errors.New("user not found")

Functions

This section is empty.

Types

type AIOperationType

type AIOperationType string

type AIUsage

type AIUsage struct {
	OpsProviderID         uuid.UUID `db:"ops_provider_id"`
	DocumentID            uuid.UUID `db:"document_id"`
	InputTokens           int32     `db:"input_tokens"`
	OutputTokens          int32     `db:"output_tokens"`
	Dimensions            int32     `db:"dimensions"`
	OperationType         string    `db:"operation_type"`
	CostPerThousandsToken float64   `db:"cost_per_thousands_token"`
	CreatedAt             time.Time `db:"created_at"`
	TotalLatency          float64   `db:"total_latency"`
}

type AnalyticsOverview

type AnalyticsOverview struct {
	EmbeddingProviders EmbeddingProvidersOverview `json:"embedding_providers"`
	LLMProviders       LLMProvidersOverview       `json:"llm_providers"`
	Datasources        DatasourcesOverview        `json:"datasources"`
}

type AppSettings

type AppSettings struct {
	ID            int       `db:"id"`
	Settings      Settings  `db:"settings"`
	LastUpdatedAt time.Time `db:"last_updated_at"`
}

type ContentPart

type ContentPart struct {
	Content                   string    `json:"content"`
	Embedding                 []float32 `json:"embedding"`
	EmbeddingProviderUUID     uuid.UUID `json:"embedding_provider_uuid"`
	EmbeddingPromptTotalToken int32     `json:"embedding_prompt_token"`
	GeneratedAt               time.Time `json:"generated_at"`
}

func NewContentPart

func NewContentPart(content string, embedding []float32, embeddingProviderUUID uuid.UUID, embeddingPromptToken int32) ContentPart

type ContextKey

type ContextKey string

type Conversation

type Conversation struct {
	UUID      uuid.UUID       `json:"uuid"`
	Role      InteractionRole `json:"role"`
	Text      string          `json:"text"`
	CreatedAt time.Time       `json:"created_at"`
}

type DataSource

type DataSource interface {
	GetID() uuid.UUID
	GetData(ctx context.Context, currentState DatasourceState) ([]Document, DatasourceState, error)
	Validate() error
}

type DatasourceConfig

type DatasourceConfig struct {
	UUID       uuid.UUID          `json:"uuid"`
	Name       string             `json:"name"`
	Status     DatasourceStatus   `json:"status"`
	SourceType DatasourceType     `json:"source_type"`
	Settings   DatasourceSettings `json:"settings"`
	State      DatasourceState    `json:"state"`
}

func (*DatasourceConfig) MarshalJSON

func (dc *DatasourceConfig) MarshalJSON() ([]byte, error)

func (*DatasourceConfig) UnmarshalJSON

func (dc *DatasourceConfig) UnmarshalJSON(data []byte) error

type DatasourceInfo

type DatasourceInfo struct {
	Name      string    `json:"name"`
	Type      string    `json:"type"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"created_at"`
}

type DatasourcePayload

type DatasourcePayload struct {
	Name       string          `json:"name"`
	SourceType DatasourceType  `json:"source_type"`
	Settings   json.RawMessage `json:"settings"`
}

type DatasourceSettings

type DatasourceSettings interface {
	Validate() error
}

type DatasourceState

type DatasourceState interface {
	Validate() error
}

func ParseDatasourceStateFromRawJSON

func ParseDatasourceStateFromRawJSON(sourceType DatasourceType, data json.RawMessage) (DatasourceState, error)

type DatasourceStatus

type DatasourceStatus string
const (
	DatasourceStatusInactive DatasourceStatus = "inactive"
	DatasourceStatusActive   DatasourceStatus = "active"
)

type DatasourceType

type DatasourceType string

type DatasourcesOverview

type DatasourcesOverview struct {
	ConfiguredDatasources                 []DatasourceInfo `json:"configured_datasources"`
	TotalDatasources                      int              `json:"total_datasources"`
	TotalDatasourcesByType                map[string]int   `json:"total_datasources_by_type"`
	TotalDatasourcesByStatus              map[string]int   `json:"total_datasources_by_status"`
	TotalDocumentsFetchedByDatasourceType map[string]int   `json:"total_documents_fetched_by_datasource_type"`
}

type DebuggingSettings

type DebuggingSettings struct {
	LogLevel  LogLevel  `json:"log_level"`
	LogFormat LogFormat `json:"log_format"`
	LogOutput LogOutput `json:"log_output"`
}

type Document

type Document struct {
	UUID      uuid.UUID      `json:"uuid"`
	URL       *url.URL       `json:"-"`
	Title     string         `json:"title"`
	Body      string         `json:"body"`
	Embedding Embedding      `json:"embedding"`
	Metadata  []Metadata     `json:"metadata"`
	Status    DocumentStatus `json:"status"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	FetchedAt time.Time      `json:"fetched_at"`
	Source    Source         `json:"source"`
}

func (*Document) MarshalJSON

func (d *Document) MarshalJSON() ([]byte, error)

func (*Document) Validate

func (d *Document) Validate() error

type DocumentFilter

type DocumentFilter struct {
	UUID       string
	Status     DocumentStatus
	SourceUUID string
}

type DocumentFilterOption

type DocumentFilterOption struct {
	Limit int
	Page  int
}

type DocumentStatus

type DocumentStatus string
const DocumentStatusErrorProcessing DocumentStatus = "error_processing"
const DocumentStatusPending DocumentStatus = "pending"
const DocumentStatusProcessing DocumentStatus = "processing"
const DocumentStatusReadyToSearch DocumentStatus = "ready_to_search"

type Embedding

type Embedding struct {
	Embedding []ContentPart `json:"embedding"`
}

type EmbeddingProviderConfig

type EmbeddingProviderConfig struct {
	UUID          uuid.UUID                 `json:"uuid"`
	Name          string                    `json:"name"`
	Provider      EmbeddingProviderType     `json:"provider"`
	Configuration EmbeddingProviderSettings `json:"configuration"`
	Status        string                    `json:"status"`
}

func (*EmbeddingProviderConfig) MarshalJSON

func (c *EmbeddingProviderConfig) MarshalJSON() ([]byte, error)

func (*EmbeddingProviderConfig) UnmarshalJSON

func (c *EmbeddingProviderConfig) UnmarshalJSON(data []byte) error

type EmbeddingProviderFilter

type EmbeddingProviderFilter struct {
	Status string `json:"status"`
}

type EmbeddingProviderFilterOption

type EmbeddingProviderFilterOption struct {
	Limit int `json:"limit"`
	Page  int `json:"page"`
}

type EmbeddingProviderSettings

type EmbeddingProviderSettings interface {
	Validate() error
	RawJSON() json.RawMessage
	ToMap() map[string]interface{}
}

func ParseEmbeddingProviderSettings

func ParseEmbeddingProviderSettings(providerType EmbeddingProviderType, settingsJSON json.RawMessage) (EmbeddingProviderSettings, error)

type EmbeddingProviderType

type EmbeddingProviderType string
const (
	EmbeddingProviderTypeOpenAI EmbeddingProviderType = "openai"
	EmbeddingProviderTypeNoOp   EmbeddingProviderType = "noop"
)

type EmbeddingProvidersOverview

type EmbeddingProvidersOverview struct {
	TotalProviders       int          `json:"total_providers"`
	TotalActiveProviders int          `json:"total_active_providers"`
	ActiveProvider       ProviderInfo `json:"active_provider"`
}

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

type GeneralSettings

type GeneralSettings struct {
	ApplicationName string `json:"application_name"`
}

type GenerateResponseMsg

type GenerateResponseMsg struct {
	Message string `json:"message"`
}

type GitHubSettings

type GitHubSettings struct {
	Org string `json:"org"`
}

func (GitHubSettings) Validate

func (s GitHubSettings) Validate() error

type Interaction

type Interaction struct {
	UUID          uuid.UUID      `json:"uuid"`
	Query         string         `json:"query"`
	Conversations []Conversation `json:"conversations"`
	CreatedAt     time.Time      `json:"created_at"`
}

type InteractionRole

type InteractionRole string

type LLMProviderConfig

type LLMProviderConfig struct {
	UUID          uuid.UUID           `json:"uuid"`
	Name          string              `json:"name"`
	Provider      LLMProviderType     `json:"provider"`
	Configuration LLMProviderSettings `json:"configuration"`
	Status        string              `json:"status"`
}

func (*LLMProviderConfig) MarshalJSON

func (c *LLMProviderConfig) MarshalJSON() ([]byte, error)

func (*LLMProviderConfig) UnmarshalJSON

func (c *LLMProviderConfig) UnmarshalJSON(data []byte) error

type LLMProviderFilter

type LLMProviderFilter struct {
	Status string `json:"status"`
}

type LLMProviderFilterOption

type LLMProviderFilterOption struct {
	Limit int `json:"limit"`
	Page  int `json:"page"`
}

type LLMProviderSettings

type LLMProviderSettings interface {
	Validate() error
	RawJSON() json.RawMessage
	ToMap() map[string]interface{}
}

func ParseLLMProviderSettings

func ParseLLMProviderSettings(providerType LLMProviderType, settingsJSON json.RawMessage) (LLMProviderSettings, error)

type LLMProviderStatus

type LLMProviderStatus string

type LLMProviderType

type LLMProviderType string

type LLMProvidersOverview

type LLMProvidersOverview struct {
	TotalProviders       int          `json:"total_providers"`
	TotalActiveProviders int          `json:"total_active_providers"`
	ActiveProvider       ProviderInfo `json:"active_provider"`
}

type LogFormat

type LogFormat string

type LogLevel

type LogLevel string

type LogOutput

type LogOutput string

type Metadata

type Metadata struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type NoOpLLMProviderSettings

type NoOpLLMProviderSettings struct {
	ResponseToReturn string `json:"response_to_return"`
	HealthCheckError *error `json:"health_check_error,omitempty"`
}

func (*NoOpLLMProviderSettings) RawJSON

func (*NoOpLLMProviderSettings) ToMap

func (s *NoOpLLMProviderSettings) ToMap() map[string]interface{}

func (*NoOpLLMProviderSettings) Validate

func (s *NoOpLLMProviderSettings) Validate() error

type NoOpSettings

type NoOpSettings struct {
	ContentParts []ContentPart
}

func (*NoOpSettings) RawJSON

func (s *NoOpSettings) RawJSON() json.RawMessage

func (*NoOpSettings) ToMap

func (s *NoOpSettings) ToMap() map[string]interface{}

func (*NoOpSettings) Validate

func (s *NoOpSettings) Validate() error

type OAuthUserInfo

type OAuthUserInfo struct {
	ID    string `json:"id"`
	Email string `json:"email"`
	Name  string `json:"name"`
}

OAuthUserInfo represents the structure of user info from an OAuth provider

type OpenAILLMSettings

type OpenAILLMSettings struct {
	APIKey  string `json:"api_key"`
	ModelID string `json:"model_id"`
}

func (*OpenAILLMSettings) RawJSON

func (s *OpenAILLMSettings) RawJSON() json.RawMessage

func (*OpenAILLMSettings) ToMap

func (s *OpenAILLMSettings) ToMap() map[string]interface{}

func (*OpenAILLMSettings) Validate

func (s *OpenAILLMSettings) Validate() error

type OpenAISettings

type OpenAISettings struct {
	APIKey      string `json:"api_key"`
	ModelID     string `json:"model_id"`
	APIEndpoint string `json:"api_endpoint,omitempty"`
}

func (*OpenAISettings) RawJSON

func (s *OpenAISettings) RawJSON() json.RawMessage

func (*OpenAISettings) ToMap

func (s *OpenAISettings) ToMap() map[string]interface{}

func (*OpenAISettings) Validate

func (s *OpenAISettings) Validate() error

type PaginatedDatasources

type PaginatedDatasources struct {
	Datasources []DatasourceConfig `json:"datasources"`
	Total       int                `json:"total"`
	Page        int                `json:"page"`
	PerPage     int                `json:"per_page"`
	TotalPages  int                `json:"total_pages"`
}

func (*PaginatedDatasources) UnmarshalJSON

func (pd *PaginatedDatasources) UnmarshalJSON(data []byte) error

type PaginatedDocuments

type PaginatedDocuments struct {
	Documents  []Document `json:"documents"`
	Total      int        `json:"total"`
	Page       int        `json:"page"`
	PerPage    int        `json:"per_page"`
	TotalPages int        `json:"total_pages"`
}

type PaginatedEmbeddingProviders

type PaginatedEmbeddingProviders struct {
	EmbeddingProviders []EmbeddingProviderConfig `json:"embedding_providers"`
	Total              int                       `json:"total"`
	Page               int                       `json:"page"`
	PerPage            int                       `json:"per_page"`
	TotalPages         int                       `json:"total_pages"`
}

type PaginatedInteractions

type PaginatedInteractions struct {
	Interactions []Interaction `json:"interactions"`
	Total        int           `json:"total"`
	Page         int           `json:"page"`
	PerPage      int           `json:"per_page"`
	TotalPages   int           `json:"total_pages"`
}

type PaginatedLLMProviders

type PaginatedLLMProviders struct {
	LLMProviders []LLMProviderConfig `json:"llm_providers"`
	Total        int                 `json:"total"`
	Page         int                 `json:"page"`
	PerPage      int                 `json:"per_page"`
	TotalPages   int                 `json:"total_pages"`
}

type PaginatedUsers

type PaginatedUsers struct {
	Users      []User `json:"users"`
	Total      int    `json:"total"`
	Page       int    `json:"page"`
	PerPage    int    `json:"per_page"`
	TotalPages int    `json:"total_pages"`
}

type ProviderInfo

type ProviderInfo struct {
	Name  string `json:"name"`
	Type  string `json:"type"`
	Model string `json:"model"`
}

type SearchConfig

type SearchConfig struct {
	QueryText  string
	Embedding  []float32
	Status     string
	SourceType string
	Limit      int
	Page       int
}

type SearchResults

type SearchResults struct {
	Documents    []SearchResultsDocument
	QueryText    string
	Limit        int
	Page         int
	TotalPages   int
	TotalResults int
}

type SearchResultsDocument

type SearchResultsDocument struct {
	ContentPart          string
	ContentPartID        int
	OriginalDocumentUUID uuid.UUID
	RelevantScore        float64
}

type SearchSettings

type SearchSettings struct {
	PerPage int `json:"per_page"`
}

type Settings

type Settings struct {
	General   GeneralSettings   `json:"general"`
	Debugging DebuggingSettings `json:"debugging"`
	Search    SearchSettings    `json:"search"`
}

type SlackSettings

type SlackSettings struct {
	Token     string `json:"token"`
	ChannelID string `json:"channel_id"`
	Workspace string `json:"workspace"`
}

func (*SlackSettings) Validate

func (s *SlackSettings) Validate() error

type SlackState

type SlackState struct {
	Type                string `json:"type,omitempty"`
	NextCursor          string `json:"next_cursor,omitempty"`
	LastThreadTimestamp string `json:"last_thread_timestamp,omitempty"`
}

func (*SlackState) MarshalJSON

func (s *SlackState) MarshalJSON() ([]byte, error)

func (*SlackState) UnmarshalJSON

func (s *SlackState) UnmarshalJSON(data []byte) error

func (*SlackState) Validate

func (s *SlackState) Validate() error

type Source

type Source struct {
	UUID       uuid.UUID      `json:"uuid"`
	Name       string         `json:"name"`
	SourceType DatasourceType `json:"type"`
}

type State

type State struct {
	Data DatasourceState
}

func (*State) MarshalJSON

func (s *State) MarshalJSON() ([]byte, error)

func (*State) UnmarshalJSON

func (s *State) UnmarshalJSON(data []byte) error

type User

type User struct {
	UUID      uuid.UUID  `json:"uuid"`
	Name      string     `json:"name"`
	Email     string     `json:"email"`
	Status    UserStatus `json:"status"`
	Roles     []UserRole `json:"roles"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
}

func DefaultAnonymousUser

func DefaultAnonymousUser() *User

DefaultAnonymousUser returns a pointer to a copy of the anonymous User

func GetAuthenticatedUser

func GetAuthenticatedUser(ctx context.Context) *User

GetAuthenticatedUser safely retrieves the authenticated user from the context If the user is not found or is nil, it returns the anonymous user

type UserFilter

type UserFilter struct {
	NameContains  string     `json:"name"`
	EmailContains string     `json:"email"`
	Status        UserStatus `json:"status"`
	Roles         []UserRole `json:"roles"`
}

type UserFilterOption

type UserFilterOption struct {
	Page    int `json:"page"`
	PerPage int `json:"per_page"`
}

type UserRole

type UserRole string

type UserStatus

type UserStatus string

type ValidationError

type ValidationError struct {
	Message string
}

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL