repository

package
v1.0.28 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ModelAvailability = map[string][]string{

	"asia-northeast1": {
		"gemini-2.5-flash",
		"gemini-1.5-pro",
		"gemini-1.5-flash",
		"gemini-pro",
	},
	"asia-northeast2": {},
	"asia-northeast3": {
		"gemini-1.5-pro",
		"gemini-1.5-flash",
		"gemini-pro",
	},
	"asia-southeast1": {
		"gemini-2.5-flash",
		"gemini-1.5-pro",
		"gemini-1.5-flash",
		"gemini-pro",
	},

	"us-central1": {
		"gemini-2.5-pro",
		"gemini-2.5-flash",
		"gemini-2.0-flash",
		"gemini-2.0-flash-lite",
		"gemini-1.5-pro",
		"gemini-1.5-flash",
		"gemini-pro",
	},
	"us-east1": {
		"gemini-2.5-flash",
		"gemini-1.5-pro",
		"gemini-1.5-flash",
		"gemini-pro",
	},
	"us-west1": {
		"gemini-2.5-flash",
		"gemini-1.5-pro",
		"gemini-1.5-flash",
		"gemini-pro",
	},

	"europe-west1": {
		"gemini-2.5-flash",
		"gemini-1.5-pro",
		"gemini-1.5-flash",
		"gemini-pro",
	},
	"europe-west4": {
		"gemini-2.5-flash",
		"gemini-1.5-pro",
		"gemini-1.5-flash",
		"gemini-pro",
	},
}

ModelAvailability defines which models are available in which regions Based on actual testing and Google Cloud documentation

Functions

func GetAvailableModelsForLocation added in v1.0.23

func GetAvailableModelsForLocation(location string) []string

GetAvailableModelsForLocation returns models available in a specific location

func NewCSVWriterRepository added in v1.0.12

func NewCSVWriterRepository(logger domain.Logger) repository.CSVWriterRepository

NewCSVWriterRepository creates a new CSV writer repository

func NewCursorAPIRepository

func NewCursorAPIRepository(timeout time.Duration) repository.CursorAPIRepository

NewCursorAPIRepository creates a new CursorAPIRepository instance

func NewCursorDBRepository

func NewCursorDBRepository(customDBPath string) repository.CursorTokenRepository

NewCursorDBRepository creates a new CursorDBRepository instance

func NewJSONConfigRepository

func NewJSONConfigRepository() repository.ConfigRepository

NewJSONConfigRepository は新しい JSONConfigRepository を作成する

func NewNoOpMetricsRepository added in v1.0.19

func NewNoOpMetricsRepository() repository.MetricsRepository

NewNoOpMetricsRepository creates a new no-op metrics repository

func NewPrometheusMetricsRepository

func NewPrometheusMetricsRepository(cfg *config.PrometheusConfig) (repository.MetricsRepository, error)

NewPrometheusMetricsRepository creates a new Prometheus metrics repository

Types

type AuthConfig

type AuthConfig struct {
	Username string
	Password string
}

AuthConfig holds authentication configuration (basic auth only)

type BedrockCloudWatchRepository added in v1.0.10

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

BedrockCloudWatchRepository implements BedrockRepository using AWS CloudWatch

func NewBedrockCloudWatchRepository added in v1.0.10

func NewBedrockCloudWatchRepository(awsProfile string) (*BedrockCloudWatchRepository, error)

NewBedrockCloudWatchRepository creates a new Bedrock CloudWatch repository

func (*BedrockCloudWatchRepository) CheckConnection added in v1.0.10

func (r *BedrockCloudWatchRepository) CheckConnection() error

CheckConnection verifies AWS credentials and CloudWatch access

func (*BedrockCloudWatchRepository) GetCurrentMonthUsage added in v1.0.10

func (r *BedrockCloudWatchRepository) GetCurrentMonthUsage(region string) (*entity.BedrockUsage, error)

GetCurrentMonthUsage retrieves usage for the current month

func (*BedrockCloudWatchRepository) GetDailyUsage added in v1.0.10

func (r *BedrockCloudWatchRepository) GetDailyUsage(region string, date time.Time) (*entity.BedrockUsage, error)

GetDailyUsage retrieves aggregated usage for a specific date

func (*BedrockCloudWatchRepository) GetUsageMetrics added in v1.0.10

func (r *BedrockCloudWatchRepository) GetUsageMetrics(region string, start, end time.Time) (*entity.BedrockUsage, error)

GetUsageMetrics retrieves Bedrock usage metrics from CloudWatch

func (*BedrockCloudWatchRepository) ListAvailableRegions added in v1.0.10

func (r *BedrockCloudWatchRepository) ListAvailableRegions() ([]string, error)

ListAvailableRegions returns regions with Bedrock activity

type CSVWriterRepositoryImpl added in v1.0.12

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

CSVWriterRepositoryImpl implements CSVWriterRepository

func (*CSVWriterRepositoryImpl) Write added in v1.0.12

func (r *CSVWriterRepositoryImpl) Write(records []*entity.MetricRecord, outputPath string) error

Write writes metric records to a CSV file

type Content added in v1.0.10

type Content struct {
	Role  string `json:"role"`
	Parts []Part `json:"parts"`
}

Content represents a content item in the request

type CursorAPIRepository

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

CursorAPIRepository implements the repository.CursorAPIRepository interface

func (*CursorAPIRepository) CheckUsageBasedStatus

func (r *CursorAPIRepository) CheckUsageBasedStatus(token *valueobject.CursorToken, teamID *int) (*repository.UsageBasedStatus, error)

CheckUsageBasedStatus checks if usage-based pricing is enabled

func (*CursorAPIRepository) GetAggregatedTokenUsage

func (r *CursorAPIRepository) GetAggregatedTokenUsage(token *valueobject.CursorToken) (int64, error)

GetAggregatedTokenUsage retrieves aggregated token usage from 00:00 to current time in the machine's timezone

func (*CursorAPIRepository) GetUsageLimit

func (r *CursorAPIRepository) GetUsageLimit(token *valueobject.CursorToken, teamID *int) (*repository.UsageLimitInfo, error)

GetUsageLimit retrieves the current usage limit settings

func (*CursorAPIRepository) GetUsageStats

func (r *CursorAPIRepository) GetUsageStats(token *valueobject.CursorToken) (*entity.CursorUsage, error)

GetUsageStats retrieves current usage statistics from the Cursor API

type CursorDBRepository

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

CursorDBRepository implements the CursorTokenRepository interface

func (*CursorDBRepository) GetToken

func (r *CursorDBRepository) GetToken() (*valueobject.CursorToken, error)

GetToken retrieves the Cursor authentication token from the SQLite database

type ErrorResponse added in v1.0.10

type ErrorResponse struct {
	Error struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
		Status  string `json:"status"`
	} `json:"error"`
}

ErrorResponse represents an error response from the API

type JSONConfigRepository

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

JSONConfigRepository は JSON形式で設定を管理するリポジトリ実装

func (*JSONConfigRepository) EnsureConfigDir

func (r *JSONConfigRepository) EnsureConfigDir() error

EnsureConfigDir は設定ディレクトリが存在することを保証する

func (*JSONConfigRepository) Exists

func (r *JSONConfigRepository) Exists() (bool, error)

Exists は設定ファイルが存在するかどうかを確認する

func (*JSONConfigRepository) GetConfigPath

func (r *JSONConfigRepository) GetConfigPath() string

GetConfigPath は設定ファイルのパスを返す

func (*JSONConfigRepository) Load

Load は設定ファイルから設定を読み込む

func (*JSONConfigRepository) Save

Save は設定をファイルに保存する

func (*JSONConfigRepository) SetConfigDir

func (r *JSONConfigRepository) SetConfigDir(dir string)

SetConfigDir はテスト用に設定ディレクトリを設定する

func (*JSONConfigRepository) SetConfigFile

func (r *JSONConfigRepository) SetConfigFile(file string)

SetConfigFile はテスト用に設定ファイルパスを設定する

func (*JSONConfigRepository) Validate

func (r *JSONConfigRepository) Validate(cfg *config.AppConfig) error

Validate は設定内容の妥当性を検証する

type JSONLCcRepository

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

JSONLCcRepository implements CcRepository using JSONL files

func NewJSONLCcRepository

func NewJSONLCcRepository(customPath string) *JSONLCcRepository

NewJSONLCcRepository creates a new JSONL-based cc repository

func (*JSONLCcRepository) CountAll

func (r *JSONLCcRepository) CountAll() (int, error)

CountAll returns the total number of cc entries

func (*JSONLCcRepository) CountByDateRange

func (r *JSONLCcRepository) CountByDateRange(start, end time.Time) (int, error)

CountByDateRange returns the number of entries within a date range

func (*JSONLCcRepository) DeleteByDateRange

func (r *JSONLCcRepository) DeleteByDateRange(start, end time.Time) error

DeleteByDateRange deletes entries within a date range (not implemented)

func (*JSONLCcRepository) DeleteByID

func (r *JSONLCcRepository) DeleteByID(id string) error

DeleteByID deletes a cc entry by ID (not implemented)

func (*JSONLCcRepository) ExistsByID

func (r *JSONLCcRepository) ExistsByID(id string) (bool, error)

ExistsByID checks if a cc entry exists with the given ID

func (*JSONLCcRepository) ExistsByMessageID

func (r *JSONLCcRepository) ExistsByMessageID(messageID string) (bool, error)

ExistsByMessageID checks if a cc entry exists with the given message ID

func (*JSONLCcRepository) ExistsByRequestID

func (r *JSONLCcRepository) ExistsByRequestID(requestID string) (bool, error)

ExistsByRequestID checks if a cc entry exists with the given request ID

func (*JSONLCcRepository) FindAll

func (r *JSONLCcRepository) FindAll() ([]*entity.CcEntry, error)

FindAll returns all cc entries

func (*JSONLCcRepository) FindByDate

func (r *JSONLCcRepository) FindByDate(date time.Time) ([]*entity.CcEntry, error)

FindByDate returns cc entries for a specific date

func (*JSONLCcRepository) FindByDateRange

func (r *JSONLCcRepository) FindByDateRange(start, end time.Time) ([]*entity.CcEntry, error)

FindByDateRange returns cc entries within a date range

func (*JSONLCcRepository) FindByID

func (r *JSONLCcRepository) FindByID(id string) (*entity.CcEntry, error)

FindByID returns a cc entry by its ID

func (*JSONLCcRepository) FindByModel

func (r *JSONLCcRepository) FindByModel(model string) ([]*entity.CcEntry, error)

FindByModel returns cc entries for a specific model

func (*JSONLCcRepository) FindByProject

func (r *JSONLCcRepository) FindByProject(projectPath string) ([]*entity.CcEntry, error)

FindByProject returns cc entries for a specific project

func (*JSONLCcRepository) FindByProjectAndDateRange

func (r *JSONLCcRepository) FindByProjectAndDateRange(projectPath string, start, end time.Time) ([]*entity.CcEntry, error)

FindByProjectAndDateRange returns cc entries for a project within a date range

func (*JSONLCcRepository) FindBySession

func (r *JSONLCcRepository) FindBySession(sessionID string) ([]*entity.CcEntry, error)

FindBySession returns cc entries for a specific session

func (*JSONLCcRepository) GetDateRange

func (r *JSONLCcRepository) GetDateRange() (start, end time.Time, err error)

GetDateRange returns the earliest and latest dates with cc entries

func (*JSONLCcRepository) GetDistinctModels

func (r *JSONLCcRepository) GetDistinctModels() ([]string, error)

GetDistinctModels returns all unique model names

func (*JSONLCcRepository) GetDistinctProjects

func (r *JSONLCcRepository) GetDistinctProjects() ([]string, error)

GetDistinctProjects returns all unique project paths

func (*JSONLCcRepository) GetDistinctSessions

func (r *JSONLCcRepository) GetDistinctSessions() ([]string, error)

GetDistinctSessions returns all unique session IDs

func (*JSONLCcRepository) Save

func (r *JSONLCcRepository) Save(entry *entity.CcEntry) error

Save persists a cc entry (not implemented)

func (*JSONLCcRepository) SaveAll

func (r *JSONLCcRepository) SaveAll(entries []*entity.CcEntry) error

SaveAll persists multiple cc entries (not implemented)

type NoOpMetricsRepository added in v1.0.19

type NoOpMetricsRepository struct{}

NoOpMetricsRepository is a no-op implementation of MetricsRepository Used when Prometheus is not configured

func (*NoOpMetricsRepository) Close added in v1.0.19

func (r *NoOpMetricsRepository) Close() error

Close does nothing

func (*NoOpMetricsRepository) SendTokenMetric added in v1.0.19

func (r *NoOpMetricsRepository) SendTokenMetric(totalTokens int, hostLabel string, metricName string) error

SendTokenMetric does nothing

func (*NoOpMetricsRepository) SendTokenMetricWithTimezone added in v1.0.19

func (r *NoOpMetricsRepository) SendTokenMetricWithTimezone(totalTokens int, hostLabel string, metricName string, timezoneInfo repository.TimezoneInfo) error

SendTokenMetricWithTimezone does nothing

type Part added in v1.0.10

type Part struct {
	Text string `json:"text"`
}

Part represents a part of the content

type PrometheusMetricsRepository

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

PrometheusMetricsRepository implements MetricsRepository using Prometheus Remote Write

func (*PrometheusMetricsRepository) Close

Close cleans up resources

func (*PrometheusMetricsRepository) SendTokenMetric

func (r *PrometheusMetricsRepository) SendTokenMetric(totalTokens int, hostLabel string, metricName string) error

SendTokenMetric sends the total token count metric to Prometheus

func (*PrometheusMetricsRepository) SendTokenMetricWithTimezone

func (r *PrometheusMetricsRepository) SendTokenMetricWithTimezone(totalTokens int, hostLabel string, metricName string, timezoneInfo repository.TimezoneInfo) error

SendTokenMetricWithTimezone sends the total token count metric with timezone information

type RemoteWriteClient

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

RemoteWriteClient handles sending metrics to Prometheus Remote Write endpoint

func NewRemoteWriteClient

func NewRemoteWriteClient(url string, timeout time.Duration, authConfig *AuthConfig) (*RemoteWriteClient, error)

NewRemoteWriteClient creates a new Remote Write client

func (*RemoteWriteClient) SendGaugeMetric

func (c *RemoteWriteClient) SendGaugeMetric(ctx context.Context, metricName string, value float64, labels map[string]string) error

SendGaugeMetric sends a gauge metric to the Remote Write endpoint with retry logic This implementation uses text format instead of protobuf for simplicity

type RetryConfig

type RetryConfig struct {
	MaxRetries int
	BaseDelay  time.Duration
	MaxDelay   time.Duration
}

RetryConfig holds retry configuration

func DefaultRetryConfig

func DefaultRetryConfig() *RetryConfig

DefaultRetryConfig returns default retry configuration

type TokenCountRequest added in v1.0.10

type TokenCountRequest struct {
	Contents []Content `json:"contents"`
}

TokenCountRequest represents the request structure for token counting

type TokenCountResponse added in v1.0.10

type TokenCountResponse struct {
	TotalTokens             int64 `json:"totalTokens"`
	CachedContentTokenCount int64 `json:"cachedContentTokenCount,omitempty"`
}

TokenCountResponse represents the response from the token count API

type VertexAIMonitoringRepository added in v1.0.10

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

VertexAIMonitoringRepository implements VertexAIRepository using Google Cloud Monitoring

func NewVertexAIMonitoringRepository added in v1.0.10

func NewVertexAIMonitoringRepository(projectID string, authenticator auth.VertexAIAuthenticator) (*VertexAIMonitoringRepository, error)

NewVertexAIMonitoringRepository creates a new Vertex AI Monitoring repository

func (*VertexAIMonitoringRepository) CheckConnection added in v1.0.10

func (r *VertexAIMonitoringRepository) CheckConnection() error

CheckConnection verifies Google Cloud credentials and Cloud Monitoring access

func (*VertexAIMonitoringRepository) Close added in v1.0.10

Close closes the monitoring client

func (*VertexAIMonitoringRepository) GetCurrentMonthUsage added in v1.0.10

func (r *VertexAIMonitoringRepository) GetCurrentMonthUsage(projectID string) (*entity.VertexAIUsage, error)

GetCurrentMonthUsage retrieves usage for the current month

func (*VertexAIMonitoringRepository) GetDailyUsage added in v1.0.10

func (r *VertexAIMonitoringRepository) GetDailyUsage(projectID string, date time.Time) (*entity.VertexAIUsage, error)

GetDailyUsage retrieves aggregated usage for a specific date

func (*VertexAIMonitoringRepository) GetUsageMetrics added in v1.0.10

func (r *VertexAIMonitoringRepository) GetUsageMetrics(projectID string, start, end time.Time) (*entity.VertexAIUsage, error)

GetUsageMetrics retrieves Vertex AI usage metrics from Cloud Monitoring

type VertexAIRESTRepository added in v1.0.10

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

VertexAIRESTRepository implements VertexAIRepository using REST API with retry logic

func NewVertexAIRESTRepository added in v1.0.10

func NewVertexAIRESTRepository(projectID string, authenticator auth.VertexAIAuthenticator) (*VertexAIRESTRepository, error)

NewVertexAIRESTRepository creates a new Vertex AI REST repository

func (*VertexAIRESTRepository) CheckConnection added in v1.0.10

func (r *VertexAIRESTRepository) CheckConnection() error

CheckConnection verifies Vertex AI API connectivity

func (*VertexAIRESTRepository) Close added in v1.0.10

func (r *VertexAIRESTRepository) Close() error

Close closes any resources (no-op for REST client)

func (*VertexAIRESTRepository) GetCurrentMonthUsage added in v1.0.10

func (r *VertexAIRESTRepository) GetCurrentMonthUsage(projectID string) (*entity.VertexAIUsage, error)

GetCurrentMonthUsage retrieves usage for the current month

func (*VertexAIRESTRepository) GetDailyUsage added in v1.0.10

func (r *VertexAIRESTRepository) GetDailyUsage(projectID string, date time.Time) (*entity.VertexAIUsage, error)

GetDailyUsage retrieves aggregated usage for a specific date

func (*VertexAIRESTRepository) GetUsageMetrics added in v1.0.10

func (r *VertexAIRESTRepository) GetUsageMetrics(projectID string, start, end time.Time) (*entity.VertexAIUsage, error)

GetUsageMetrics retrieves Vertex AI usage metrics (placeholder implementation)

func (*VertexAIRESTRepository) ListPublisherModels added in v1.0.23

func (r *VertexAIRESTRepository) ListPublisherModels(ctx context.Context, location string) ([]string, error)

ListPublisherModels returns a hardcoded list of supported Gemini models for the specific location

func (*VertexAIRESTRepository) SetMaxRetries added in v1.0.10

func (r *VertexAIRESTRepository) SetMaxRetries(retries int)

SetMaxRetries sets the maximum number of retries

func (*VertexAIRESTRepository) SetRetryDelay added in v1.0.10

func (r *VertexAIRESTRepository) SetRetryDelay(delay time.Duration)

SetRetryDelay sets the delay between retries

Directories

Path Synopsis
This file is intentionally empty - using types.go instead
This file is intentionally empty - using types.go instead

Jump to

Keyboard shortcuts

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