openhorizon-cli 1.0.7 → 1.0.10
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/index.js +29 -8
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -223,6 +223,10 @@ async function* streamCompletion(baseUrl, apiKey, model, messages) {
|
|
|
223
223
|
const base = baseUrl.replace(/\/$/, "");
|
|
224
224
|
const v1base = base.endsWith("/v1") ? base : `${base}/v1`;
|
|
225
225
|
const url = `${v1base}/chat/completions`;
|
|
226
|
+
const systemMessage = {
|
|
227
|
+
role: "system",
|
|
228
|
+
content: "You are a helpful AI assistant. Respond in clear, concise Markdown. Made by Saidev Dhal at Galgotias University. You are hosted on NVIDIA DGX H200 GPUs."
|
|
229
|
+
};
|
|
226
230
|
const res = await fetch(url, {
|
|
227
231
|
method: "POST",
|
|
228
232
|
headers: {
|
|
@@ -230,13 +234,30 @@ async function* streamCompletion(baseUrl, apiKey, model, messages) {
|
|
|
230
234
|
Authorization: `Bearer ${apiKey}`,
|
|
231
235
|
"x-api-key": apiKey,
|
|
232
236
|
"x-client": "openhorizon-cli",
|
|
233
|
-
"x-client-version": "1.0.
|
|
237
|
+
"x-client-version": "1.0.10"
|
|
234
238
|
},
|
|
235
|
-
body: JSON.stringify({
|
|
239
|
+
body: JSON.stringify({
|
|
240
|
+
model,
|
|
241
|
+
messages: [systemMessage, ...messages],
|
|
242
|
+
stream: true
|
|
243
|
+
})
|
|
236
244
|
});
|
|
237
245
|
if (!res.ok) {
|
|
238
|
-
const
|
|
239
|
-
|
|
246
|
+
const bodyText = await res.text().catch(() => "");
|
|
247
|
+
let errorMessage = res.statusText || String(res.status);
|
|
248
|
+
try {
|
|
249
|
+
const json = JSON.parse(bodyText);
|
|
250
|
+
if (json.details) {
|
|
251
|
+
errorMessage = json.details;
|
|
252
|
+
} else if (json.error) {
|
|
253
|
+
errorMessage = json.error;
|
|
254
|
+
} else {
|
|
255
|
+
errorMessage = bodyText;
|
|
256
|
+
}
|
|
257
|
+
} catch {
|
|
258
|
+
errorMessage = bodyText || res.statusText || String(res.status);
|
|
259
|
+
}
|
|
260
|
+
throw new Error(errorMessage);
|
|
240
261
|
}
|
|
241
262
|
if (!res.body) throw new Error("No response body received from server.");
|
|
242
263
|
const reader = res.body.getReader();
|
|
@@ -280,7 +301,7 @@ async function runChatLoop(options) {
|
|
|
280
301
|
console.log(
|
|
281
302
|
chalk3.gray(
|
|
282
303
|
`
|
|
283
|
-
Commands: ${chalk3.white("/model")} ${chalk3.white("/clear")} ${chalk3.white("/help")} ${chalk3.white("/version")} ${chalk3.white("/update")} ${chalk3.white("exit")}
|
|
304
|
+
Commands: ${chalk3.white("/model")} ${chalk3.white("/history")} ${chalk3.white("/clear")} ${chalk3.white("/help")} ${chalk3.white("/version")} ${chalk3.white("/update")} ${chalk3.white("exit")}
|
|
284
305
|
`
|
|
285
306
|
)
|
|
286
307
|
);
|
|
@@ -314,12 +335,12 @@ async function runChatLoop(options) {
|
|
|
314
335
|
}
|
|
315
336
|
if (trimmed === "/version") {
|
|
316
337
|
console.log(chalk3.blue(`
|
|
317
|
-
OpenHorizon CLI version: ${chalk3.bold("1.0.
|
|
338
|
+
OpenHorizon CLI version: ${chalk3.bold("1.0.10")}
|
|
318
339
|
`));
|
|
319
340
|
continue;
|
|
320
341
|
}
|
|
321
342
|
if (trimmed === "/update") {
|
|
322
|
-
await runUpdate("1.0.
|
|
343
|
+
await runUpdate("1.0.10");
|
|
323
344
|
continue;
|
|
324
345
|
}
|
|
325
346
|
if (trimmed.startsWith("/history")) {
|
|
@@ -411,7 +432,7 @@ async function runChatLoop(options) {
|
|
|
411
432
|
// src/index.ts
|
|
412
433
|
dotenv.config();
|
|
413
434
|
var program = new Command();
|
|
414
|
-
var version = "1.0.
|
|
435
|
+
var version = "1.0.10";
|
|
415
436
|
program.name("openhorizon").description("CLI to interact with OpenHorizon AI Models").version(version, "-v, --version", "Output the current version");
|
|
416
437
|
program.command("version").description("Show the current CLI version").action(() => {
|
|
417
438
|
console.log(chalk4.blue(`OpenHorizon CLI version: ${chalk4.bold(version)}`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openhorizon-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Official CLI for OpenHorizon — chat with AI models directly from your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"build": "tsup",
|
|
18
18
|
"dev": "tsup --watch",
|
|
19
19
|
"prepublishOnly": "npm run build",
|
|
20
|
-
"
|
|
20
|
+
"release": "npm publish --access public"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
23
|
"openhorizon",
|