Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKey ¶
type APIKey struct {
gorm.Model `json:"-"`
ID uuid.UUID `gorm:"primaryKey;not null;type:uuid;default:gen_random_uuid();" json:"id,omitempty"`
// Digest is the hashed API key
Digest string `gorm:"uniqueIndex;not null;" json:"digest,omitempty"`
// APIKey is the masked API key
APIKey string `gorm:"not null;" json:"api_key"`
// Name is the name of the API key
Name *string `json:"name,omitempty"`
// Foreign Keys
UserID uuid.UUID `gorm:"not null;type:uuid;" json:"user_id"`
// CreatedAt
CreatedAt time.Time `json:"created_at"`
}
APIKey struct
type ChatInput ¶
type ChatInput struct {
// Model is the model name
Model string `json:"model,required"`
// Messages is the list of messages
Messages []Message `json:"messages,required"`
// Temperature is the temperature of the model
Temperature *float64 `json:"temperature,omitempty"`
// TopP is the top-p of the model
TopP *float64 `json:"top_p,omitempty"`
// N is the number of responses
N *int `json:"n,omitempty"`
// Stream is whether to stream the response
Stream *bool `json:"stream,omitempty"`
// Logprobs is whether to return log probabilities of the output tokens or not
Logprobs *bool `json:"logprobs,omitempty"`
// TopLogprobs is the number of top log probabilities to return
TopLogprobs *int `json:"top_logprobs,omitempty"`
}
type EvaluationResult ¶
type EvaluationScore ¶
type EvaluationScore struct {
Name string `json:"name"`
Score float32 `json:"score"`
RepresentativeReasoning string `json:"representative_reasoning"`
AllEvaluations []EvaluationResult `json:"all_evaluations"`
SpanID string `json:"span_id"`
}
type GroupingKey ¶
type GroupingKey string
const ( // GroupByDate groups by date, default GroupByDate GroupingKey = "date" // GroupByModel groups by model GroupByModel GroupingKey = "model" )
type Session ¶
type Session struct {
gorm.Model `json:"-"`
ID uuid.UUID `gorm:"primaryKey;not null;type:uuid;" json:"id,omitempty"`
Name *string `json:"name,omitempty"`
UserID uuid.UUID `gorm:"not null;type:uuid;" json:"user_id"`
Traces []Trace `gorm:"foreignKey:SessionID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"traces,omitempty"`
// CreatedAt
CreatedAt time.Time `json:"created_at"`
}
Session struct
type Span ¶
type Span struct {
// SpanID is a fixed-length string of 8 bytes
ID string `json:"id"`
// TraceID is a UUID4 string
TraceID uuid.UUID `json:"trace_id"`
// ParentID is a fixed-length string of 8 bytes
ParentID string `json:"parent_id"`
// Name is the name of the span
Name string `json:"name"`
// StartTime is the start time of the span in Unix Nano
StartTime time.Time `json:"start_time"`
// EndTime is the end time of the span in Unix Nano
EndTime sql.NullTime `json:"end_time"`
// Duration is the duration of the span in milliseconds
Duration *float64 `json:"duration,omitempty"`
// Kind is the kind of the span
Kind string `json:"kind"`
// Metadata is a map of key-value pairs
Metadata map[string]string `json:"metadata,omitempty"`
}
Span struct
type Trace ¶
type Trace struct {
gorm.Model `json:"-"`
// ID is a UUID4 string
ID uuid.UUID `gorm:"primaryKey;not null;type:uuid;default:gen_random_uuid()" json:"id,omitempty"`
// Name is the name of the trace
Name *string `json:"name,omitempty"`
// StartTime is the start time of the trace in Unix Nano
StartTime time.Time `json:"start_time"`
// EndTime is the end time of the trace in Unix Nano
EndTime sql.NullTime `json:"end_time,omitempty"`
// Session ID
SessionID uuid.UUID `gorm:"not null;type:uuid;" json:"session_id,omitempty"`
}
Trace struct
type Usage ¶
type Usage struct {
Model string `json:"model"`
InputTokens uint64 `json:"input_tokens"`
OutputTokens uint64 `json:"output_tokens"`
TotalTokens uint64 `json:"total_tokens"`
SpanID string `json:"span_id"`
UserID uuid.UUID `json:"user_id"`
TraceID uuid.UUID `json:"trace_id"`
Created time.Time `json:"created"`
}
type UsageQuery ¶
type UsageQuery struct {
StartTime int64 `query:"start_time"`
EndTime *int64 `query:"end_time"`
GroupBy *GroupingKey `query:"group_by"`
}
type UsageResult ¶
type UsageResult struct {
InputTokens uint64 `json:"input_tokens"`
OutputTokens uint64 `json:"output_tokens"`
TotalTokens uint64 `json:"total_tokens"`
// Model exists only if GroupBy is set to model
Model *string `json:"model"`
// Date exists only if GroupBy is empty or set to date
Date *int64 `json:"date"`
}
type User ¶
type User struct {
gorm.Model `json:"-"`
ID uuid.UUID `gorm:"primaryKey;not null;type:uuid;default:gen_random_uuid()" json:"id,omitempty"`
Username string `gorm:"uniqueIndex:idx_username_active;not null;size:50;" validate:"required,min=3,max=50" json:"username"`
Email string `gorm:"uniqueIndex:idx_email_active;not null;size:255;" validate:"required,email" json:"email"`
Password string `gorm:"not null;" validate:"required,min=6,max=50" json:"password,omitempty"`
Name *string `json:"name,omitempty"`
APIKeys []APIKey `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"api_keys,omitempty"`
Sessions []Session `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"sessions,omitempty"`
// Allow to create a new user with the same username or email after the user is deleted
DeletedAt sql.NullTime `gorm:"uniqueIndex:idx_username_active;uniqueIndex:idx_email_active;" json:"deleted_at,omitempty"`
}
User struct
Click to show internal directories.
Click to hide internal directories.