Documentation ¶
Overview ¶
Package openAI defines the data structures used for OpenAI API requests and responses. It includes models for request payloads, response data, and associated metadata.
Index ¶
- func Create(id, name string, v *Config, workers map[eosc.RequireId]eosc.IWorker) (eosc.IWorker, error)
- func NewFactory() eosc.IExtenderDriverFactory
- func Register(register eosc.IExtenderDriverRegister)
- type Chat
- type ClientRequest
- type CompletionTokensDetails
- type Config
- type Converter
- type Error
- type IModelMode
- type Message
- type ModelConfig
- type Response
- type ResponseChoice
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Chat ¶
type Chat struct {
// contains filtered or unexported fields
}
Chat represents the chat mode implementation. It includes the endpoint and methods for request and response conversion.
func (*Chat) RequestConvert ¶
RequestConvert converts the request body for the Chat mode. It modifies the HTTP context to include the appropriate endpoint and formatted request body.
type ClientRequest ¶
type ClientRequest struct { // Messages is a list of messages forming the conversation history. Messages []*Message `json:"messages"` }
ClientRequest represents the request payload sent to the OpenAI API.
type CompletionTokensDetails ¶
type CompletionTokensDetails struct { // ReasoningTokens is the number of tokens used for reasoning in the response. ReasoningTokens int `json:"reasoning_tokens"` }
CompletionTokensDetails provides detailed information about completion tokens.
type Config ¶
type Config struct { APIKey string `json:"openai_api_key"` // APIKey is the authentication key for accessing OpenAI API. Organization string `json:"openai_organization"` // Organization specifies the associated organization ID (optional). Base string `json:"openai_api_base"` // Base is the base URL for OpenAI API. It can be customized if needed. }
Config represents the configuration for OpenAI API. It includes the necessary fields for authentication and base URL configuration.
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
func (*Converter) RequestConvert ¶
type IModelMode ¶
type IModelMode interface { Endpoint() string convert.IConverter }
IModelMode defines the interface for model modes. It includes methods for retrieving the endpoint and performing data conversion.
type Message ¶
type Message struct { // Role indicates the role of the message sender (e.g., "system", "user", "assistant"). Role string `json:"role"` // Content contains the actual text of the message. Content string `json:"content"` }
Message represents a single message in the conversation.
type ModelConfig ¶
type Response ¶
type Response struct { // Id is the unique identifier for the response. Id string `json:"id"` // Object specifies the type of object returned (e.g., "response"). Object string `json:"object"` // Created is the timestamp of when the response was generated. Created int `json:"created"` // Model indicates the model used to generate the response. Model string `json:"model"` // SystemFingerprint is a fingerprint of the system generating the response. SystemFingerprint string `json:"system_fingerprint"` // Choices contains the list of choices generated by the model. Choices []ResponseChoice `json:"choices"` // Usage provides information about token usage for the request and response. Usage Usage `json:"usage"` Error Error `json:"error"` }
Response represents the response payload received from the OpenAI API.
type ResponseChoice ¶
type ResponseChoice struct { // Index is the position of the choice in the response list. Index int `json:"index"` // Message contains the generated message for this choice. Message Message `json:"message"` // Logprobs provides log probability data for the tokens (if available). Logprobs interface{} `json:"logprobs"` // FinishReason indicates why the generation stopped (e.g., "length", "stop"). FinishReason string `json:"finish_reason"` }
ResponseChoice represents a single choice in the response.
type Usage ¶
type Usage struct { // PromptTokens is the number of tokens used in the input prompt. PromptTokens int `json:"prompt_tokens"` // CompletionTokens is the number of tokens generated in the response. CompletionTokens int `json:"completion_tokens"` // TotalTokens is the total number of tokens used (prompt + completion). TotalTokens int `json:"total_tokens"` // CompletionTokensDetails provides a breakdown of completion tokens. CompletionTokensDetails CompletionTokensDetails `json:"completion_tokens_details"` }
Usage provides information about the token counts for the request and response.