Documentation
¶
Overview ¶
Package openai exposes OpenAI adapters. NewChat uses Chat Completions; NewResponses uses the Responses API.
Index ¶
- Constants
- type AudioTTSModel
- type AudioTTSModelConfig
- type AudioTranscriptionModel
- type AudioTranscriptionModelConfig
- type AudioTranslationModel
- type AudioTranslationModelConfig
- type Chat
- type ChatConfig
- type EmbeddingModel
- type EmbeddingModelConfig
- type ImageModel
- type ImageModelConfig
- type ModerationModel
- type ModerationModelConfig
- type Responses
- type ResponsesConfig
Examples ¶
Constants ¶
const ( Provider = "OpenAI" RequestExtensionKey = "openai/request" ResponseExtensionKey = "openai/response" StreamChunkExtensionKey = "openai/stream_chunk" ResponsesRequestExtensionKey = "openai/responses_request" ResponsesResponseExtensionKey = "openai/responses_response" SpeechRequestExtensionKey = "openai/speech_request" TranscriptionRequestExtensionKey = "openai/transcription_request" TranslationRequestExtensionKey = "openai/translation_request" EmbeddingRequestExtensionKey = "openai/embedding_request" ImageRequestExtensionKey = "openai/image_request" ModerationRequestExtensionKey = "openai/moderation_request" )
Exported identifiers keep provider-owned names and defaults out of caller literals.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AudioTTSModel ¶
type AudioTTSModel = openaiprotocol.AudioTTSModel
AudioTTSModel is the OpenAI-compatible speech protocol model.
func NewAudioTTSModel ¶
func NewAudioTTSModel(config AudioTTSModelConfig) (*AudioTTSModel, error)
NewAudioTTSModel rejects an invalid provider binding before the first speech call.
type AudioTTSModelConfig ¶
type AudioTTSModelConfig struct {
APIKey string
DefaultOptions tts.Options
BaseURL string
HTTPClient *http.Client
MaxResponseBytes int64
}
AudioTTSModelConfig binds provider access and defaults shared by every speech call.
func (AudioTTSModelConfig) Validate ¶
func (a AudioTTSModelConfig) Validate() error
type AudioTranscriptionModel ¶
type AudioTranscriptionModel = openaiprotocol.AudioTranscriptionModel
AudioTranscriptionModel is the OpenAI-compatible transcription protocol model.
func NewAudioTranscriptionModel ¶
func NewAudioTranscriptionModel(config AudioTranscriptionModelConfig) (*AudioTranscriptionModel, error)
NewAudioTranscriptionModel rejects an invalid provider binding before the first transcription call.
type AudioTranscriptionModelConfig ¶
type AudioTranscriptionModelConfig struct {
APIKey string
DefaultOptions transcription.Options
BaseURL string
HTTPClient *http.Client
}
AudioTranscriptionModelConfig binds provider access and defaults shared by every transcription call.
func (AudioTranscriptionModelConfig) Validate ¶
func (a AudioTranscriptionModelConfig) Validate() error
type AudioTranslationModel ¶
type AudioTranslationModel = openaiprotocol.AudioTranslationModel
AudioTranslationModel is the OpenAI-compatible translation protocol model.
func NewAudioTranslationModel ¶
func NewAudioTranslationModel(config AudioTranslationModelConfig) (*AudioTranslationModel, error)
NewAudioTranslationModel rejects an invalid provider binding before the first translation call.
type AudioTranslationModelConfig ¶
type AudioTranslationModelConfig struct {
APIKey string
DefaultOptions transcription.Options
BaseURL string
HTTPClient *http.Client
}
AudioTranslationModelConfig binds provider access and defaults shared by every translation call.
func (AudioTranslationModelConfig) Validate ¶
func (a AudioTranslationModelConfig) Validate() error
type Chat ¶
type Chat = openaiprotocol.ChatCompletions
Chat is the OpenAI Chat Completions protocol model.
func NewChat ¶
func NewChat(config ChatConfig) (*Chat, error)
NewChat rejects an invalid provider binding before the first chat call.
Example ¶
package main
import (
"fmt"
"github.com/Tangerg/scope/core/chat"
"github.com/Tangerg/scope/models/openai"
)
func main() {
model, err := openai.NewChat(openai.ChatConfig{
APIKey: "example-key",
DefaultOptions: chat.Options{Model: "example-model"},
})
if err != nil {
panic(err)
}
fmt.Println(model != nil)
}
Output: true
type ChatConfig ¶
type ChatConfig struct {
APIKey string
DefaultOptions corechat.Options
BaseURL string
HTTPClient *http.Client
}
ChatConfig configures the OpenAI Chat Completions endpoint. Construction does no network I/O; per-call overrides remain in chat.Request.
func (ChatConfig) Validate ¶
func (c ChatConfig) Validate() error
type EmbeddingModel ¶
type EmbeddingModel = openaiprotocol.EmbeddingModel
EmbeddingModel is the OpenAI-compatible embedding protocol model.
func NewEmbeddingModel ¶
func NewEmbeddingModel(config EmbeddingModelConfig) (*EmbeddingModel, error)
NewEmbeddingModel rejects an invalid provider binding before the first embedding call.
type EmbeddingModelConfig ¶
type EmbeddingModelConfig struct {
APIKey string
DefaultOptions embedding.Options
BaseURL string
HTTPClient *http.Client
}
EmbeddingModelConfig binds provider access and defaults shared by every embedding call.
func (EmbeddingModelConfig) Validate ¶
func (e EmbeddingModelConfig) Validate() error
type ImageModel ¶
type ImageModel = openaiprotocol.ImageModel
ImageModel is the OpenAI-compatible image protocol model.
func NewImageModel ¶
func NewImageModel(config ImageModelConfig) (*ImageModel, error)
NewImageModel rejects an invalid provider binding before the first image call.
type ImageModelConfig ¶
type ImageModelConfig struct {
APIKey string
DefaultOptions image.Options
BaseURL string
HTTPClient *http.Client
}
ImageModelConfig binds provider access and defaults shared by every image call.
func (ImageModelConfig) Validate ¶
func (i ImageModelConfig) Validate() error
type ModerationModel ¶
type ModerationModel = openaiprotocol.ModerationModel
ModerationModel is the OpenAI-compatible moderation protocol model.
func NewModerationModel ¶
func NewModerationModel(config ModerationModelConfig) (*ModerationModel, error)
NewModerationModel rejects an invalid provider binding before the first moderation call.
type ModerationModelConfig ¶
type ModerationModelConfig struct {
APIKey string
DefaultOptions moderation.Options
BaseURL string
HTTPClient *http.Client
}
ModerationModelConfig binds provider access and defaults shared by every moderation call.
func (ModerationModelConfig) Validate ¶
func (m ModerationModelConfig) Validate() error
type Responses ¶ added in v0.13.0
type Responses = openaiprotocol.Responses
Responses is the OpenAI Responses API model. It remains distinct from Chat because the endpoints expose different transport capabilities.
func NewResponses ¶ added in v0.13.0
func NewResponses(config ResponsesConfig) (*Responses, error)
NewResponses rejects an invalid provider binding before the first Responses call.
type ResponsesConfig ¶ added in v0.13.0
type ResponsesConfig struct {
APIKey string
DefaultOptions corechat.Options
BaseURL string
HTTPClient *http.Client
}
ResponsesConfig configures the OpenAI Responses endpoint independently from Chat Completions because their transport capabilities differ.
func (ResponsesConfig) Validate ¶ added in v0.13.0
func (r ResponsesConfig) Validate() error