topiccontext

package
v0.3.20 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderItemText

func RenderItemText(item Item) string

func WithScope

func WithScope(ctx context.Context, scope Scope) context.Context

Types

type Item

type Item struct {
	ConversationKey          string  `json:"conversation_key"`
	TopicID                  string  `json:"topic_id,omitempty"`
	Runtime                  string  `json:"runtime,omitempty"`
	Model                    string  `json:"model,omitempty"`
	NormalizedModel          string  `json:"normalized_model,omitempty"`
	ContextWindowTokens      int64   `json:"context_window_tokens,omitempty"`
	ContextWindowSource      string  `json:"context_window_source,omitempty"`
	UsedInputTokens          int64   `json:"used_input_tokens,omitempty"`
	CachedInputTokens        int64   `json:"cached_input_tokens,omitempty"`
	CacheCreationInputTokens int64   `json:"cache_creation_input_tokens,omitempty"`
	UsageRatio               float64 `json:"usage_ratio,omitempty"`
	LastRunID                string  `json:"last_run_id,omitempty"`
	LastOriginEventID        string  `json:"last_origin_event_id,omitempty"`
	UpdatedAt                string  `json:"updated_at,omitempty"`
}

type Scope

type Scope struct {
	Runtime         string
	ConversationKey string
	TopicID         string
}

func ScopeFromContext

func ScopeFromContext(ctx context.Context) (Scope, bool)

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(path string) *Store

func (*Store) CommandFunc added in v0.3.3

func (s *Store) CommandFunc(conversationKey string) func() (string, error)

func (*Store) Get

func (s *Store) Get(conversationKey string) (Item, bool, error)

func (*Store) ObserveUsage added in v0.3.3

func (s *Store) ObserveUsage(ctx context.Context, sample UsageSample)

func (*Store) RenderCommandText added in v0.3.3

func (s *Store) RenderCommandText(conversationKey string) (string, error)

func (*Store) UpdateFromSample

func (s *Store) UpdateFromSample(scope Scope, sample UsageSample) error

type UsageSample

type UsageSample struct {
	RunID                    string
	OriginEventID            string
	Scene                    string
	Provider                 string
	APIBase                  string
	Model                    string
	ContextWindowTokens      int64
	InputTokens              int64
	CachedInputTokens        int64
	CacheCreationInputTokens int64
	UpdatedAt                time.Time
}

Jump to

Keyboard shortcuts

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