api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: EUPL-1.2 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseReplyMessages

func ParseReplyMessages(input string) ([]replyMessage, error)

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 ErrorResponseContent struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type Model

type Model struct {
	Id string `json:"id"`
}

type Modelz

type Modelz struct {
	Data []Model `json:"data"`
}

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 Provider

type Provider struct {
	RequireParameters bool `json:"require_parameters"`
}

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

type StreamingChoiceDelta struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Jump to

Keyboard shortcuts

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