@nhonh/qabot 0.2.2 → 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 +10 -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 || "";
|
|
@@ -185,21 +185,23 @@ export class AIEngine {
|
|
|
185
185
|
async callProxy(prompt) {
|
|
186
186
|
if (!this.baseUrl) {
|
|
187
187
|
throw new Error(
|
|
188
|
-
"Proxy provider requires baseUrl. Set ai.baseUrl in qabot.config.
|
|
188
|
+
"Proxy provider requires baseUrl. Set ai.baseUrl in qabot.config.json",
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
const headers = this.buildAuthHeaders();
|
|
193
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
|
+
|
|
194
201
|
const res = await fetch(this.baseUrl, {
|
|
195
202
|
method: "POST",
|
|
196
203
|
headers,
|
|
197
|
-
body: JSON.stringify(
|
|
198
|
-
model: this.model,
|
|
199
|
-
messages: [{ role: "user", content: prompt }],
|
|
200
|
-
temperature: this.temperature,
|
|
201
|
-
max_tokens: this.maxTokens,
|
|
202
|
-
}),
|
|
204
|
+
body: JSON.stringify(body),
|
|
203
205
|
});
|
|
204
206
|
if (!res.ok) {
|
|
205
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