Documentation ¶
Overview ¶
Package goopenai is a generated GoMock package.
Index ¶
- Variables
- type Client
- func (c *Client) Call(ctx context.Context, method string, url string, body io.Reader) (response *http.Response, err error)
- func (c *Client) CreateChatCompletions(ctx context.Context, r *CreateChatCompletionsRequest, url string) (response *CreateChatCompletionsResponse, err error)
- func (c *Client) CreateChatCompletionsRaw(ctx context.Context, r *CreateChatCompletionsRequest, url string) ([]byte, error)
- func (c *Client) CreateEdits(ctx context.Context, r *CreateEditsRequest) (response *CreateEditsResponse, err error)
- func (c *Client) CreateEditsRaw(ctx context.Context, r *CreateEditsRequest) ([]byte, error)
- func (c *Client) CreateEmbeddings(ctx context.Context, r *CreateEmbeddingsRequest) (response *CreateEmbeddingsResponse, err error)
- func (c *Client) CreateEmbeddingsRaw(ctx context.Context, r *CreateEmbeddingsRequest) ([]byte, error)
- func (c *Client) CreateImages(ctx context.Context, r *CreateImagesRequest) (response *CreateImagesResponse, err error)
- func (c *Client) CreateImagesEdits(ctx context.Context, r *CreateImagesEditsRequest) (response *CreateImagesEditsResponse, err error)
- func (c *Client) CreateImagesEditsRaw(ctx context.Context, r *CreateImagesEditsRequest) ([]byte, error)
- func (c *Client) CreateImagesRaw(ctx context.Context, r *CreateImagesRequest) ([]byte, error)
- func (c *Client) CreateImagesVariations(ctx context.Context, r *CreateImagesVariationsRequest) (response *CreateImagesVariationsResponse, err error)
- func (c *Client) CreateImagesVariationsRaw(ctx context.Context, r *CreateImagesVariationsRequest) ([]byte, error)
- func (c *Client) CreateModerations(ctx context.Context, r *CreateModerationsRequest) (response *CreateModerationsResponse, err error)
- func (c *Client) CreateModerationsRaw(ctx context.Context, r *CreateModerationsRequest) ([]byte, error)
- func (c *Client) CreateTranscriptions(ctx context.Context, r *CreateTranscriptionsRequest) (response *CreateTranscriptionsResponse, err error)
- func (c *Client) CreateTranscriptionsRaw(ctx context.Context, r *CreateTranscriptionsRequest) ([]byte, error)
- func (c *Client) CreateTranslations(ctx context.Context, r *CreateTranslationsRequest) (response *CreateTranslationsResponse, err error)
- func (c *Client) CreateTranslationsRaw(ctx context.Context, r *CreateTranslationsRequest) ([]byte, error)
- func (c *Client) Get(ctx context.Context, url string, input any) (response []byte, err error)
- func (c *Client) ListModels(ctx context.Context) (response *ListModelsResponse, err error)
- func (c *Client) ListModelsRaw(ctx context.Context) ([]byte, error)
- func (c *Client) Post(ctx context.Context, url string, input any) (response []byte, err error)
- func (c *Client) RetrieveModel(ctx context.Context, id string) (response *RetrieveModelResponse, err error)
- func (c *Client) RetrieveModelRaw(ctx context.Context, id string) ([]byte, error)
- type ClientInterface
- type CompletionFunciton
- type CreateChatCompletionsChoice
- type CreateChatCompletionsRequest
- type CreateChatCompletionsResponse
- type CreateChatCompletionsUsave
- type CreateEditsChoice
- type CreateEditsRequest
- type CreateEditsResponse
- type CreateEditsUsage
- type CreateEmbeddingsData
- type CreateEmbeddingsRequest
- type CreateEmbeddingsResponse
- type CreateEmbeddingsUsage
- type CreateImagesData
- type CreateImagesEditsData
- type CreateImagesEditsRequest
- type CreateImagesEditsResponse
- type CreateImagesRequest
- type CreateImagesResponse
- type CreateImagesVariationsData
- type CreateImagesVariationsRequest
- type CreateImagesVariationsResponse
- type CreateModerationsCategories
- type CreateModerationsCategoriesScores
- type CreateModerationsRequest
- type CreateModerationsResponse
- type CreateModerationsResult
- type CreateTranscriptionsRequest
- type CreateTranscriptionsResponse
- type CreateTranslationsRequest
- type CreateTranslationsResponse
- type Error
- type ErrorResponse
- type Function
- type FunctionCall
- type HttpClient
- type ListModelsData
- type ListModelsResponse
- type LlamaCppParams
- type Message
- type MockHttpClient
- type MockHttpClientMockRecorder
- type ResponseFormat
- type RetrieveModelResponse
- type StrArray
- type ToolCallFunction
- type ToolCalls
- type ToolChoice
- type ToolChoiceObject
- type Tools
- type ToolsFunction
Constants ¶
This section is empty.
Variables ¶
var ErrStrArrayUnsupportedType = errors.New("unsupported type, must be string or []string")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, method string, url string, body io.Reader) (response *http.Response, err error)
Call makes a request
func (*Client) CreateChatCompletions ¶
func (c *Client) CreateChatCompletions(ctx context.Context, r *CreateChatCompletionsRequest, url string) (response *CreateChatCompletionsResponse, err error)
func (*Client) CreateChatCompletionsRaw ¶
func (c *Client) CreateChatCompletionsRaw(ctx context.Context, r *CreateChatCompletionsRequest, url string) ([]byte, error)
CreateChatCompletionsRaw creates a new completion. To use the OpenAI Chat API, pass "" as the url. Otherwise pass a valide endpoint for any server that mimics the API.
func (*Client) CreateEdits ¶
func (c *Client) CreateEdits(ctx context.Context, r *CreateEditsRequest) (response *CreateEditsResponse, err error)
func (*Client) CreateEditsRaw ¶
func (*Client) CreateEmbeddings ¶
func (c *Client) CreateEmbeddings(ctx context.Context, r *CreateEmbeddingsRequest) (response *CreateEmbeddingsResponse, err error)
func (*Client) CreateEmbeddingsRaw ¶
func (*Client) CreateImages ¶
func (c *Client) CreateImages(ctx context.Context, r *CreateImagesRequest) (response *CreateImagesResponse, err error)
func (*Client) CreateImagesEdits ¶
func (c *Client) CreateImagesEdits(ctx context.Context, r *CreateImagesEditsRequest) (response *CreateImagesEditsResponse, err error)
func (*Client) CreateImagesEditsRaw ¶
func (*Client) CreateImagesRaw ¶
func (*Client) CreateImagesVariations ¶
func (c *Client) CreateImagesVariations(ctx context.Context, r *CreateImagesVariationsRequest) (response *CreateImagesVariationsResponse, err error)
func (*Client) CreateImagesVariationsRaw ¶
func (*Client) CreateModerations ¶
func (c *Client) CreateModerations(ctx context.Context, r *CreateModerationsRequest) (response *CreateModerationsResponse, err error)
func (*Client) CreateModerationsRaw ¶
func (*Client) CreateTranscriptions ¶
func (c *Client) CreateTranscriptions(ctx context.Context, r *CreateTranscriptionsRequest) (response *CreateTranscriptionsResponse, err error)
func (*Client) CreateTranscriptionsRaw ¶
func (*Client) CreateTranslations ¶
func (c *Client) CreateTranslations(ctx context.Context, r *CreateTranslationsRequest) (response *CreateTranslationsResponse, err error)
func (*Client) CreateTranslationsRaw ¶
func (*Client) ListModels ¶
func (c *Client) ListModels(ctx context.Context) (response *ListModelsResponse, err error)
func (*Client) RetrieveModel ¶
type ClientInterface ¶
type ClientInterface interface { // ListModels Lists the currently available models, and provides basic information about each one such as the owner and availability. ListModels(ctx context.Context) (response *ListModelsResponse, err error) // RetrieveModel Retrieves a model instance, providing basic information about the model such as the owner and permissioning. RetrieveModel(ctx context.Context, id string) (response *RetrieveModelResponse, err error) // CreateChatCompletions Creates a completion for the provided prompt and parameters CreateChatCompletions(ctx context.Context, r *CreateChatCompletionsRequest, url string) (response *CreateChatCompletionsResponse, err error) // CreateEdits Creates a new edit for the provided input, instruction, and parameters. CreateEdits(ctx context.Context, r *CreateEditsRequest) (response *CreateEditsResponse, err error) // CreateImages Creates an image given a prompt. CreateImages(ctx context.Context, r *CreateImagesRequest) (response *CreateImagesResponse, err error) // CreateImagesEdits Creates an edited or extended image given an original image and a prompt. CreateImagesEdits(ctx context.Context, r *CreateImagesEditsRequest) (response *CreateImagesEditsResponse, err error) // CreateImagesVariations Creates a variation of a given image. CreateImagesVariations(ctx context.Context, r *CreateImagesVariationsRequest) (response *CreateImagesVariationsResponse, err error) // CreateEmbeddings Creates an embedding vector representing the input text. CreateEmbeddings(ctx context.Context, r *CreateEmbeddingsRequest) (response *CreateEmbeddingsResponse, err error) // CreateTranscriptions Transcribes audio into the input language. CreateTranscriptions(ctx context.Context, r *CreateTranscriptionsRequest) (response *CreateTranscriptionsResponse, err error) // CreateTranslations Translates audio into into English. CreateTranslations(ctx context.Context, r *CreateTranslationsRequest) (response *CreateTranslationsResponse, err error) // CreateModerations Classifies if text violates OpenAI's Content Policy CreateModerations(ctx context.Context, r *CreateModerationsRequest) (response *CreateModerationsResponse, err error) }
ClientInterface is the interface for the OpenAI API client. Documentation at https://platform.openai.com/docs/api-reference/introduction
type CompletionFunciton ¶
type CreateChatCompletionsRequest ¶
type CreateChatCompletionsRequest struct { Model string `json:"model,omitempty"` Messages []Message `json:"messages,omitempty"` Temperature float64 `json:"temperature,omitempty"` TopP *float64 `json:"top_p,omitempty"` N *int `json:"n,omitempty"` Stream *bool `json:"stream,omitempty"` Stop StrArray `json:"stop,omitempty"` MaxTokens *int `json:"max_tokens,omitempty"` PresencePenalty *float64 `json:"presence_penalty,omitempty"` FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"` LogitBias map[string]string `json:"logit_bias,omitempty"` ResponseFormat *ResponseFormat `json:"response_format,omitempty"` Seed *int `json:"seed,omitempty"` Tools []Tools `json:"tools,omitempty"` ToolChoice *ToolChoice `json:"tool_choice,omitempty"` User *string `json:"user,omitempty"` // The following struct is specific to the llama.cpp API and should be left empty for the OpenAI Chat API. CachePrompt *bool `json:"cache_prompt,omitempty"` // default: false, pass true to request caching. SlotId *int `json:"slot_id,omitempty"` // default: 0, pass a specific slot id to use a cached prompt. Prompt *string `json:"prompt,omitempty"` // used when asking for simple text completions // FunctionCall is deprecated in favor of Tools FunctionCall *string `json:"function_call,omitempty"` // Functions is deprecated in favor of Tools Functions []CompletionFunciton `json:"functions,omitempty"` }
type CreateChatCompletionsResponse ¶
type CreateChatCompletionsResponse struct { ID string `json:"id,omitempty"` Choices []CreateChatCompletionsChoice `json:"choices,omitempty"` Created int `json:"created,omitempty"` Model string `json:"model,omitempty"` SystemFingerprint string `json:"system_fingerprint,omitempty"` Object string `json:"object,omitempty"` Usage CreateChatCompletionsUsave `json:"usage,omitempty"` }
type CreateEditsChoice ¶
type CreateEditsRequest ¶
type CreateEditsResponse ¶
type CreateEditsResponse struct { Object string `json:"object,omitempty"` Created int `json:"created,omitempty"` Choices []CreateEditsChoice `json:"choices,omitempty"` Usage CreateEditsUsage `json:"usage,omitempty"` }
type CreateEditsUsage ¶
type CreateEmbeddingsData ¶
type CreateEmbeddingsRequest ¶
type CreateEmbeddingsResponse ¶
type CreateEmbeddingsResponse struct { Object string `json:"object,omitempty"` Data []CreateEmbeddingsData `json:"data,omitempty"` Model string `json:"model,omitempty"` Usage CreateEmbeddingsUsage `json:"usage,omitempty"` Error *Error `json:"error"` }
type CreateEmbeddingsUsage ¶
type CreateImagesData ¶
type CreateImagesData struct {
URL string `json:"url,omitempty"`
}
type CreateImagesEditsData ¶
type CreateImagesEditsData struct {
URL string `json:"url,omitempty"`
}
type CreateImagesEditsRequest ¶
type CreateImagesEditsRequest struct { Image string `json:"image,omitempty"` Mask string `json:"mask,omitempty"` 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 CreateImagesEditsResponse ¶
type CreateImagesEditsResponse struct { Created int `json:"created,omitempty"` Data []CreateImagesEditsData `json:"data,omitempty"` }
type CreateImagesRequest ¶
type CreateImagesResponse ¶
type CreateImagesResponse struct { Created int `json:"created,omitempty"` Data []CreateImagesData `json:"data,omitempty"` }
type CreateImagesVariationsData ¶
type CreateImagesVariationsData struct {
URL string `json:"url,omitempty"`
}
type CreateImagesVariationsResponse ¶
type CreateImagesVariationsResponse struct { Created int `json:"created,omitempty"` Data []CreateImagesVariationsData `json:"data,omitempty"` }
type CreateModerationsCategories ¶
type CreateModerationsCategories struct { Hate bool `json:"hate,omitempty"` HateThreatening bool `json:"hate/threatening,omitempty"` SelfHarm bool `json:"self-harm,omitempty"` Sexual bool `json:"sexual,omitempty"` SexualMinors bool `json:"sexual/minors,omitempty"` Violence bool `json:"violence,omitempty"` ViolenceGraphic bool `json:"violence/graphic,omitempty"` }
type CreateModerationsCategoriesScores ¶
type CreateModerationsCategoriesScores struct { Hate float64 `json:"hate,omitempty"` HateThreatening float64 `json:"hate/threatening,omitempty"` SelfHarm float64 `json:"self-harm,omitempty"` Sexual float64 `json:"sexual,omitempty"` SexualMinors float64 `json:"sexual/minors,omitempty"` Violence float64 `json:"violence,omitempty"` ViolenceGraphic float64 `json:"violence/graphic,omitempty"` }
type CreateModerationsResponse ¶
type CreateModerationsResponse struct { ID string `json:"id,omitempty"` Model string `json:"model,omitempty"` Results []CreateModerationsResult `json:"results,omitempty"` }
type CreateModerationsResult ¶
type CreateModerationsResult struct { Categories CreateModerationsCategories `json:"categories,omitempty"` CategoryScores CreateModerationsCategoriesScores `json:"category_scores,omitempty"` Flagged bool `json:"flagged,omitempty"` }
type CreateTranscriptionsRequest ¶
type CreateTranscriptionsRequest struct { File string `json:"file,omitempty"` Model string `json:"model,omitempty"` Prompt string `json:"prompt,omitempty"` ResponseFormat string `json:"response_format,omitempty"` Temperature float64 `json:"temperature,omitempty"` Language string `json:"language,omitempty"` }
type CreateTranscriptionsResponse ¶
type CreateTranscriptionsResponse struct {
Text string `json:"text,omitempty"`
}
type CreateTranslationsResponse ¶
type CreateTranslationsResponse struct {
Text string `json:"text,omitempty"`
}
type Error ¶
type Error struct { Message string `json:"message,omitempty"` Type string `json:"type,omitempty"` Param interface{} `json:"param,omitempty"` Code interface{} `json:"code,omitempty"` }
Error is the error standard response from the API
type ErrorResponse ¶
type ErrorResponse struct {
Error *Error `json:"error,omitempty"`
}
type FunctionCall ¶
type ListModelsData ¶
type ListModelsResponse ¶
type ListModelsResponse struct { Data []ListModelsData `json:"data,omitempty"` Object string `json:"object,omitempty"` }
type LlamaCppParams ¶ added in v1.2.3
type Message ¶
type Message struct { Role string `json:"role,omitempty"` Content string `json:"content,omitempty"` ToolCalls []ToolCalls `json:"tool_calls,omitempty"` // FunctionCall is deprecated in favor of ToolCalls FunctionCall *FunctionCall `json:"function_call,omitempty"` }
Message is the message struct for the chat and completions endpoint
type MockHttpClient ¶
type MockHttpClient struct {
// contains filtered or unexported fields
}
MockHttpClient is a mock of HttpClient interface.
func NewMockHttpClient ¶
func NewMockHttpClient(ctrl *gomock.Controller) *MockHttpClient
NewMockHttpClient creates a new mock instance.
func (*MockHttpClient) EXPECT ¶
func (m *MockHttpClient) EXPECT() *MockHttpClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockHttpClientMockRecorder ¶
type MockHttpClientMockRecorder struct {
// contains filtered or unexported fields
}
MockHttpClientMockRecorder is the mock recorder for MockHttpClient.
func (*MockHttpClientMockRecorder) Do ¶
func (mr *MockHttpClientMockRecorder) Do(req interface{}) *gomock.Call
Do indicates an expected call of Do.
type ResponseFormat ¶
type ResponseFormat struct {
Type string `json:"type"`
}
type RetrieveModelResponse ¶
type ToolCallFunction ¶
type ToolCalls ¶
type ToolCalls struct { ID string `json:"id,omitempty"` Type string `json:"type,omitempty"` Function ToolCallFunction `json:"function,omitempty"` }
type ToolChoice ¶
type ToolChoice struct { String *string `json:"string,omitempty"` Object *ToolChoiceObject `json:"object,omitempty"` }
func (*ToolChoice) MarshalJSON ¶
func (c *ToolChoice) MarshalJSON() ([]byte, error)
type ToolChoiceObject ¶
type ToolChoiceObject struct { Type string `json:"type"` Function ToolsFunction `json:"function"` }
type ToolsFunction ¶
type ToolsFunction struct {
Name string `json:"name"`
}