agent

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conversation

type Conversation struct {
	bun.BaseModel `bun:"table:conversations"`

	ID                     uuid.UUID              `bun:",pk,type:uuid" json:"id"`
	AgentSpecID            uuid.UUID              `bun:"type:uuid" json:"agent_spec_id"`
	SessionID              string                 `json:"session_id,omitempty"`
	AgentName              string                 `json:"agent_name"`
	Provider               LLMProvider            `json:"provider"`
	Model                  string                 `json:"model"`
	ReasoningEffort        types.ReasoningEffort  `json:"reasoning_effort"`
	Instructions           string                 `json:"instructions"`
	Tools                  []types.ToolDefinition `bun:"type:jsonb,nullzero" json:"-"`
	Messages               []types.Message        `bun:"type:jsonb,nullzero" json:"messages"`
	Metadata               map[string]any         `bun:"type:jsonb,nullzero" json:"metadata"`
	Status                 ConversationStatus     `json:"status"`
	InputTokens            int64                  `json:"input_tokens"`
	OutputTokens           int64                  `json:"output_tokens"`
	CachedTokens           int64                  `json:"cached_tokens"`
	Cost                   int64                  `json:"cost"`
	CreatedAt              time.Time              `json:"created_at"`
	AutoCompact            bool                   `json:"auto_compact"`
	CompactAtPercent       int                    `json:"compact_at_percent"`
	CompactionPrompt       string                 `json:"compaction_prompt"`
	CompactCount           int                    `json:"compact_count"`
	ShellRoot              string                 `json:"shell_root,omitempty"`
	ShellAccess            bool                   `json:"shell_access"`
	WebSearch              bool                   `json:"web_search"`
	StructuredOutput       bool                   `json:"structured_output"`
	StructuredOutputSchema json.RawMessage        `bun:"type:json,nullzero" json:"structured_output_schema"`
}

func GetConversationByID

func GetConversationByID(ctx context.Context, db bun.IDB, id uuid.UUID) (*Conversation, error)

func GetConversationsBySpecID

func GetConversationsBySpecID(ctx context.Context, db bun.IDB, agentSpecID uuid.UUID) ([]*Conversation, error)

func NewConversation

func NewConversation(agentSpec *Spec, messages []types.Message, metadata map[string]any) (*Conversation, error)

func (*Conversation) AfterScanRow added in v0.2.11

func (c *Conversation) AfterScanRow(ctx context.Context) error

func (*Conversation) Clone added in v0.2.4

func (c *Conversation) Clone(ctx context.Context, db bun.IDB, discardMessages bool) (*Conversation, error)

func (*Conversation) Delete

func (c *Conversation) Delete(ctx context.Context, db bun.IDB) error

func (Conversation) GetCursor

func (c Conversation) GetCursor() string

func (Conversation) GetSortField

func (c Conversation) GetSortField() string

func (Conversation) GetSortValue

func (c Conversation) GetSortValue() interface{}

func (Conversation) GetUniqueField

func (c Conversation) GetUniqueField() string

func (Conversation) GetUniqueValue

func (c Conversation) GetUniqueValue() interface{}

func (*Conversation) Insert

func (c *Conversation) Insert(ctx context.Context, db bun.IDB) error

func (*Conversation) Update

func (c *Conversation) Update(ctx context.Context, db bun.IDB) error

func (*Conversation) Validate

func (c *Conversation) Validate() error

type ConversationStatus

type ConversationStatus string
const (
	ConversationStatusQueued    ConversationStatus = "queued"
	ConversationStatusRunning   ConversationStatus = "running"
	ConversationStatusSucceeded ConversationStatus = "succeeded"
	ConversationStatusFailed    ConversationStatus = "failed"
	ConversationStatusCanceled  ConversationStatus = "canceled"
)

func (ConversationStatus) MarshalJSON

func (s ConversationStatus) MarshalJSON() ([]byte, error)

func (*ConversationStatus) UnmarshalJSON

func (s *ConversationStatus) UnmarshalJSON(b []byte) error

func (ConversationStatus) Validate

func (s ConversationStatus) Validate() error

type LLMProvider

type LLMProvider string
const (
	LLMProviderOpenAI LLMProvider = "open_ai"
)

func (LLMProvider) MarshalJSON

func (e LLMProvider) MarshalJSON() ([]byte, error)

func (*LLMProvider) UnmarshalJSON

func (e *LLMProvider) UnmarshalJSON(b []byte) error

func (LLMProvider) Validate

func (e LLMProvider) Validate() error

type Spec

type Spec struct {
	bun.BaseModel `bun:"table:agent_specs"`

	ID                     uuid.UUID                    `bun:",pk,type:uuid" json:"id"`
	Name                   string                       `json:"name"`
	Provider               LLMProvider                  `json:"provider"`
	Model                  string                       `json:"model"`
	ReasoningEffort        runtimetypes.ReasoningEffort `json:"reasoning_effort"`
	Instructions           string                       `json:"instructions"`
	AutoCompact            bool                         `json:"auto_compact"`
	CompactAtPercent       int                          `json:"compact_at_percent"`
	CompactionPrompt       string                       `json:"compaction_prompt"`
	ShellAccess            bool                         `json:"shell_access"`
	WebSearch              bool                         `json:"web_search"`
	StructuredOutput       bool                         `json:"structured_output"`
	StructuredOutputSchema json.RawMessage              `bun:"type:json,nullzero" json:"structured_output_schema"`
	Version                int                          `json:"version"`
}

func GetAgentSpecByID

func GetAgentSpecByID(ctx context.Context, db bun.IDB, id uuid.UUID) (*Spec, error)

func NewAgentSpec

func NewAgentSpec(name string, prov LLMProvider, model, instructions string, reasoningEffort runtimetypes.ReasoningEffort, version int) (*Spec, error)

func (*Spec) AfterScanRow added in v0.2.11

func (pt *Spec) AfterScanRow(ctx context.Context) error

func (*Spec) Delete

func (pt *Spec) Delete(ctx context.Context, db bun.IDB) error

func (Spec) GetCursor

func (pt Spec) GetCursor() string

func (Spec) GetSortField

func (pt Spec) GetSortField() string

func (Spec) GetSortValue

func (pt Spec) GetSortValue() interface{}

func (Spec) GetUniqueField

func (pt Spec) GetUniqueField() string

func (Spec) GetUniqueValue

func (pt Spec) GetUniqueValue() interface{}

func (*Spec) Insert

func (pt *Spec) Insert(ctx context.Context, db bun.IDB) error

func (*Spec) Update

func (pt *Spec) Update(ctx context.Context, db bun.IDB) error

func (*Spec) Validate

func (pt *Spec) Validate() error

Jump to

Keyboard shortcuts

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