Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/types/gotypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ declare global {
"ai:apitype"?: string;
"ai:model"?: string;
"ai:thinkinglevel"?: string;
"ai:verbosity"?: string;
"ai:endpoint"?: string;
"ai:azureapiversion"?: string;
"ai:apitoken"?: string;
Expand Down
18 changes: 13 additions & 5 deletions pkg/aiusechat/openai/openai-convertmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
const (
OpenAIDefaultAPIVersion = "2024-12-31"
OpenAIDefaultMaxTokens = 4096
// "medium" verbosity is more widely supported across models than "low"
OpenAIDefaultVerbosity = "medium"
)

// convertContentBlockToParts converts a single content block to UIMessageParts
Expand Down Expand Up @@ -190,10 +192,11 @@ func debugPrintReq(req *OpenAIRequest, endpoint string) {
func buildOpenAIHTTPRequest(ctx context.Context, inputs []any, chatOpts uctypes.WaveChatOpts, cont *uctypes.WaveContinueResponse) (*http.Request, error) {
opts := chatOpts.Config

// If continuing from premium rate limit, downgrade to default model and low thinking
// If continuing from premium rate limit, downgrade to default model and medium thinking
// (medium is more widely supported than low across different models)
if cont != nil && cont.ContinueFromKind == uctypes.StopKindPremiumRateLimit {
opts.Model = uctypes.DefaultOpenAIModel
opts.ThinkingLevel = uctypes.ThinkingLevelLow
opts.ThinkingLevel = uctypes.ThinkingLevelMedium
}

if opts.Model == "" {
Expand Down Expand Up @@ -229,13 +232,18 @@ func buildOpenAIHTTPRequest(ctx context.Context, inputs []any, chatOpts uctypes.
}

// Build request body
// Use configured verbosity, or fall back to default constant
verbosity := opts.Verbosity
if verbosity == "" {
verbosity = OpenAIDefaultVerbosity
}
reqBody := &OpenAIRequest{
Model: opts.Model,
Input: inputs,
Stream: true,
StreamOptions: &StreamOptionsType{IncludeObfuscation: false},
MaxOutputTokens: maxTokens,
Text: &TextType{Verbosity: "low"},
Text: &TextType{Verbosity: verbosity},
}

// Add system prompt as instructions if provided
Expand Down Expand Up @@ -264,10 +272,10 @@ func buildOpenAIHTTPRequest(ctx context.Context, inputs []any, chatOpts uctypes.
reqBody.Tools = append(reqBody.Tools, webSearchTool)
}

// Set reasoning based on thinking level
// Set reasoning based on thinking level from config
if opts.ThinkingLevel != "" {
reqBody.Reasoning = &ReasoningType{
Effort: opts.ThinkingLevel, // low, medium, high map directly
Effort: opts.ThinkingLevel,
}
if opts.Model == "gpt-5" || opts.Model == "gpt-5.1" {
reqBody.Reasoning.Summary = "auto"
Expand Down
1 change: 1 addition & 0 deletions pkg/aiusechat/uctypes/uctypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ type AIOptsType struct {
MaxTokens int `json:"maxtokens,omitempty"`
TimeoutMs int `json:"timeoutms,omitempty"`
ThinkingLevel string `json:"thinkinglevel,omitempty"` // ThinkingLevelLow, ThinkingLevelMedium, or ThinkingLevelHigh
Verbosity string `json:"verbosity,omitempty"` // Text verbosity level (OpenAI Responses API only, ignored by other backends)
AIMode string `json:"aimode,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
WaveAIPremium bool `json:"waveaipremium,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/aiusechat/usechat.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,17 @@ func getWaveAISettings(premium bool, builderMode bool, rtInfo waveobj.ObjRTInfo,
if thinkingLevel == "" {
thinkingLevel = uctypes.ThinkingLevelMedium
}
verbosity := config.Verbosity
if verbosity == "" {
verbosity = uctypes.ThinkingLevelMedium // default to medium
}
opts := &uctypes.AIOptsType{
Provider: config.Provider,
APIType: config.APIType,
Model: config.Model,
MaxTokens: maxTokens,
ThinkingLevel: thinkingLevel,
Verbosity: verbosity,
AIMode: aiMode,
Endpoint: baseUrl,
Capabilities: config.Capabilities,
Expand Down
1 change: 1 addition & 0 deletions pkg/wconfig/settingsconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ type AIModeConfigType struct {
APIType string `json:"ai:apitype,omitempty" jsonschema:"enum=google-gemini,enum=openai-responses,enum=openai-chat"`
Model string `json:"ai:model,omitempty"`
ThinkingLevel string `json:"ai:thinkinglevel,omitempty" jsonschema:"enum=low,enum=medium,enum=high"`
Verbosity string `json:"ai:verbosity,omitempty" jsonschema:"enum=low,enum=medium,enum=high,description=Text verbosity level (OpenAI Responses API only)"`
Endpoint string `json:"ai:endpoint,omitempty"`
AzureAPIVersion string `json:"ai:azureapiversion,omitempty"`
APIToken string `json:"ai:apitoken,omitempty"`
Expand Down
9 changes: 9 additions & 0 deletions schema/waveai.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@
"high"
]
},
"ai:verbosity": {
"type": "string",
"enum": [
"low",
"medium",
"high"
],
"description": "Text verbosity level (OpenAI Responses API only)"
},
"ai:endpoint": {
"type": "string"
},
Expand Down