openai

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertHistoryToInputItems

func ConvertHistoryToInputItems(history []api.Message) []api.InputItem

ConvertHistoryToInputItems は api.ConvertHistoryToInputItems のエイリアス

func LevelToReasoningEffort

func LevelToReasoningEffort(level string) string

LevelToReasoningEffort は Thinking Level を OpenAI reasoning_effort に変換

Types

type CompactRequest

type CompactRequest struct {
	Model        string          `json:"model"`
	Input        []api.InputItem `json:"input"` // フル会話ウィンドウ
	Instructions string          `json:"instructions,omitempty"`
}

CompactRequest は /responses/compact リクエスト

type CompactResponse

type CompactResponse = api.CompactResponse

CompactResponse は api.CompactResponse のエイリアス

type ContentPart

type ContentPart struct {
	Type     string    `json:"type"`                // "text" or "image_url"
	Text     string    `json:"text,omitempty"`      // type="text"の場合
	ImageURL *ImageURL `json:"image_url,omitempty"` // type="image_url"の場合
}

ContentPart はマルチモーダルコンテンツのパート

type ImageURL

type ImageURL struct {
	URL string `json:"url"` // "data:image/png;base64,..." 形式
}

ImageURL は画像URL

type InputContentPart

type InputContentPart = api.InputContentPart

InputContentPart は api.InputContentPart のエイリアス(api packageで定義)

type InputItem

type InputItem = api.InputItem

InputItem は api.InputItem のエイリアス(api packageで定義)

type MultimodalMessage

type MultimodalMessage struct {
	Role    string        `json:"role"`
	Content []ContentPart `json:"content"`
}

MultimodalMessage はマルチモーダルメッセージ

type MultimodalRequest

type MultimodalRequest struct {
	Model           string        `json:"model"`
	Messages        []interface{} `json:"messages"` // Message or MultimodalMessage
	Stream          bool          `json:"stream"`
	ReasoningEffort string        `json:"reasoning_effort,omitempty"` // low/medium/high
}

MultimodalRequest はマルチモーダルAPIリクエスト

type Provider

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

Provider はOpenAI APIのプロバイダー実装

func New

func New(apiKey string) *Provider

New は新しいProviderを作成

func (*Provider) ChatWithImage

func (p *Provider) ChatWithImage(ctx context.Context, systemPrompt string, history []api.Message, userMessage string, image *api.ImageData, model string) (string, error)

ChatWithImage は画像付きメッセージで会話を行う

func (*Provider) ChatWithTools

func (p *Provider) ChatWithTools(ctx context.Context, systemPrompt string, history []api.Message, model string) (string, error)

ChatWithTools は Provider interface の実装(context対応)

func (*Provider) ClearResponseID added in v0.43.0

func (p *Provider) ClearResponseID()

ClearResponseID は responseID をクリアする(圧縮後などに使用)

func (*Provider) CompactHistory

func (p *Provider) CompactHistory(ctx context.Context, input []api.InputItem, model, instructions string) (*CompactResponse, error)

CompactHistory は会話履歴を Compact API で圧縮

func (*Provider) HasCachedResponseID added in v0.43.0

func (p *Provider) HasCachedResponseID() bool

HasCachedResponseID は Responses API のキャッシュ済み responseID があるか返す

func (*Provider) Name

func (p *Provider) Name() string

Name はプロバイダー名を返す

func (*Provider) SupportsCompact

func (p *Provider) SupportsCompact() bool

SupportsCompact は Compact API 対応を返す

func (*Provider) SupportsImages

func (p *Provider) SupportsImages() bool

SupportsImages は画像入力対応を返す

type ReasoningConfig

type ReasoningConfig struct {
	Effort string `json:"effort,omitempty"` // low, medium, high
}

ReasoningConfig は OpenAI Extended Thinking の設定

type ResponseMetadata

type ResponseMetadata struct {
	ID     string `json:"id"`               // "resp_xxx..."
	Status string `json:"status,omitempty"` // "in_progress", "completed"
	Model  string `json:"model,omitempty"`
}

ResponseMetadata はレスポンスメタデータ(response.created イベント用)

type ResponsesRequest

type ResponsesRequest struct {
	Model              string           `json:"model"`
	Input              interface{}      `json:"input,omitempty"`                // string or []InputItem(previous_response_id使用時は省略可)
	PreviousResponseID string           `json:"previous_response_id,omitempty"` // 前回のレスポンスID(キャッシュ用)
	Instructions       string           `json:"instructions,omitempty"`         // システムプロンプト
	Stream             bool             `json:"stream,omitempty"`
	Reasoning          *ReasoningConfig `json:"reasoning,omitempty"` // Extended Thinking
}

ResponsesRequest は Responses API リクエスト

type ResponsesResult

type ResponsesResult struct {
	Content    string // テキストコンテンツ
	ResponseID string // レスポンスID(response.created から取得)
}

ResponsesResult は Responses API のレスポンス結果(ID付き)

type ResponsesStreamChunk

type ResponsesStreamChunk struct {
	Type     string            `json:"type"`               // "response.output_text.delta", "response.created", etc.
	Delta    string            `json:"delta,omitempty"`    // テキスト差分
	Response *ResponseMetadata `json:"response,omitempty"` // response.created で取得
}

ResponsesStreamChunk は Responses API ストリーミングチャンク

Jump to

Keyboard shortcuts

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