@nhonh/qabot 0.2.1 → 0.2.3
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 +1 -1
- package/src/ai/ai-engine.js +11 -8
- package/src/cli/commands/auth.js +1 -1
- package/src/core/constants.js +1 -1
package/package.json
CHANGED
package/src/ai/ai-engine.js
CHANGED
|
@@ -9,7 +9,7 @@ export class AIEngine {
|
|
|
9
9
|
constructor(config = {}) {
|
|
10
10
|
this.provider = config.provider || "none";
|
|
11
11
|
this.model =
|
|
12
|
-
config.model
|
|
12
|
+
config.model ?? AI_PROVIDER_DEFAULTS[this.provider]?.model ?? "";
|
|
13
13
|
this.apiKey = resolveApiKey(config);
|
|
14
14
|
this.baseUrl =
|
|
15
15
|
config.baseUrl || AI_PROVIDER_DEFAULTS[this.provider]?.baseUrl || "";
|
|
@@ -29,6 +29,7 @@ export class AIEngine {
|
|
|
29
29
|
isAvailable() {
|
|
30
30
|
if (this.provider === "none") return false;
|
|
31
31
|
if (this.provider === "ollama") return true;
|
|
32
|
+
if (this.provider === "proxy") return !!this.baseUrl;
|
|
32
33
|
return !!this.apiKey;
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -184,21 +185,23 @@ export class AIEngine {
|
|
|
184
185
|
async callProxy(prompt) {
|
|
185
186
|
if (!this.baseUrl) {
|
|
186
187
|
throw new Error(
|
|
187
|
-
"Proxy provider requires baseUrl. Set ai.baseUrl in qabot.config.
|
|
188
|
+
"Proxy provider requires baseUrl. Set ai.baseUrl in qabot.config.json",
|
|
188
189
|
);
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
const headers = this.buildAuthHeaders();
|
|
192
193
|
|
|
194
|
+
const body = {
|
|
195
|
+
messages: [{ role: "user", content: prompt }],
|
|
196
|
+
temperature: this.temperature,
|
|
197
|
+
max_tokens: this.maxTokens,
|
|
198
|
+
};
|
|
199
|
+
if (this.model) body.model = this.model;
|
|
200
|
+
|
|
193
201
|
const res = await fetch(this.baseUrl, {
|
|
194
202
|
method: "POST",
|
|
195
203
|
headers,
|
|
196
|
-
body: JSON.stringify(
|
|
197
|
-
model: this.model,
|
|
198
|
-
messages: [{ role: "user", content: prompt }],
|
|
199
|
-
temperature: this.temperature,
|
|
200
|
-
max_tokens: this.maxTokens,
|
|
201
|
-
}),
|
|
204
|
+
body: JSON.stringify(body),
|
|
202
205
|
});
|
|
203
206
|
if (!res.ok) {
|
|
204
207
|
const body = await res.text().catch(() => "");
|
package/src/cli/commands/auth.js
CHANGED
|
@@ -147,7 +147,7 @@ async function interactiveSetup(projectDir, config, isEmpty) {
|
|
|
147
147
|
]);
|
|
148
148
|
|
|
149
149
|
aiConfig.baseUrl = proxyAnswers.baseUrl;
|
|
150
|
-
|
|
150
|
+
aiConfig.model = proxyAnswers.model || "";
|
|
151
151
|
|
|
152
152
|
if (proxyAnswers.authMethod === "bearer") {
|
|
153
153
|
aiConfig.authHeader = "Authorization";
|
package/src/core/constants.js
CHANGED