Documentation ¶
Index ¶
- func ParseReplyMessages(input string) ([]replyMessage, error)
- type ChatCompletionChunk
- type ChatStats
- type ErrorResponse
- type ErrorResponseContent
- type Message
- type Model
- type Modelz
- type OpenrouterApi
- type Provider
- type RequestBody
- type ResponseFormat
- type SkippedMalformedLine
- type StreamingChoice
- type StreamingChoiceDelta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseReplyMessages ¶
Types ¶
type ChatCompletionChunk ¶
type ChatCompletionChunk struct { ID string `json:"id"` Model string `json:"model"` Object string `json:"object"` Created int64 `json:"created"` Choices []StreamingChoice `json:"choices"` }
type ChatStats ¶
type ChatStats struct { Data struct { ID string `json:"id"` Model string `json:"model"` Streamed bool `json:"streamed"` GenerationTime int `json:"generation_time"` CreatedAt string `json:"created_at"` TokensPrompt int `json:"tokens_prompt"` TokensCompletion int `json:"tokens_completion"` NativeTokensPrompt int `json:"native_tokens_prompt"` NativeTokensCompletion int `json:"native_tokens_completion"` NumMediaPrompt *int `json:"num_media_prompt"` NumMediaCompletion *int `json:"num_media_completion"` Origin string `json:"origin"` TotalCost float64 `json:"total_cost"` } `json:"data"` }
type ErrorResponse ¶
type ErrorResponse struct {
Err ErrorResponseContent `json:"error"`
}
func (ErrorResponse) Error ¶
func (err ErrorResponse) Error() string
type ErrorResponseContent ¶
type OpenrouterApi ¶
type OpenrouterApi struct {
// contains filtered or unexported fields
}
func NewOpenrouterApi ¶
func NewOpenrouterApi(apiKey string) *OpenrouterApi
func (OpenrouterApi) GetChatStats ¶
func (api OpenrouterApi) GetChatStats(chatId string) (ChatStats, error)
func (OpenrouterApi) GetCompletions ¶
func (api OpenrouterApi) GetCompletions(model string, messages []Message, resultWriter io.Writer) error
getCompletions queries openrouter with the given data and writes the result into the writer
func (OpenrouterApi) GetModels ¶
func (OpenrouterApi) GetModels() ([]Model, error)
type RequestBody ¶
type RequestBody struct { Model string `json:"model"` Messages []Message `json:"messages"` Stream bool `json:"stream"` ResponseFormat ResponseFormat `json:"response_format"` }
type ResponseFormat ¶
type ResponseFormat struct {
Type string `json:"type"`
}
type SkippedMalformedLine ¶
type SkippedMalformedLine struct{}
func (SkippedMalformedLine) Error ¶
func (SkippedMalformedLine) Error() string
type StreamingChoice ¶
type StreamingChoice struct { Index int `json:"index"` Delta StreamingChoiceDelta `json:"delta"` FinishReason *string `json:"finish_reason"` }
type StreamingChoiceDelta ¶
Click to show internal directories.
Click to hide internal directories.