chatgpt

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(client *openai.Client) (types.LLMProvider, error)

Types

type ChatGPT

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

func (*ChatGPT) CalculateCost

func (gpt *ChatGPT) CalculateCost(model string, inputTokens, outputTokens, cachedTokens int64) int64

CalculateCost returns total USD cents (rounded half-up) at Standard pricing. Reasoning tokens must be included in outputTokens by the caller.

func (*ChatGPT) Chat

func (gpt *ChatGPT) Chat(ctx context.Context, model string, request *types.ChatRequest) (types.ChatResponse, error)

func (*ChatGPT) CheckContextWindow

func (gpt *ChatGPT) CheckContextWindow(model string, totalInputTokens, compactAtPercent int) error

func (*ChatGPT) EstimateInputTokens

func (gpt *ChatGPT) EstimateInputTokens(model string, messages []types.Message) (int, error)

func (*ChatGPT) ValidateModel

func (chatgpt *ChatGPT) ValidateModel(ctx context.Context, model string) error

type TokenUsage

type TokenUsage struct {
	InputTokens        int64 `json:"input_tokens"`
	OutputTokens       int64 `json:"output_tokens"`
	TotalTokens        int64 `json:"total_tokens"`
	InputTokensDetails struct {
		CachedTokens int64 `json:"cached_tokens"`
	} `json:"input_tokens_details"`
	OutputTokensDetails struct {
		ReasoningTokens int64 `json:"reasoning_tokens"`
	} `json:"output_tokens_details"`
}

Jump to

Keyboard shortcuts

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