Documentation
¶
Index ¶
- Variables
- func ApplyChatReasoning(cfg *config.Root, p *openai.ChatCompletionNewParams, forceDisable bool)
- func ApplyMaxResponseTokens(cfg *config.Root, p *openai.ChatCompletionNewParams)
- func ApplyReasoningDisable(p *openai.ChatCompletionNewParams)
- func BuildUserContentParts(content string, imageFiles map[int]string) []openai.ChatCompletionContentPartUnionParam
- func ImagePlaceholder(seq int) string
- func JumpLeftOverImgTag(line []rune, pos int) int
- func JumpRightOverImgTag(line []rune, pos int) int
- func MessageParams(system string, msgs []chatstore.Message, imageFiles map[int]string) []openai.ChatCompletionMessageParamUnion
- func ModelID(s string) shared.ChatModel
- func PopulateAssistantTurnUsage(dst *chatstore.Message, system string, msgsPrior []chatstore.Message, ...)
- func PromptDisplaySplit(system string, msgs []chatstore.Message, apiPromptTokens int64) (contextTok int64, lastUserTok int64)
- func UsagePromptParts(system string, msgs []chatstore.Message, promptTokens int64, ...) (contextTok int64, lastUserTok int64, contextEstimated bool)
- func UsageTokensDisplayParts(system string, msgs []chatstore.Message, u UsageStats, turnCount int) (contextTok, lastUserTok int64, contextEstimated bool, ...)
- type AssistantToolCall
- type AssistantTurnResult
- type StreamOpts
- type UsageStats
Constants ¶
This section is empty.
Variables ¶
var ErrStreamAccumulatorRejected = errors.New("chat completion stream accumulator rejected chunk")
Functions ¶
func ApplyChatReasoning ¶
func ApplyChatReasoning(cfg *config.Root, p *openai.ChatCompletionNewParams, forceDisable bool)
func ApplyMaxResponseTokens ¶
func ApplyMaxResponseTokens(cfg *config.Root, p *openai.ChatCompletionNewParams)
func ApplyReasoningDisable ¶
func ApplyReasoningDisable(p *openai.ChatCompletionNewParams)
func BuildUserContentParts ¶
func BuildUserContentParts(content string, imageFiles map[int]string) []openai.ChatCompletionContentPartUnionParam
func ImagePlaceholder ¶
ImagePlaceholder returns the placeholder string for a given image sequence number.
func JumpLeftOverImgTag ¶
JumpLeftOverImgTag treats an [img-<n>] tag as a single atomic unit: if the cursor lies anywhere inside the tag (start < pos <= end), it jumps to start (before the tag). Spaces around the tag are never considered part of the placeholder.
func JumpRightOverImgTag ¶
JumpRightOverImgTag treats an [img-<n>] tag as a single atomic unit: if the cursor lies anywhere inside the tag (start <= pos < end), it jumps to end (after the tag). Spaces around the tag are never considered part of the placeholder.
func MessageParams ¶
func MessageParams(system string, msgs []chatstore.Message, imageFiles map[int]string) []openai.ChatCompletionMessageParamUnion
MessageParams builds OpenAI API message params from chatstore messages. If imageFiles is non-nil and contains entries for [img-<n>] placeholders found in user messages, those placeholders are replaced with image content parts.
func PromptDisplaySplit ¶
func UsagePromptParts ¶
func UsageTokensDisplayParts ¶
Types ¶
type AssistantToolCall ¶
type AssistantTurnResult ¶
type AssistantTurnResult struct {
Content string
ReasoningText string
ToolCalls []AssistantToolCall
Usage UsageStats
}
func StreamAssistantTurn ¶
func StreamAssistantTurn(ctx context.Context, client openai.Client, params openai.ChatCompletionNewParams, contentOut io.Writer, opts StreamOpts) (AssistantTurnResult, error)
type StreamOpts ¶
type UsageStats ¶
type UsageStats struct {
PromptTokens int64
CachedPromptTokens int64
ReasoningTokens int64
ResponseTokens int64
TotalTokens int64
OutputTPS float64
TTFTSecs float64
PromptTPS float64
TurnWallSecs float64
ThoughtSecs float64
}
func AggregateConsecutiveTurnUsage ¶
func AggregateConsecutiveTurnUsage(usages []UsageStats) UsageStats
func StreamText ¶
func StreamText(ctx context.Context, client openai.Client, params openai.ChatCompletionNewParams, contentOut io.Writer, opts StreamOpts) (string, UsageStats, error)