Documentation ¶
Index ¶
- func ValidateRequestsQuotaUsage(ctx context.Context, clientRepository RepositoryPrediction, user *User) (throttling bool, quotaExceeded bool, err error)
- type HTTPClient
- type HTTPHandler
- type Input
- type MockHTTPClient
- type MockInput
- type MockModelInference
- type MockOutput
- type MockRepositoryPrediction
- func (m MockRepositoryPrediction) Close(_ context.Context) error
- func (m MockRepositoryPrediction) GetDailySuccessfulResultsTimestampsByUserID(_ context.Context, _ string) ([]time.Time, error)
- func (m MockRepositoryPrediction) WriteInputPrompt(_ context.Context, _, _, _ string) error
- func (m MockRepositoryPrediction) WriteModelResult(_ context.Context, _, _, _, _, _ string, _, _ uint16) error
- func (m MockRepositoryPrediction) WriteSuccessFlag(_ context.Context, _, _, _ string) error
- type MockRepositorySecretsVault
- type MockRepositoryToken
- type ModelInference
- type Output
- type QuotaRequestsConsumption
- type QuotasUsage
- type RepositoryPrediction
- type RepositorySecretsVault
- type RepositoryToken
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateRequestsQuotaUsage ¶ added in v0.0.5
func ValidateRequestsQuotaUsage(ctx context.Context, clientRepository RepositoryPrediction, user *User) ( throttling bool, quotaExceeded bool, err error, )
ValidateRequestsQuotaUsage checks if the requests' quota was exceeded.
Types ¶
type HTTPClient ¶
HTTPClient client to communicate over http.
type HTTPHandler ¶ added in v0.0.5
HTTPHandler handler to generate a diagram given the input.
type MockHTTPClient ¶
type MockInput ¶
func (MockInput) GetRequestID ¶
type MockModelInference ¶
type MockOutput ¶
func (MockOutput) Serialize ¶
func (m MockOutput) Serialize() ([]byte, error)
type MockRepositoryPrediction ¶
func (MockRepositoryPrediction) Close ¶
func (m MockRepositoryPrediction) Close(_ context.Context) error
func (MockRepositoryPrediction) GetDailySuccessfulResultsTimestampsByUserID ¶ added in v0.0.5
func (MockRepositoryPrediction) WriteInputPrompt ¶
func (m MockRepositoryPrediction) WriteInputPrompt(_ context.Context, _, _, _ string) error
func (MockRepositoryPrediction) WriteModelResult ¶
func (MockRepositoryPrediction) WriteSuccessFlag ¶ added in v0.0.5
func (m MockRepositoryPrediction) WriteSuccessFlag(_ context.Context, _, _, _ string) error
type MockRepositorySecretsVault ¶
func (MockRepositorySecretsVault) ReadLastVersion ¶
func (m MockRepositorySecretsVault) ReadLastVersion(_ context.Context, _ string, o interface{}) error
type MockRepositoryToken ¶ added in v0.0.5
func (MockRepositoryToken) GetActiveUserIDByActiveTokenID ¶ added in v0.0.5
type ModelInference ¶
type ModelInference interface { Do(ctx context.Context, userPrompt string, systemContent string, model string) ( predictionRaw string, prediction []byte, usageTokensPrompt uint16, usageTokensCompletions uint16, err error, ) }
ModelInference interface to communicate with the model.
type Output ¶
Output defines the exit point's interface.
func NewResultSVG ¶
NewResultSVG create a response object with the SVG diagram.
type QuotaRequestsConsumption ¶ added in v0.0.5
type QuotasUsage ¶ added in v0.0.5
type QuotasUsage struct { PromptLengthMax int `json:"prompt_length_max"` RateMinute QuotaRequestsConsumption `json:"rate_minute"` RateDay QuotaRequestsConsumption `json:"rate_day"` }
func GetQuotaUsage ¶ added in v0.0.5
func GetQuotaUsage(ctx context.Context, clientRepository RepositoryPrediction, user *User) (QuotasUsage, error)
GetQuotaUsage read current usage of the quota.
type RepositoryPrediction ¶
type RepositoryPrediction interface { // WriteInputPrompt records user's input prompt. WriteInputPrompt(ctx context.Context, requestID, userID, prompt string) error // WriteModelResult records the model's prediction result and the associated costs in tokens. WriteModelResult( ctx context.Context, requestID, userID, predictionRaw, prediction, model string, usageTokensPrompt, usageTokensCompletions uint16, ) error // WriteSuccessFlag records the instance of a successful diagram generation // based on the model's prediction result. WriteSuccessFlag(ctx context.Context, requestID, userID, token string) error // GetDailySuccessfulResultsTimestampsByUserID reads the timestamps of all user's successful requests // which led to successful diagrams generation over the last 24 hours / day. GetDailySuccessfulResultsTimestampsByUserID(ctx context.Context, userID string) ([]time.Time, error) // Close closes connection to persistence service. Close(ctx context.Context) error }
RepositoryPrediction defines the interface to store prediction input (prompt) and model result.
type RepositorySecretsVault ¶
type RepositorySecretsVault interface {
ReadLastVersion(ctx context.Context, uri string, output interface{}) error
}
RepositorySecretsVault defines the interface to read secrets from the vault.
type RepositoryToken ¶ added in v0.0.5
type RepositoryToken interface { // GetActiveUserIDByActiveTokenID reads userID from the repository given the tokenID. // It returns a non-empty value if and only if the token and user are active. GetActiveUserIDByActiveTokenID(ctx context.Context, id string) (string, error) }
RepositoryToken defines the communication port to persistence layer hosting API access tokens.
Click to show internal directories.
Click to hide internal directories.