vzcode 1.52.0 → 1.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{index-CoGL485l.js → index-BxRNGHcB.js} +110 -110
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/client/VZSidebar/AIChat/ChatInput.tsx +46 -43
- package/src/client/VZSidebar/AIChat/index.tsx +31 -29
- package/src/client/featureFlags.ts +2 -0
- package/src/server/aiChatHandler/llmStreaming.ts +28 -21
package/dist/index.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
|
|
21
21
|
rel="stylesheet"
|
|
22
22
|
/>
|
|
23
|
-
<script type="module" crossorigin src="/assets/index-
|
|
23
|
+
<script type="module" crossorigin src="/assets/index-BxRNGHcB.js"></script>
|
|
24
24
|
<link rel="stylesheet" crossorigin href="/assets/index-L1AANcDx.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
ButtonGroup,
|
|
11
11
|
ToggleButton,
|
|
12
12
|
} from '../../bootstrap';
|
|
13
|
+
import { enableAskMode } from '../../featureFlags';
|
|
13
14
|
|
|
14
15
|
interface ChatInputProps {
|
|
15
16
|
aiChatMessage: string;
|
|
@@ -58,50 +59,52 @@ const ChatInputComponent = ({
|
|
|
58
59
|
|
|
59
60
|
return (
|
|
60
61
|
<div className="ai-chat-input-container">
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
62
|
+
{enableAskMode && (
|
|
63
|
+
<div
|
|
64
|
+
className="ai-chat-mode-toggle"
|
|
65
|
+
style={{ marginBottom: '8px' }}
|
|
66
|
+
>
|
|
67
|
+
<ButtonGroup size="sm">
|
|
68
|
+
<ToggleButton
|
|
69
|
+
id="ai-chat-mode-ask"
|
|
70
|
+
type="radio"
|
|
71
|
+
variant={
|
|
72
|
+
aiChatMode === 'ask'
|
|
73
|
+
? 'primary'
|
|
74
|
+
: 'outline-primary'
|
|
75
|
+
}
|
|
76
|
+
name="ai-chat-mode"
|
|
77
|
+
value="ask"
|
|
78
|
+
checked={aiChatMode === 'ask'}
|
|
79
|
+
onChange={() => setAIChatMode('ask')}
|
|
80
|
+
disabled={isLoading}
|
|
81
|
+
>
|
|
82
|
+
💬 Ask
|
|
83
|
+
</ToggleButton>
|
|
84
|
+
<ToggleButton
|
|
85
|
+
id="ai-chat-mode-edit"
|
|
86
|
+
type="radio"
|
|
87
|
+
variant={
|
|
88
|
+
aiChatMode === 'edit'
|
|
89
|
+
? 'primary'
|
|
90
|
+
: 'outline-primary'
|
|
91
|
+
}
|
|
92
|
+
name="ai-chat-mode"
|
|
93
|
+
value="edit"
|
|
94
|
+
checked={aiChatMode === 'edit'}
|
|
95
|
+
onChange={() => setAIChatMode('edit')}
|
|
96
|
+
disabled={isLoading}
|
|
97
|
+
>
|
|
98
|
+
✏️ Edit
|
|
99
|
+
</ToggleButton>
|
|
100
|
+
</ButtonGroup>
|
|
101
|
+
<div className="ai-chat-mode-description">
|
|
102
|
+
{aiChatMode === 'ask'
|
|
103
|
+
? 'Ask questions without editing files'
|
|
104
|
+
: 'Get answers and code edits'}
|
|
105
|
+
</div>
|
|
103
106
|
</div>
|
|
104
|
-
|
|
107
|
+
)}
|
|
105
108
|
<Form.Group className="ai-chat-input-group">
|
|
106
109
|
<Form.Control
|
|
107
110
|
as="textarea"
|
|
@@ -164,39 +164,41 @@ export const AIChat = () => {
|
|
|
164
164
|
useEffect(() => {
|
|
165
165
|
DEBUG &&
|
|
166
166
|
console.log('AIChat: Checking for stored AI prompt');
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
console.log(
|
|
170
|
-
'AIChat: Stored prompt result:',
|
|
171
|
-
storedPrompt,
|
|
172
|
-
);
|
|
173
|
-
if (storedPrompt) {
|
|
174
|
-
// Restore the prompt and mode
|
|
167
|
+
if (getStoredAIPrompt) {
|
|
168
|
+
const storedPrompt = getStoredAIPrompt();
|
|
175
169
|
DEBUG &&
|
|
176
|
-
console.log(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
)
|
|
170
|
+
console.log(
|
|
171
|
+
'AIChat: Stored prompt result:',
|
|
172
|
+
storedPrompt,
|
|
173
|
+
);
|
|
174
|
+
if (storedPrompt) {
|
|
175
|
+
// Restore the prompt and mode
|
|
176
|
+
DEBUG &&
|
|
177
|
+
console.log('AIChat: Restoring prompt and mode');
|
|
178
|
+
setAIChatMessage(storedPrompt.prompt);
|
|
179
|
+
setAIChatMode(
|
|
180
|
+
storedPrompt.modelName === 'ask' ? 'ask' : 'edit',
|
|
181
|
+
);
|
|
181
182
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
// Clear the stored prompt
|
|
184
|
+
DEBUG &&
|
|
185
|
+
console.log('AIChat: Clearing stored prompt');
|
|
186
|
+
clearStoredAIPrompt();
|
|
186
187
|
|
|
187
|
-
|
|
188
|
-
DEBUG &&
|
|
189
|
-
console.log('AIChat: Scheduling auto-submit');
|
|
190
|
-
setTimeout(() => {
|
|
188
|
+
// Auto-submit the restored prompt after a short delay
|
|
191
189
|
DEBUG &&
|
|
192
|
-
console.log(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
190
|
+
console.log('AIChat: Scheduling auto-submit');
|
|
191
|
+
setTimeout(() => {
|
|
192
|
+
DEBUG &&
|
|
193
|
+
console.log(
|
|
194
|
+
'AIChat: Auto-submitting restored prompt',
|
|
195
|
+
);
|
|
196
|
+
handleSendMessage(storedPrompt.prompt);
|
|
197
|
+
}, 100);
|
|
198
|
+
} else {
|
|
199
|
+
DEBUG &&
|
|
200
|
+
console.log('AIChat: No stored prompt found');
|
|
201
|
+
}
|
|
200
202
|
}
|
|
201
203
|
}, [
|
|
202
204
|
getStoredAIPrompt,
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
parseMarkdownFiles,
|
|
3
3
|
StreamingMarkdownParser,
|
|
4
4
|
} from 'llm-code-format';
|
|
5
|
-
import { ChatOpenAI } from '@langchain/openai';
|
|
6
5
|
import OpenAI from 'openai';
|
|
7
6
|
import fs from 'fs';
|
|
8
7
|
import { generateRunId } from '@vizhub/viz-utils';
|
|
@@ -52,7 +51,9 @@ export const createLLMFunction = ({
|
|
|
52
51
|
chatId: VizChatId;
|
|
53
52
|
}) => {
|
|
54
53
|
return async (fullPrompt: string) => {
|
|
55
|
-
const localPresence =
|
|
54
|
+
const localPresence = enableStreamingEditing
|
|
55
|
+
? createAIEditLocalPresence()
|
|
56
|
+
: null;
|
|
56
57
|
|
|
57
58
|
// Create OpenRouter client for reasoning token support
|
|
58
59
|
const openRouterClient = new OpenAI({
|
|
@@ -154,14 +155,19 @@ export const createLLMFunction = ({
|
|
|
154
155
|
],
|
|
155
156
|
};
|
|
156
157
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
error
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
158
|
+
if (localPresence) {
|
|
159
|
+
localPresence.submit(
|
|
160
|
+
filePresence,
|
|
161
|
+
(error) => {
|
|
162
|
+
if (error) {
|
|
163
|
+
console.warn(
|
|
164
|
+
'AI Editor line presence submission error:',
|
|
165
|
+
error,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
);
|
|
170
|
+
}
|
|
165
171
|
}
|
|
166
172
|
}
|
|
167
173
|
},
|
|
@@ -196,14 +202,13 @@ export const createLLMFunction = ({
|
|
|
196
202
|
)({
|
|
197
203
|
model: modelName,
|
|
198
204
|
messages: [{ role: 'user', content: fullPrompt }],
|
|
199
|
-
max_tokens: 8192,
|
|
200
205
|
reasoning: {
|
|
201
206
|
effort: 'medium',
|
|
202
207
|
exclude: false,
|
|
203
208
|
},
|
|
204
209
|
provider: {
|
|
205
210
|
sort: 'throughput',
|
|
206
|
-
},
|
|
211
|
+
},
|
|
207
212
|
usage: { include: true },
|
|
208
213
|
stream: true,
|
|
209
214
|
});
|
|
@@ -283,15 +288,17 @@ export const createLLMFunction = ({
|
|
|
283
288
|
console.log(
|
|
284
289
|
'AI editing done, clearing AI Editor presence',
|
|
285
290
|
);
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
291
|
+
if (localPresence) {
|
|
292
|
+
localPresence.submit(null, (error) => {
|
|
293
|
+
DEBUG && console.log('AI Editor presence cleared');
|
|
294
|
+
if (error) {
|
|
295
|
+
console.warn(
|
|
296
|
+
'AI Editor presence cleanup error:',
|
|
297
|
+
error,
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
295
302
|
|
|
296
303
|
// If streaming editing is not enabled, we need to
|
|
297
304
|
// apply all the edits at once
|