Documentation
¶
Index ¶
- func GetProductIDFromAPIKey(ctx context.Context, apiKeyId uuid.UUID) (uuid.UUID, error)
- func HandleAPICallAndResponse(w http.ResponseWriter, r *http.Request, ctx context.Context, ...)
- func HandleContextCache(ctx context.Context, req ChatCompletionRequest, productID uuid.UUID) (string, bool, error)
- func HandleError(w http.ResponseWriter, err error, statusCode int)
- func LogProviderError(r *http.Request, provider string, err error)
- func LogProviderInput(r *http.Request, provider string, content interface{})
- func LogProviderOutput(r *http.Request, provider string, content interface{})
- func PerformAuditLogging(r *http.Request, logType string, messageType string, body []byte)
- func ProcessInput(w http.ResponseWriter, r *http.Request, req ChatCompletionRequest) (bool, error)
- func SetContextCacheResponse(ctx context.Context, req ChatCompletionRequest, resp *ChatCompletionResponse, ...) error
- type ChatCompletionRequest
- type ChatCompletionResponse
- type Choice
- type InputRequest
- type Provider
- type Stream
- type StreamResponse
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetProductIDFromAPIKey ¶
func HandleAPICallAndResponse ¶
func HandleAPICallAndResponse(w http.ResponseWriter, r *http.Request, ctx context.Context, req ChatCompletionRequest, productID uuid.UUID, provider Provider)
func HandleContextCache ¶
func HandleError ¶
func HandleError(w http.ResponseWriter, err error, statusCode int)
func LogProviderError ¶ added in v0.4.0
func LogProviderInput ¶ added in v0.4.0
func LogProviderOutput ¶ added in v0.4.0
func PerformAuditLogging ¶
func ProcessInput ¶
func ProcessInput(w http.ResponseWriter, r *http.Request, req ChatCompletionRequest) (bool, error)
func SetContextCacheResponse ¶
func SetContextCacheResponse(ctx context.Context, req ChatCompletionRequest, resp *ChatCompletionResponse, productID uuid.UUID) error
Types ¶
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Model string `json:"model"`
Messages []types.Message `json:"messages"`
MaxTokens int `json:"max_tokens"`
Stream bool `json:"stream"`
}
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []Choice `json:"choices"`
Usage Usage `json:"usage"`
}
func CreateChatCompletionResponseFromCache ¶
func CreateChatCompletionResponseFromCache(cachedResponse string, model string) (*ChatCompletionResponse, error)
func HandleCacheLogic ¶
func HandleCacheLogic(ctx context.Context, req ChatCompletionRequest, productID uuid.UUID) (*ChatCompletionResponse, bool, error)
type InputRequest ¶
type Provider ¶
type Provider interface {
CreateChatCompletion(ctx context.Context, req ChatCompletionRequest) (*ChatCompletionResponse, error)
CreateChatCompletionStream(ctx context.Context, req ChatCompletionRequest) (Stream, error)
}
type Stream ¶
type Stream interface {
Recv() (StreamResponse, error)
Close()
}
type StreamResponse ¶
Click to show internal directories.
Click to hide internal directories.