openaichatcomp

package
v0.0.0-...-3420d2a Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package openaichatcomp provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.12.4 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCreateChatCompletionRequest

func NewCreateChatCompletionRequest(server string, body CreateChatCompletionJSONRequestBody) (*http.Request, error)

NewCreateChatCompletionRequest calls the generic CreateChatCompletion builder with application/json body

func NewCreateChatCompletionRequestWithBody

func NewCreateChatCompletionRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewCreateChatCompletionRequestWithBody generates requests for CreateChatCompletion with any type of body

Types

type ChatCompletionRequestMessage

type ChatCompletionRequestMessage struct {
	// Content The contents of the message
	Content string `json:"content"`

	// Name The name of the user in a multi-user chat
	Name *string `json:"name,omitempty"`

	// Role The role of the author of this message.
	Role ChatCompletionRequestMessageRole `json:"role"`
}

ChatCompletionRequestMessage defines model for ChatCompletionRequestMessage.

type ChatCompletionRequestMessageRole

type ChatCompletionRequestMessageRole string

ChatCompletionRequestMessageRole The role of the author of this message.

const (
	ChatCompletionRequestMessageRoleAssistant ChatCompletionRequestMessageRole = "assistant"
	ChatCompletionRequestMessageRoleSystem    ChatCompletionRequestMessageRole = "system"
	ChatCompletionRequestMessageRoleUser      ChatCompletionRequestMessageRole = "user"
)

Defines values for ChatCompletionRequestMessageRole.

type ChatCompletionResponseMessage

type ChatCompletionResponseMessage struct {
	// Content The contents of the message
	Content string `json:"content"`

	// Role The role of the author of this message.
	Role ChatCompletionResponseMessageRole `json:"role"`
}

ChatCompletionResponseMessage defines model for ChatCompletionResponseMessage.

type ChatCompletionResponseMessageRole

type ChatCompletionResponseMessageRole string

ChatCompletionResponseMessageRole The role of the author of this message.

const (
	ChatCompletionResponseMessageRoleAssistant ChatCompletionResponseMessageRole = "assistant"
	ChatCompletionResponseMessageRoleSystem    ChatCompletionResponseMessageRole = "system"
	ChatCompletionResponseMessageRoleUser      ChatCompletionResponseMessageRole = "user"
)

Defines values for ChatCompletionResponseMessageRole.

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) CreateChatCompletion

func (c *Client) CreateChatCompletion(ctx context.Context, body CreateChatCompletionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) CreateChatCompletionWithBody

func (c *Client) CreateChatCompletionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// CreateChatCompletion request with any body
	CreateChatCompletionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	CreateChatCompletion(ctx context.Context, body CreateChatCompletionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) CreateChatCompletionWithBodyWithResponse

func (c *ClientWithResponses) CreateChatCompletionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateChatCompletion_, error)

CreateChatCompletionWithBodyWithResponse request with arbitrary body returning *CreateChatCompletion_

func (*ClientWithResponses) CreateChatCompletionWithResponse

func (c *ClientWithResponses) CreateChatCompletionWithResponse(ctx context.Context, body CreateChatCompletionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateChatCompletion_, error)

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// CreateChatCompletion request with any body
	CreateChatCompletionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateChatCompletion_, error)

	CreateChatCompletionWithResponse(ctx context.Context, body CreateChatCompletionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateChatCompletion_, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type CreateChatCompletionJSONRequestBody

type CreateChatCompletionJSONRequestBody = CreateChatCompletionRequest

CreateChatCompletionJSONRequestBody defines body for CreateChatCompletion for application/json ContentType.

type CreateChatCompletionRequest

type CreateChatCompletionRequest struct {
	// FrequencyPenalty Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
	//
	// [See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)
	FrequencyPenalty *float32 `json:"frequency_penalty"`

	// LogitBias Modify the likelihood of specified tokens appearing in the completion.
	//
	// Accepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.
	LogitBias *map[string]interface{} `json:"logit_bias"`

	// MaxTokens The maximum number of tokens allowed for the generated answer. By default, the number of tokens the model can return will be (4096 - prompt tokens).
	MaxTokens *int `json:"max_tokens,omitempty"`

	// Messages The messages to generate chat completions for, in the [chat format](/docs/guides/chat/introduction).
	Messages []ChatCompletionRequestMessage `json:"messages"`

	// Model ID of the model to use. Currently, only `gpt-3.5-turbo` and `gpt-3.5-turbo-0301` are supported.
	Model string `json:"model"`

	// N How many chat completion choices to generate for each input message.
	N *int `json:"n"`

	// PresencePenalty Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
	//
	// [See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)
	PresencePenalty *float32 `json:"presence_penalty"`

	// Stop Up to 4 sequences where the API will stop generating further tokens.
	Stop *CreateChatCompletionRequest_Stop `json:"stop,omitempty"`

	// Stream If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message.
	Stream *bool `json:"stream"`

	// Temperature What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
	//
	// We generally recommend altering this or `top_p` but not both.
	Temperature *float32 `json:"temperature"`

	// TopP An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
	//
	// We generally recommend altering this or `temperature` but not both.
	TopP *float32 `json:"top_p"`

	// User A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
	User *string `json:"user,omitempty"`
}

CreateChatCompletionRequest defines model for CreateChatCompletionRequest.

type CreateChatCompletionRequestStop0

type CreateChatCompletionRequestStop0 = string

CreateChatCompletionRequestStop0 defines model for .

type CreateChatCompletionRequestStop1

type CreateChatCompletionRequestStop1 = []string

CreateChatCompletionRequestStop1 defines model for .

type CreateChatCompletionRequest_Stop

type CreateChatCompletionRequest_Stop struct {
	// contains filtered or unexported fields
}

CreateChatCompletionRequest_Stop Up to 4 sequences where the API will stop generating further tokens.

func (CreateChatCompletionRequest_Stop) AsCreateChatCompletionRequestStop0

func (t CreateChatCompletionRequest_Stop) AsCreateChatCompletionRequestStop0() (CreateChatCompletionRequestStop0, error)

AsCreateChatCompletionRequestStop0 returns the union data inside the CreateChatCompletionRequest_Stop as a CreateChatCompletionRequestStop0

func (CreateChatCompletionRequest_Stop) AsCreateChatCompletionRequestStop1

func (t CreateChatCompletionRequest_Stop) AsCreateChatCompletionRequestStop1() (CreateChatCompletionRequestStop1, error)

AsCreateChatCompletionRequestStop1 returns the union data inside the CreateChatCompletionRequest_Stop as a CreateChatCompletionRequestStop1

func (*CreateChatCompletionRequest_Stop) FromCreateChatCompletionRequestStop0

func (t *CreateChatCompletionRequest_Stop) FromCreateChatCompletionRequestStop0(v CreateChatCompletionRequestStop0) error

FromCreateChatCompletionRequestStop0 overwrites any union data inside the CreateChatCompletionRequest_Stop as the provided CreateChatCompletionRequestStop0

func (*CreateChatCompletionRequest_Stop) FromCreateChatCompletionRequestStop1

func (t *CreateChatCompletionRequest_Stop) FromCreateChatCompletionRequestStop1(v CreateChatCompletionRequestStop1) error

FromCreateChatCompletionRequestStop1 overwrites any union data inside the CreateChatCompletionRequest_Stop as the provided CreateChatCompletionRequestStop1

func (CreateChatCompletionRequest_Stop) MarshalJSON

func (t CreateChatCompletionRequest_Stop) MarshalJSON() ([]byte, error)

func (*CreateChatCompletionRequest_Stop) MergeCreateChatCompletionRequestStop0

func (t *CreateChatCompletionRequest_Stop) MergeCreateChatCompletionRequestStop0(v CreateChatCompletionRequestStop0) error

MergeCreateChatCompletionRequestStop0 performs a merge with any union data inside the CreateChatCompletionRequest_Stop, using the provided CreateChatCompletionRequestStop0

func (*CreateChatCompletionRequest_Stop) MergeCreateChatCompletionRequestStop1

func (t *CreateChatCompletionRequest_Stop) MergeCreateChatCompletionRequestStop1(v CreateChatCompletionRequestStop1) error

MergeCreateChatCompletionRequestStop1 performs a merge with any union data inside the CreateChatCompletionRequest_Stop, using the provided CreateChatCompletionRequestStop1

func (*CreateChatCompletionRequest_Stop) UnmarshalJSON

func (t *CreateChatCompletionRequest_Stop) UnmarshalJSON(b []byte) error

type CreateChatCompletionResponse

type CreateChatCompletionResponse struct {
	Choices []struct {
		FinishReason *string                        `json:"finish_reason,omitempty"`
		Index        *int                           `json:"index,omitempty"`
		Message      *ChatCompletionResponseMessage `json:"message,omitempty"`
	} `json:"choices"`
	Created int    `json:"created"`
	Id      string `json:"id"`
	Model   string `json:"model"`
	Object  string `json:"object"`
	Usage   *struct {
		CompletionTokens int `json:"completion_tokens"`
		PromptTokens     int `json:"prompt_tokens"`
		TotalTokens      int `json:"total_tokens"`
	} `json:"usage,omitempty"`
}

CreateChatCompletionResponse defines model for CreateChatCompletionResponse.

type CreateChatCompletion_

type CreateChatCompletion_ struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *CreateChatCompletionResponse
}

func ParseCreateChatCompletion_

func ParseCreateChatCompletion_(rsp *http.Response) (*CreateChatCompletion_, error)

ParseCreateChatCompletion_ parses an HTTP response from a CreateChatCompletionWithResponse call

func (CreateChatCompletion_) Status

func (r CreateChatCompletion_) Status() string

Status returns HTTPResponse.Status

func (CreateChatCompletion_) StatusCode

func (r CreateChatCompletion_) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

Jump to

Keyboard shortcuts

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