Documentation
¶
Overview ¶
Package chat implements the dedicated conversational DevOps/SRE agent.
Index ¶
- Constants
- Variables
- func LocationFromReportSettings(provider storage.Provider) *time.Location
- func PromptOrder() []string
- func ResolveTimePhrase(phrase string, now time.Time, loc *time.Location) (core.ChatTimeRange, error)
- func SystemPrompt() string
- type Agent
- type Options
- type Service
- func NewService(store *SessionStore, chatRouter TurnRunner, seeder discoverySeeder, ...) *Service
- func NewServiceWithLocation(store *SessionStore, chatRouter TurnRunner, seeder discoverySeeder, ...) *Service
- func NewServiceWithLocationProvider(store *SessionStore, chatRouter TurnRunner, seeder discoverySeeder, ...) *Service
- func NewServiceWithLocationProviderAndContextDecorator(store *SessionStore, chatRouter TurnRunner, seeder discoverySeeder, ...) *Service
- func (service *Service) Available() bool
- func (service *Service) Cancel(id string) error
- func (service *Service) Create() (*Session, error)
- func (service *Service) Delete(id string) error
- func (service *Service) Get(id string) (*Session, error)
- func (service *Service) List() ([]*Session, error)
- func (service *Service) Send(ctx context.Context, id, message string, attachment *core.ChatAttachment) (result *core.ChatTurnResult, err error)
- func (service *Service) Start(ctx context.Context, id, message string, attachment *core.ChatAttachment) (<-chan TurnOutcome, error)
- type Session
- type SessionStatus
- type SessionStore
- func (store *SessionStore) AcquireLease(id, owner string, ttl time.Duration) (uint64, bool, error)
- func (store *SessionStore) Append(id string, turns ...Turn) (*Session, error)
- func (store *SessionStore) Create(id string) (*Session, error)
- func (store *SessionStore) Delete(id string) error
- func (store *SessionStore) Get(id string) (*Session, error)
- func (store *SessionStore) LeaseActive(id string) (bool, error)
- func (store *SessionStore) List() ([]*Session, error)
- func (store *SessionStore) ReleaseLease(id, owner string, epoch uint64) error
- func (store *SessionStore) RenewLease(id, owner string, epoch uint64, ttl time.Duration) (bool, bool, error)
- func (store *SessionStore) RequestCancel(id string) (bool, error)
- func (store *SessionStore) SetStatus(id string, status SessionStatus, seeded bool) error
- type Turn
- type TurnOutcome
- type TurnRole
- type TurnRunner
Constants ¶
const ( MaxToolIterations = 8 DefaultToolTimeout = 20 * time.Second MaxOutputBytes = 8192 MaxModelContextTurns = 20 )
const ( MaxSessions = 100 MaxTurnsPerSession = 100 MaxMessageBytes = 8192 MaxToolPayloadBytes = 8192 MaxEventsPerTurn = 128 MaxCitationsPerTrace = 4 MaxEventBytesPerTurn = 32 * 1024 MaxToolBytesPerTurn = 32 * 1024 MaxSessionBlobBytes = 5 * 1024 * 1024 SessionRetention = 30 * 24 * time.Hour )
const (
DefaultRunTimeout = 10 * time.Minute
)
Variables ¶
Functions ¶
func LocationFromReportSettings ¶
LocationFromReportSettings returns the durable report timezone used when a chat turn resolves time hints. Runtime changes apply to the next turn; unreadable, absent, or invalid settings fall back to UTC.
func PromptOrder ¶
func PromptOrder() []string
PromptOrder returns a defensive copy of the canonical fragment order.
func ResolveTimePhrase ¶
func ResolveTimePhrase(phrase string, now time.Time, loc *time.Location) (core.ChatTimeRange, error)
ResolveTimePhrase converts the deliberately small supported phrase set into absolute bounds in loc. Unsupported or ambiguous phrases return an error.
func SystemPrompt ¶
func SystemPrompt() string
SystemPrompt returns the assembled prompt used for chat runs.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func (*Agent) Kind ¶
func (agent *Agent) Kind() core.AITaskKind
func (*Agent) RunChatTurn ¶
type Options ¶
type Options struct {
HTTPClient *http.Client
BaseURL string
Timeout time.Duration
RuntimeKeyFunc func(context.Context) (string, bool)
Runtime einowrap.RuntimeAI
ChatModel model.ToolCallingChatModel
ToolTimeout time.Duration
ToolProvider func() ([]core.Tool, error)
SeedProvider func() ([]core.Tool, error)
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(store *SessionStore, chatRouter TurnRunner, seeder discoverySeeder, now func() time.Time) *Service
func NewServiceWithLocation ¶
func NewServiceWithLocation(store *SessionStore, chatRouter TurnRunner, seeder discoverySeeder, now func() time.Time, loc *time.Location) *Service
NewServiceWithLocation constructs a service with deterministic date phrase resolution in loc. Nil clocks and locations default to time.Now and UTC.
func NewServiceWithLocationProvider ¶
func NewServiceWithLocationProvider(store *SessionStore, chatRouter TurnRunner, seeder discoverySeeder, now func() time.Time, location func() *time.Location) *Service
NewServiceWithLocationProvider resolves the current report timezone for every turn so runtime settings changes do not require a process restart.
func NewServiceWithLocationProviderAndContextDecorator ¶ added in v1.4.26
func NewServiceWithLocationProviderAndContextDecorator(store *SessionStore, chatRouter TurnRunner, seeder discoverySeeder, now func() time.Time, location func() *time.Location, decorate func(context.Context) context.Context) *Service
NewServiceWithLocationProviderAndContextDecorator constructs a service that decorates every detached turn context before seed, tool, and model execution. A nil decorator preserves the OSS identity behavior.
func (*Service) Send ¶
func (service *Service) Send(ctx context.Context, id, message string, attachment *core.ChatAttachment) (result *core.ChatTurnResult, err error)
func (*Service) Start ¶
func (service *Service) Start(ctx context.Context, id, message string, attachment *core.ChatAttachment) (<-chan TurnOutcome, error)
Start atomically admits and starts a detached turn. Admission errors such as an already-active session are returned before an SSE response is committed.
type SessionStatus ¶
type SessionStatus string
const ( SessionIdle SessionStatus = "idle" SessionRunning SessionStatus = "running" SessionFailed SessionStatus = "failed" )
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
func NewSessionStore ¶
func (*SessionStore) AcquireLease ¶
func (*SessionStore) Append ¶
func (store *SessionStore) Append(id string, turns ...Turn) (*Session, error)
func (*SessionStore) Delete ¶
func (store *SessionStore) Delete(id string) error
func (*SessionStore) LeaseActive ¶
func (store *SessionStore) LeaseActive(id string) (bool, error)
func (*SessionStore) List ¶
func (store *SessionStore) List() ([]*Session, error)
func (*SessionStore) ReleaseLease ¶
func (store *SessionStore) ReleaseLease(id, owner string, epoch uint64) error
func (*SessionStore) RenewLease ¶
func (*SessionStore) RequestCancel ¶
func (store *SessionStore) RequestCancel(id string) (bool, error)
func (*SessionStore) SetStatus ¶
func (store *SessionStore) SetStatus(id string, status SessionStatus, seeded bool) error
type Turn ¶
type Turn struct {
ID string `json:"id"`
Role TurnRole `json:"role"`
Content string `json:"content"`
CreatedAt time.Time `json:"created_at"`
Attachment *core.ChatAttachment `json:"attachment,omitempty"`
ToolCalls []core.ToolCallTrace `json:"tool_calls,omitempty"`
Citations []core.ChatCitation `json:"citations,omitempty"`
Events []core.ChatEvent `json:"events,omitempty"`
}
type TurnOutcome ¶
type TurnOutcome struct {
Result *core.ChatTurnResult
Err error
}