@nhonh/qabot 0.3.0 → 0.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nhonh/qabot",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "AI-powered universal QA automation tool. Import any project, AI analyzes and runs tests across all layers.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -117,6 +117,7 @@ export class AIEngine {
117
117
  messages: [{ role: "user", content: prompt }],
118
118
  temperature: this.temperature,
119
119
  max_tokens: this.maxTokens,
120
+ stream: false,
120
121
  }),
121
122
  });
122
123
  if (!res.ok) {
@@ -195,24 +196,42 @@ export class AIEngine {
195
196
 
196
197
  const headers = this.buildAuthHeaders();
197
198
 
198
- const body = {
199
+ const reqBody = {
199
200
  messages: [{ role: "user", content: prompt }],
200
201
  temperature: this.temperature,
201
202
  max_tokens: this.maxTokens,
203
+ stream: false,
202
204
  };
203
- if (this.model) body.model = this.model;
205
+ if (this.model) reqBody.model = this.model;
204
206
 
205
207
  const res = await fetch(this.baseUrl, {
206
208
  method: "POST",
207
209
  headers,
208
- body: JSON.stringify(body),
210
+ body: JSON.stringify(reqBody),
209
211
  });
210
212
  if (!res.ok) {
211
- const body = await res.text().catch(() => "");
212
- throw new Error(`Proxy API error (${res.status}): ${body}`);
213
+ const errText = await res.text().catch(() => "");
214
+ throw new Error(`Proxy API error (${res.status}): ${errText}`);
213
215
  }
214
216
 
215
- const data = await res.json();
217
+ const rawText = await res.text();
218
+ let data;
219
+ try {
220
+ data = JSON.parse(rawText);
221
+ } catch {
222
+ const jsonLine = rawText
223
+ .split("\n")
224
+ .find((l) => l.startsWith("data: ") && !l.includes("[DONE]"));
225
+ if (jsonLine) {
226
+ data = JSON.parse(jsonLine.slice(6));
227
+ if (data.choices?.[0]?.delta?.content) {
228
+ return data.choices[0].delta.content;
229
+ }
230
+ }
231
+ throw new Error(
232
+ `Proxy returned non-JSON response. First 200 chars: ${rawText.slice(0, 200)}`,
233
+ );
234
+ }
216
235
 
217
236
  if (data.choices?.[0]?.message?.content)
218
237
  return data.choices[0].message.content;
@@ -1,4 +1,4 @@
1
- export const VERSION = "0.3.0";
1
+ export const VERSION = "0.3.1";
2
2
  export const TOOL_NAME = "qabot";
3
3
 
4
4
  export const PROJECT_TYPES = [