Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertPNGToDataURI(data []byte) string
- func CreateImageRequest(token string, prompt string) (*http.Request, error)
- func CreateSpeechToTextRequest(token string, audio []byte) (*http.Request, error)
- func CreateTextCompletionRequest(token string, model string, messages Messages, outputs ...string) (*http.Request, error)
- func CreateTextToSpeechRequest(token string, text string, opts ...TTSReqOptions) (*http.Request, error)
- func CreateVisionRequest(token string, model ModelConfig, messages Messages) (*http.Request, error)
- func Do(ctx context.Context, token string, model ModelConfig, prompt Prompt) (io.Reader, error)
- func DoImageRequest(ctx context.Context, token string, prompt string) ([]byte, error)
- func ErrorBadRequest(r http.Response) error
- func ErrorRateLimitExceeded(r http.Response) error
- func NewClientError(r *http.Response) error
- func ParseCreateImageResponse(resp *http.Response) (string, error)
- func ParseLinkToImage(link string) ([]byte, error)
- func ParseTextCompletionRequest(resp *http.Response) (io.Reader, error)
- func ParseVisionResponse(resp *http.Response) (io.Reader, error)
- func SpeechToText(ctx context.Context, token string, audio []byte) (string, error)
- func TextToSpeech(ctx context.Context, token string, text string) ([]byte, error)
- func URLToURI(url url.URL) (string, error)
- type BadRequestError
- type ClientError
- type ImageRequest
- type ImageResponse
- type Message
- type Messages
- type ModelConfig
- type Prompt
- type RateLimitError
- type TTSReqOptions
- type TextCompletionRequest
- type TextCompletionResponse
- type TextMessage
- type TextToSpeechRequestBody
- type VisionCompletionResponse
- type VisionImageURL
- type VisionMessage
- type VisionRequest
- type Voice
Constants ¶
View Source
const ( RoleUser = "user" RoleAssistant = "assistant" RoleSystem = "system" )
View Source
const ( GPT4o = "gpt-4o" GPT4oMini = "gpt-4o-mini" GPTo1 = "o1-preview" GPTo1Mini = "o1-mini" )
View Source
const ( DALLE3 = "dall-e-3" GPT4V = "gpt-4o" )
View Source
const ( TTS = "tts-1" TTS_HQ = "tts-1-hq" WHISPER = "whisper-1" )
Variables ¶
View Source
var Models = map[string]ModelConfig{ "gpt-4o": { Name: "gpt-4o", SupportsSystemMessages: true, SupportsVision: true, }, "gpt-4o-mini": { Name: "gpt-4o-mini", SupportsSystemMessages: true, SupportsVision: true, }, "o1-preview": { Name: "o1-preview", SupportsSystemMessages: false, SupportsVision: false, }, "o1-mini": { Name: "o1-mini", SupportsSystemMessages: false, SupportsVision: false, }, }
Functions ¶
func ConvertPNGToDataURI ¶
func CreateImageRequest ¶
func CreateVisionRequest ¶
func DoImageRequest ¶
func ErrorBadRequest ¶
func ErrorRateLimitExceeded ¶
func NewClientError ¶
func ParseLinkToImage ¶
func SpeechToText ¶
func TextToSpeech ¶
Types ¶
type BadRequestError ¶
func (BadRequestError) Error ¶
func (e BadRequestError) Error() string
type ClientError ¶
func (ClientError) Error ¶
func (e ClientError) Error() string
type ImageRequest ¶
type ImageRequest struct { Model string `json:"model"` Prompt string `json:"prompt"` N int `json:"n"` Size string `json:"size"` }
Image Generation Capability
type ImageResponse ¶
type ModelConfig ¶
type RateLimitError ¶
func (RateLimitError) Error ¶
func (e RateLimitError) Error() string
type TTSReqOptions ¶
type TTSReqOptions func(TextToSpeechRequestBody) TextToSpeechRequestBody
func WithVoice ¶
func WithVoice(voice Voice) TTSReqOptions
type TextCompletionRequest ¶
type TextCompletionResponse ¶
type TextCompletionResponse struct { Choices []struct { Message TextMessage `json:"message"` } `json:"choices"` }
type TextMessage ¶
func (TextMessage) GetFormat ¶
func (m TextMessage) GetFormat() string
type TextToSpeechRequestBody ¶
type VisionCompletionResponse ¶
type VisionCompletionResponse struct { Choices []struct { Message struct { Content string `json:"content"` } `json:"message"` } `json:"choices"` }
type VisionImageURL ¶
type VisionMessage ¶
type VisionMessage struct { Role string `json:"role"` Content []VisionImageURL `json:"content"` }
func (VisionMessage) GetContent ¶
func (m VisionMessage) GetContent() string
func (VisionMessage) GetFormat ¶
func (m VisionMessage) GetFormat() string
type VisionRequest ¶
Click to show internal directories.
Click to hide internal directories.