Documentation
¶
Index ¶
- func ImportOllamaCookiesFromLinuxBrowsers(home, outputPath string) (int, error)
- func WriteOllamaCookieHeader(path, header string) error
- type Budget
- type BudgetAlert
- type CompletionRecord
- type CookieLoader
- type HistoricalUsageSample
- type OllamaMeIdentity
- type OllamaMeSigner
- type OllamaQuotaFetcher
- type ProviderSummary
- type QuotaIdentityState
- type QuotaSource
- type QuotaState
- type QuotaSummary
- type Recorder
- type Store
- func (s *Store) Close() error
- func (s *Store) CurrentProviderSummary(sessionKey, providerID, modelName string, now time.Time) (ProviderSummary, error)
- func (s *Store) DailySummary(providerID string, day time.Time) (Summary, error)
- func (s *Store) DeleteBudget(ctx context.Context, id string) error
- func (s *Store) GetBudget(ctx context.Context, id string) (Budget, error)
- func (s *Store) LatestQuotaSummary(providerID string) (QuotaSummary, error)
- func (s *Store) ListBudgetAlerts(budgetID string) ([]BudgetAlert, error)
- func (s *Store) ListBudgets(ctx context.Context) ([]Budget, error)
- func (s *Store) ListHistoricalSamples(providerID string) ([]HistoricalUsageSample, error)
- func (s *Store) ListUsageRecords(sessionKey string) ([]UsageRecord, error)
- func (s *Store) PruneOlderThan(ctx context.Context, cutoff time.Time) error
- func (s *Store) RecordCompletion(ctx context.Context, record CompletionRecord) error
- func (s *Store) RecordHistoricalSample(ctx context.Context, sample HistoricalUsageSample) error
- func (s *Store) SaveQuotaSummary(ctx context.Context, summary QuotaSummary) error
- func (s *Store) SessionSummary(sessionKey string) (Summary, error)
- func (s *Store) UpsertBudget(ctx context.Context, budget Budget) error
- func (s *Store) WeeklySummary(providerID string, now time.Time) (Summary, error)
- type Summary
- type UsageRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteOllamaCookieHeader ¶
Types ¶
type BudgetAlert ¶
type CompletionRecord ¶
type CookieLoader ¶
func NewCookieJarStore ¶
func NewCookieJarStore(path string) CookieLoader
type HistoricalUsageSample ¶
type OllamaMeIdentity ¶
type OllamaMeIdentity struct {
IdentityState QuotaIdentityState
Source QuotaSource
AccountName string
AccountEmail string
PlanName string
NotifyUsageLimits bool
AccountMetadataPopulated bool
}
func ProbeOllamaMe ¶
func ProbeOllamaMe(ctx context.Context, baseURL string, client *http.Client, signer OllamaMeSigner, now func() time.Time) (OllamaMeIdentity, error)
type OllamaMeSigner ¶
func NewOllamaKeySigner ¶
func NewOllamaKeySigner(keyPath string) OllamaMeSigner
type OllamaQuotaFetcher ¶
type OllamaQuotaFetcher struct {
BaseURL string
Client *http.Client
Clock func() time.Time
Signer OllamaMeSigner
CookieLoader CookieLoader
}
func (*OllamaQuotaFetcher) Fetch ¶
func (f *OllamaQuotaFetcher) Fetch(ctx context.Context) (QuotaSummary, error)
type ProviderSummary ¶
type QuotaIdentityState ¶
type QuotaIdentityState string
const ( QuotaIdentityStateUnknown QuotaIdentityState = "" QuotaIdentityStateAuthenticated QuotaIdentityState = "authenticated" QuotaIdentityStateAuthenticatedEmpty QuotaIdentityState = "authenticated_empty" QuotaIdentityStateUnauthenticated QuotaIdentityState = "unauthenticated" QuotaIdentityStateError QuotaIdentityState = "error" )
type QuotaSource ¶
type QuotaSource string
const ( QuotaSourceUnknown QuotaSource = "" QuotaSourceOllamaAPIMe QuotaSource = "ollama_api_me" QuotaSourceOllamaSettingsHTML QuotaSource = "ollama_settings_html" )
type QuotaState ¶
type QuotaState string
const ( QuotaStateLive QuotaState = "live" QuotaStateStale QuotaState = "stale" QuotaStateExpired QuotaState = "expired" )
type QuotaSummary ¶
type QuotaSummary struct {
ProviderID string
AccountName string
AccountEmail string
PlanName string
SessionUsedPercent float64
SessionResetsAt *time.Time
WeeklyUsedPercent float64
WeeklyResetsAt *time.Time
NotifyUsageLimits bool
State QuotaState
Source QuotaSource
FetchedAt time.Time
ExpiresAt time.Time
IdentityState QuotaIdentityState
IdentitySource QuotaSource
IdentityAccountName string
IdentityAccountEmail string
}
func ParseOllamaSettingsUsageHTML ¶
func ParseOllamaSettingsUsageHTML(data []byte, fetchedAt, expiresAt time.Time) (QuotaSummary, error)
type Recorder ¶
type Recorder interface {
RecordCompletion(ctx context.Context, record CompletionRecord) error
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) CurrentProviderSummary ¶
func (*Store) DailySummary ¶
func (*Store) LatestQuotaSummary ¶
func (s *Store) LatestQuotaSummary(providerID string) (QuotaSummary, error)
func (*Store) ListBudgetAlerts ¶
func (s *Store) ListBudgetAlerts(budgetID string) ([]BudgetAlert, error)
func (*Store) ListHistoricalSamples ¶
func (s *Store) ListHistoricalSamples(providerID string) ([]HistoricalUsageSample, error)
func (*Store) ListUsageRecords ¶
func (s *Store) ListUsageRecords(sessionKey string) ([]UsageRecord, error)
func (*Store) PruneOlderThan ¶
func (*Store) RecordCompletion ¶
func (s *Store) RecordCompletion(ctx context.Context, record CompletionRecord) error
func (*Store) RecordHistoricalSample ¶
func (s *Store) RecordHistoricalSample(ctx context.Context, sample HistoricalUsageSample) error
func (*Store) SaveQuotaSummary ¶
func (s *Store) SaveQuotaSummary(ctx context.Context, summary QuotaSummary) error
Click to show internal directories.
Click to hide internal directories.