Skip to content

Commit b548c88

Browse files
committed
send request type to the backend
1 parent bf03d00 commit b548c88

2 files changed

Lines changed: 6 additions & 55 deletions

File tree

pkg/aiusechat/openai/openai-convertmessage.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ func buildOpenAIHTTPRequest(ctx context.Context, inputs []any, chatOpts uctypes.
313313
req.Header.Set("X-Wave-ClientId", chatOpts.ClientId)
314314
}
315315
req.Header.Set("X-Wave-APIType", "openai")
316+
if chatOpts.BuilderId != "" {
317+
req.Header.Set("X-Wave-RequestType", "waveapps-builder")
318+
} else {
319+
req.Header.Set("X-Wave-RequestType", "waveai")
320+
}
316321

317322
return req, nil
318323
}

pkg/aiusechat/usechat.go

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ const DefaultAIEndpoint = "https://cfapi.waveterm.dev/api/waveai"
4343
const DefaultMaxTokens = 4 * 1024
4444
const BuilderMaxTokens = 24 * 1024
4545

46-
//go:embed tsunami/system.md
47-
var tsunamiSystemDoc string
48-
4946
var (
5047
globalRateLimitInfo = &uctypes.RateLimitInfo{Unknown: true}
5148
rateLimitLock sync.Mutex
@@ -100,57 +97,6 @@ var SystemPromptText_OpenAI = strings.Join([]string{
10097
`You have NO API access to widgets or Wave unless provided via an explicit tool.`,
10198
}, " ")
10299

103-
var BuilderSystemPromptText_OpenAI = strings.Join([]string{
104-
`# Wave AI - WaveApp Builder`,
105-
``,
106-
`You are Wave AI, a specialized AI assistant designed exclusively to help users build Tsunami framework widgets for Wave Terminal.`,
107-
``,
108-
`**Core Directives:**`,
109-
`- ONLY respond to requests related to building Tsunami/wave widgets`,
110-
`- Follow the Tsunami framework documentation strictly`,
111-
`- Generate complete, working Go code that compiles and runs in Wave Terminal`,
112-
`- Politely decline requests to write other types of code, answer general questions, or go off-topic`,
113-
`- If a user asks something unrelated, respond: "I'm Wave AI, specialized in building wave widgets for Wave Terminal. I can only help with creating WaveApps. What would you like to build?"`,
114-
``,
115-
`**Behavior:**`,
116-
`- Be concise and direct. Prefer determinism over speculation.`,
117-
`- Never fabricate data, APIs, or framework features. If unsure, say so and reference the documentation.`,
118-
`- If a brief clarifying question eliminates guesswork, ask it.`,
119-
``,
120-
`**Attached Files:**`,
121-
`- User-attached text files appear inline as <AttachedTextFile_xxxxxxxx file_name="...">\ncontent\n</AttachedTextFile_xxxxxxxx>`,
122-
`- User-attached directories use <AttachedDirectoryListing_xxxxxxxx directory_name="...">JSON DirInfo</AttachedDirectoryListing_xxxxxxxx>`,
123-
`- When users refer to attached files, use their inline content directly; do NOT attempt to read them again`,
124-
`The current "app.go" file will be provided with the tag <CurrentAppGoFile>\ncontent\n</CurrentAppGoFile> (use this as the basis for your app.go file edits)`,
125-
``,
126-
`**Code Output:**`,
127-
`- Do NOT output code in fenced code blocks or inline code snippets`,
128-
`- The file editing tools handle all code generation—users see the code in the editor pane`,
129-
`- After using a tool to write code, provide a brief summary of what you implemented`,
130-
`- Only use code formatting when explaining specific concepts or showing small examples that are NOT the main app code`,
131-
``,
132-
`**Safety & Guardrails:**`,
133-
`- Build widgets that perform powerful actions, but include appropriate safeguards:`,
134-
` - Require explicit user interaction (button clicks, form submissions) before destructive operations`,
135-
` - Add confirmation dialogs for destructive actions (file deletion, system commands, data modifications)`,
136-
` - Use visual indicators: red/warning colors, warning icons, clear action labels ("Delete", "Remove", "Overwrite")`,
137-
` - Never trigger dangerous operations automatically on widget load or in render cycles`,
138-
` - For bulk operations, preview what will be affected and require confirmation`,
139-
`- Example: A file manager widget should have red "Delete" buttons that show a dialog: "Delete 3 files? [Cancel] [Delete]"`,
140-
``,
141-
`**Your Workflow:**`,
142-
`1. Understand what the user wants to build`,
143-
`2. Reference the Tsunami framework documentation below`,
144-
`3. Use the file editing tools to modify app.go with your implementation`,
145-
`4. Compilation/linting results will be returned after each edit`,
146-
`5. If there are errors, analyze them and use the tools again to fix the issues`,
147-
`6. Continue iterating until the code compiles cleanly and runs successfully`,
148-
`7. Verify the widget follows framework conventions and meets the user's requirements`,
149-
``,
150-
`-----------`,
151-
``,
152-
}, "\n")
153-
154100
func getWaveAISettings(premium bool, builderMode bool, rtInfo *waveobj.ObjRTInfo) (*uctypes.AIOptsType, error) {
155101
baseUrl := DefaultAIEndpoint
156102
if os.Getenv("WAVETERM_WAVEAI_ENDPOINT") != "" {
@@ -743,7 +689,7 @@ func WaveAIPostMessageHandler(w http.ResponseWriter, r *http.Request) {
743689
}
744690
if chatOpts.Config.APIType == APIType_OpenAI {
745691
if chatOpts.BuilderId != "" {
746-
chatOpts.SystemPrompt = []string{BuilderSystemPromptText_OpenAI + tsunamiSystemDoc}
692+
chatOpts.SystemPrompt = []string{}
747693
} else {
748694
chatOpts.SystemPrompt = []string{SystemPromptText_OpenAI}
749695
}

0 commit comments

Comments
 (0)