123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- package gpt
- import "fmt"
- type APIError struct {
- StatusCode int `json:"status_code"`
- Message string `json:"message"`
- Type string `json:"type"`
- }
- func (e APIError) Error() string {
- return fmt.Sprintf("[%d:%s] %s", e.StatusCode, e.Type, e.Message)
- }
- type APIErrorResponse struct {
- Error APIError `json:"error"`
- }
- type EngineObject struct {
- ID string `json:"id"`
- Object string `json:"object"`
- Owner string `json:"owner"`
- Ready bool `json:"ready"`
- }
- type EnginesResponse struct {
- Data []EngineObject `json:"data"`
- Object string `json:"object"`
- }
- type ChatCompletionRequestMessage struct {
-
- Role string `json:"role"`
-
- Content string `json:"content"`
- }
- type ChatCompletionRequest struct {
-
- Model string `json:"model"`
-
- Messages []ChatCompletionRequestMessage `json:"messages"`
-
-
- Temperature float32 `json:"temperature,omitempty"`
-
-
- TopP float32 `json:"top_p,omitempty"`
-
- N int `json:"n,omitempty"`
-
- Stream bool `json:"stream,omitempty"`
-
- Stop []string `json:"stop,omitempty"`
-
- MaxTokens int `json:"max_tokens,omitempty"`
-
- PresencePenalty float32 `json:"presence_penalty,omitempty"`
-
- FrequencyPenalty float32 `json:"frequency_penalty,omitempty"`
-
- LogitBias map[string]float32 `json:"logit_bias,omitempty"`
-
- User string `json:"user,omitempty"`
- }
- type CompletionRequest struct {
- Model string `json:"model"`
-
- Prompt []string `json:"prompt,omitempty"`
-
- Suffix string `json:"suffix,omitempty"`
-
- MaxTokens int `json:"max_tokens,omitempty"`
-
- Temperature float32 `json:"temperature,omitempty"`
-
- TopP *float32 `json:"top_p,omitempty"`
-
- N *int `json:"n"`
-
-
- Stream bool `json:"stream,omitempty"`
-
- LogProbs *int `json:"logprobs"`
-
- Echo bool `json:"echo"`
-
- Stop []string `json:"stop,omitempty"`
-
- PresencePenalty float32 `json:"presence_penalty"`
-
- FrequencyPenalty float32 `json:"frequency_penalty"`
-
- BestOf int `json:"best_of,omitempty"`
-
- LogitBias map[string]float32 `json:"logit_bias,omitempty"`
-
- User string `json:"user,omitempty"`
-
- ConversationID string `json:"conversation_id,omitempty"`
- }
- type EditsRequest struct {
-
-
- Model string `json:"model"`
-
- Input string `json:"input,omitempty"`
-
- Instruction string `json:"instruction"`
-
- N *int `json:"n,omitempty"`
-
- Temperature *float32 `json:"temperature,omitempty"`
-
- TopP *float32 `json:"top_p,omitempty"`
- }
- type EmbeddingsRequest struct {
-
-
-
- Input []string `json:"input"`
-
- Model string `json:"model"`
-
-
-
-
-
-
- User string `json:"user,omitempty"`
- }
- type LogProbResult struct {
- Tokens []string `json:"tokens"`
- TokenLogProbs []float32 `json:"token_logprobs"`
- TopLogProbs []map[string]float32 `json:"top_logprobs"`
- TextOffset []int `json:"text_offset"`
- }
- type ChatCompletionResponseMessage struct {
- Role string `json:"role"`
- Content string `json:"content"`
- }
- type ChatCompletionResponseChoice struct {
- Index int `json:"index"`
- FinishReason string `json:"finish_reason"`
- Message ChatCompletionResponseMessage `json:"message"`
- }
- type ChatCompletionStreamResponseChoice struct {
- Index int `json:"index"`
- FinishReason string `json:"finish_reason"`
- Delta ChatCompletionResponseMessage `json:"delta"`
- }
- type ChatCompletionsResponseUsage struct {
- PromptTokens int `json:"prompt_tokens"`
- CompletionTokens int `json:"completion_tokens"`
- TotalTokens int `json:"total_tokens"`
- }
- type ChatCompletionResponse struct {
- ID string `json:"id"`
- Object string `json:"object"`
- Created int `json:"created"`
- Model string `json:"model"`
- Choices []ChatCompletionResponseChoice `json:"choices"`
- Usage ChatCompletionsResponseUsage `json:"usage"`
- }
- type ChatCompletionStreamResponse struct {
- ID string `json:"id"`
- Object string `json:"object"`
- Created int `json:"created"`
- Model string `json:"model"`
- Choices []ChatCompletionStreamResponseChoice `json:"choices"`
- Usage ChatCompletionsResponseUsage `json:"usage"`
- }
- type CompletionResponseChoice struct {
- Text string `json:"text"`
- Index int `json:"index"`
- LogProbs LogProbResult `json:"logprobs"`
- FinishReason string `json:"finish_reason"`
- }
- type CompletionResponse struct {
- ID string `json:"id"`
- Object string `json:"object"`
- Created int `json:"created"`
- Model string `json:"model"`
- Choices []CompletionResponseChoice `json:"choices"`
- Usage CompletionResponseUsage `json:"usage"`
- }
- type CompletionResponseUsage struct {
- PromptTokens int `json:"prompt_tokens"`
- CompletionTokens int `json:"completion_tokens"`
- TotalTokens int `json:"total_tokens"`
- }
- type EditsResponse struct {
- Object string `json:"object"`
- Created int `json:"created"`
- Choices []EditsResponseChoice `json:"choices"`
- Usage EditsResponseUsage `json:"usage"`
- }
- type EmbeddingsResult struct {
-
- Object string `json:"object"`
-
- Embedding []float64 `json:"embedding"`
- Index int `json:"index"`
- }
- type EmbeddingsUsage struct {
-
- PromptTokens int `json:"prompt_tokens"`
-
- TotalTokens int `json:"total_tokens"`
- }
- type EmbeddingsResponse struct {
- Object string `json:"object"`
- Data []EmbeddingsResult `json:"data"`
- Usage EmbeddingsUsage `json:"usage"`
- }
- type EditsResponseChoice struct {
- Text string `json:"text"`
- Index int `json:"index"`
- }
- type EditsResponseUsage struct {
- PromptTokens int `json:"prompt_tokens"`
- CompletionTokens int `json:"completion_tokens"`
- TotalTokens int `json:"total_tokens"`
- }
- type SearchRequest struct {
- Documents []string `json:"documents"`
- Query string `json:"query"`
- }
- type SearchData struct {
- Document int `json:"document"`
- Object string `json:"object"`
- Score float64 `json:"score"`
- }
- type SearchResponse struct {
- Data []SearchData `json:"data"`
- Object string `json:"object"`
- }
- type ImageRequest struct {
- Prompt string `json:"prompt,omitempty"`
- N int `json:"n,omitempty"`
- Size string `json:"size,omitempty"`
- ResponseFormat string `json:"response_format,omitempty"`
- User string `json:"user,omitempty"`
- }
- type ImageResponse struct {
- Created int64 `json:"created,omitempty"`
- Data []ImageResponseDataInner `json:"data,omitempty"`
- }
- type ImageResponseDataInner struct {
- URL string `json:"url,omitempty"`
- B64JSON string `json:"b64_json,omitempty"`
- }
|