types

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(v interface{}) (io.Reader, error)

Encode encodes v into a reader

Types

type AudioTranscriptionResponse added in v0.3.0

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

AudioTranscriptionResponse response for a transcription request

func DecodeAudioTranscriptionResponse added in v0.3.0

func DecodeAudioTranscriptionResponse(body io.Reader) (AudioTranscriptionResponse, error)

DecodeAudioTranscriptionResponse decodes a response from the audio transcription endpoint

type ChatMessage added in v0.2.0

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

type ChatRequest added in v0.2.0

type ChatRequest struct {
	Model            string        `json:"model"`
	Messages         []ChatMessage `json:"messages"`
	Temperature      float64       `json:"temperature"`
	TopP             float64       `json:"top_p"`
	N                int           `json:"n"`
	Stream           bool          `json:"stream"`
	Stop             []string      `json:"stop"`
	MaxTokens        int           `json:"max_tokens"`
	PresencePenalty  float64       `json:"presence_penalty"`
	FrequencyPenalty float64       `json:"frequency_penalty"`
	User             string        `json:"user"`
}

ChatRequest represents a request to the chat endpoint

func NewDefaultChatRequest added in v0.2.0

func NewDefaultChatRequest(prompt string) *ChatRequest

NewDefaultChatRequest returns a ChatRequest with default values

type ChatResponse added in v0.2.0

type ChatResponse struct {
	ID      string               `json:"id"`
	Object  string               `json:"object"`
	Created int                  `json:"created"`
	Choices []ChatResponseChoice `json:"choices"`
	Usage   Usage                `json:"usage"`
}

ChatResponse response for a chat request

func DecodeChatResponse added in v0.2.0

func DecodeChatResponse(body io.Reader) (ChatResponse, error)

DecodeChatResponse decodes a response from the chat endpoint

type ChatResponseChoice added in v0.2.0

type ChatResponseChoice struct {
	Index        int         `json:"index"`
	FinishReason string      `json:"finish_reason"`
	Message      ChatMessage `json:"message"`
}

type Choice

type Choice struct {
	Text         string      `json:"text"`
	Index        int         `json:"index"`
	LogProbs     interface{} `json:"logprobs"`
	FinishReason string      `json:"finish_reason"`
}

Choice represents a choice that the API returns

type CompletionRequest

type CompletionRequest struct {
	Model            string   `json:"model"`
	Prompt           string   `json:"prompt"`
	MaxTokens        int      `json:"max_tokens"`
	Temperature      float64  `json:"temperature"`
	TopP             float64  `json:"top_p"`
	N                int      `json:"n"`
	Stream           bool     `json:"stream"`
	Stop             []string `json:"stop"`
	PresencePenalty  float64  `json:"presence_penalty"`
	FrequencyPenalty float64  `json:"frequency_penalty"`
	BestOf           int      `json:"best_of"`
	User             string   `json:"user"`
	Suffix           string   `json:"suffix"`
	Echo             bool     `json:"echo"`
}

func NewDefaultCompletionRequest

func NewDefaultCompletionRequest(prompt string) *CompletionRequest

NewDefaultCompletionRequest returns a CompletionRequest with default values

type CompletionResponse

type CompletionResponse struct {
	ID      string   `json:"id"`
	Object  string   `json:"object"`
	Created int      `json:"created"`
	Model   string   `json:"model"`
	Choices []Choice `json:"choices"`
	Usage   Usage    `json:"usage"`
}

CompletionResponse response for completion

func DecodeCompletionResponse

func DecodeCompletionResponse(body io.Reader) (CompletionResponse, error)

DecodeCompletionResponse decodes a response from the completion endpoint

type Edit

type Edit struct {
	Text  string `json:"text"`
	Index int    `json:"index"`
}

Edit response for search

type EditRequest

type EditRequest struct {
	Model        string  `json:"model"`
	Input        string  `json:"input"`
	Instructions string  `json:"instruction"`
	Temperature  float64 `json:"temperature"`
	N            int     `json:"n"`
	TopP         float64 `json:"top_p"`
}

func NewDefaultEditRequest

func NewDefaultEditRequest(input, instructions string) *EditRequest

NewDefaultEditRequest returns a EditRequest with default values

type EditResponse

type EditResponse struct {
	Object  string `json:"object"`
	Created int    `json:"created"`
	Model   string `json:"model"`
	Edits   []Edit `json:"choices"`
	Usage   Usage  `json:"usage"`
}

EditResponse response for search

func DecodeEditResponse

func DecodeEditResponse(body io.Reader) (EditResponse, error)

DecodeEditResponse decodes a response from the edit endpoint

type Image

type Image struct {
	URL string `json:"url"`
}

Image response for an image

type ImageRequest

type ImageRequest struct {
	Prompt         string `json:"prompt"`
	N              int    `json:"n"`
	Size           string `json:"size"`
	ResponseFormat string `json:"response_format"`
	User           string `json:"user"`
}

func NewDefaultImageRequest

func NewDefaultImageRequest(prompt string) *ImageRequest

NewDefaultImageRequest returns a ImageRequest with default values

type ImageResponse

type ImageResponse struct {
	Created int     `json:"created"`
	Data    []Image `json:"data"`
}

ImageResponse response for an image generation request

func DecodeImageResponse

func DecodeImageResponse(body io.Reader) (ImageResponse, error)

DecodeImageResponse decodes a response from the image endpoint

type Model

type Model struct {
	ID         string      `json:"id"`
	Object     string      `json:"object"`
	OwnedBy    string      `json:"owned_by"`
	Permission interface{} `json:"permission"`
}

Model represents a model

type ModelsResponse

type ModelsResponse struct {
	Data   []Model `json:"data"`
	Object string  `json:"object"`
}

ModelsResponse response for listing models

func DecodeModelsResponse

func DecodeModelsResponse(body io.Reader) (ModelsResponse, error)

DecodeModelsResponse decodes a response from the models endpoint

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Usage represents the usage of the API

Jump to

Keyboard shortcuts

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