@octen.ai/cli 0.1.0 → 0.1.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/dist/commands/search.js +3 -2
- package/dist/output/pretty/embedding.d.ts +6 -5
- package/dist/output/pretty/embedding.js +14 -5
- package/dist/output/pretty/extract.d.ts +1 -2
- package/dist/output/pretty/extract.js +17 -3
- package/dist/output/pretty/search.d.ts +1 -2
- package/dist/output/pretty/search.js +16 -2
- package/dist/output/pretty/vlEmbedding.d.ts +5 -5
- package/dist/output/pretty/vlEmbedding.js +13 -5
- package/package.json +1 -1
package/dist/commands/search.js
CHANGED
|
@@ -5,7 +5,7 @@ import { renderSearch } from "../output/pretty/search.js";
|
|
|
5
5
|
import { makeClient, parseIntOpt } from "./utils.js";
|
|
6
6
|
export function registerSearch(program, fixedTopic) {
|
|
7
7
|
const cmd = program.command(fixedTopic ?? "search")
|
|
8
|
-
.argument("<query
|
|
8
|
+
.argument("<query...>", "search query")
|
|
9
9
|
.description(fixedTopic ? "News-focused web search" : "Search the live web")
|
|
10
10
|
.option("-n, --count <n>", "results 1-100", parseIntOpt("--count"))
|
|
11
11
|
.option("--include-domains <list>", "comma list", (v) => v.split(","))
|
|
@@ -20,9 +20,10 @@ export function registerSearch(program, fixedTopic) {
|
|
|
20
20
|
.option("--images").option("--videos");
|
|
21
21
|
if (!fixedTopic)
|
|
22
22
|
cmd.option("--topic <t>", "general|news");
|
|
23
|
-
cmd.action(async (
|
|
23
|
+
cmd.action(async (queryArg, opts, command) => {
|
|
24
24
|
const g = command.optsWithGlobals();
|
|
25
25
|
const client = makeClient(g);
|
|
26
|
+
const query = Array.isArray(queryArg) ? queryArg.join(" ") : queryArg;
|
|
26
27
|
const searchOpts = { ...opts, topic: fixedTopic ?? opts.topic };
|
|
27
28
|
const req = buildSearchRequest(query, searchOpts);
|
|
28
29
|
const res = await client.request(ENDPOINTS.search, req);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { EmbeddingResponse } from "../../api/embedding.js";
|
|
2
1
|
/**
|
|
3
2
|
* Render an OpenAI-style /embedding response in a compact table.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
|
|
5
|
+
* We unwrap to the inner body when present, then handle the shape robustly:
|
|
6
|
+
* - vectors at body.results ?? body.data ?? body.embeddings ?? []
|
|
6
7
|
* - each item's vector at item.embedding ?? item.vector ?? item (item may itself be the array)
|
|
7
|
-
* - model at data.model
|
|
8
|
+
* - model at body.model ?? data.model
|
|
8
9
|
*
|
|
9
10
|
* Raw float arrays are never printed in pretty mode.
|
|
10
11
|
*/
|
|
11
|
-
export declare function renderEmbedding(data:
|
|
12
|
+
export declare function renderEmbedding(data: any): string;
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import pc from "picocolors";
|
|
2
2
|
/**
|
|
3
3
|
* Render an OpenAI-style /embedding response in a compact table.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
|
|
6
|
+
* We unwrap to the inner body when present, then handle the shape robustly:
|
|
7
|
+
* - vectors at body.results ?? body.data ?? body.embeddings ?? []
|
|
6
8
|
* - each item's vector at item.embedding ?? item.vector ?? item (item may itself be the array)
|
|
7
|
-
* - model at data.model
|
|
9
|
+
* - model at body.model ?? data.model
|
|
8
10
|
*
|
|
9
11
|
* Raw float arrays are never printed in pretty mode.
|
|
10
12
|
*/
|
|
11
13
|
export function renderEmbedding(data) {
|
|
12
|
-
|
|
14
|
+
// Unwrap the envelope only when `data.data` is a non-array object (the real
|
|
15
|
+
// API shape). When `data.data` is itself an array (legacy un-enveloped shape),
|
|
16
|
+
// keep `data` as-is so the `?? data` fallback paths below still work.
|
|
17
|
+
const inner = data?.data;
|
|
18
|
+
const body = data && typeof data === "object" && inner && typeof inner === "object" && !Array.isArray(inner)
|
|
19
|
+
? inner
|
|
20
|
+
: data;
|
|
21
|
+
const items = (body?.results ?? body?.data ?? body?.embeddings ?? []);
|
|
13
22
|
if (!items.length) {
|
|
14
23
|
return pc.dim("No embeddings returned.");
|
|
15
24
|
}
|
|
16
|
-
const model = data?.model;
|
|
25
|
+
const model = body?.model ?? data?.model;
|
|
17
26
|
const lines = [];
|
|
18
27
|
// Header
|
|
19
28
|
const modelLabel = model ? pc.dim(` (${model})`) : "";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function renderExtract(data: ExtractResponse): string;
|
|
1
|
+
export declare function renderExtract(data: any): string;
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import pc from "picocolors";
|
|
2
2
|
const MAX_CONTENT = 500;
|
|
3
3
|
export function renderExtract(data) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
// The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
|
|
5
|
+
// Unwrap to the inner body only when `data.data` is a non-array object (the real
|
|
6
|
+
// API shape); fall back to the raw object otherwise so un-enveloped inputs still work.
|
|
7
|
+
const inner = data?.data;
|
|
8
|
+
const body = data && typeof data === "object" && inner && typeof inner === "object" && !Array.isArray(inner)
|
|
9
|
+
? inner
|
|
10
|
+
: data;
|
|
11
|
+
const items = body?.items ??
|
|
12
|
+
body?.results ??
|
|
6
13
|
[];
|
|
7
|
-
if (!items.length)
|
|
14
|
+
if (!items.length) {
|
|
15
|
+
// Surface app-level API errors (non-zero code) instead of a bland "No results."
|
|
16
|
+
const code = data?.code;
|
|
17
|
+
const msg = data?.msg;
|
|
18
|
+
if (code != null && code !== 0 && msg) {
|
|
19
|
+
return pc.red(`error: ${msg}`);
|
|
20
|
+
}
|
|
8
21
|
return pc.dim("No results.");
|
|
22
|
+
}
|
|
9
23
|
return items
|
|
10
24
|
.map((item) => {
|
|
11
25
|
const lines = [];
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function renderSearch(data: SearchResponse): string;
|
|
1
|
+
export declare function renderSearch(data: any): string;
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import pc from "picocolors";
|
|
2
2
|
const MAX_SNIPPET = 300;
|
|
3
3
|
export function renderSearch(data) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
// The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
|
|
5
|
+
// Unwrap to the inner body only when `data.data` is a non-array object (the real
|
|
6
|
+
// API shape); fall back to the raw object otherwise so un-enveloped inputs still work.
|
|
7
|
+
const inner = data?.data;
|
|
8
|
+
const body = data && typeof data === "object" && inner && typeof inner === "object" && !Array.isArray(inner)
|
|
9
|
+
? inner
|
|
10
|
+
: data;
|
|
11
|
+
const res = body?.results ?? [];
|
|
12
|
+
if (!res.length) {
|
|
13
|
+
// Surface app-level API errors (non-zero code) instead of a bland "No results."
|
|
14
|
+
const code = data?.code;
|
|
15
|
+
const msg = data?.msg;
|
|
16
|
+
if (code != null && code !== 0 && msg) {
|
|
17
|
+
return pc.red(`error: ${msg}`);
|
|
18
|
+
}
|
|
6
19
|
return pc.dim("No results.");
|
|
20
|
+
}
|
|
7
21
|
return res
|
|
8
22
|
.map((r, i) => {
|
|
9
23
|
const lines = [];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { VLEmbeddingResponse } from "../../api/vlEmbedding.js";
|
|
2
1
|
/**
|
|
3
2
|
* Render an Octen /vl-embedding response in a compact table.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
|
|
5
|
+
* We unwrap to the inner body when present, then handle the shape robustly:
|
|
6
|
+
* - item list at body.results ?? body.data ?? body.embeddings ?? body.items ?? []
|
|
7
7
|
* - each item's vector at item.embedding ?? item.vector ?? item (bare array)
|
|
8
8
|
* - item type label at item.type (e.g. "fusion" | "vl") when present
|
|
9
|
-
* - model from data.model
|
|
9
|
+
* - model from body.model ?? data.model
|
|
10
10
|
*
|
|
11
11
|
* Raw float arrays are never printed — use --json for those.
|
|
12
12
|
*/
|
|
13
|
-
export declare function renderVlEmbedding(data:
|
|
13
|
+
export declare function renderVlEmbedding(data: any): string;
|
|
@@ -2,20 +2,28 @@ import pc from "picocolors";
|
|
|
2
2
|
/**
|
|
3
3
|
* Render an Octen /vl-embedding response in a compact table.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
|
|
6
|
+
* We unwrap to the inner body when present, then handle the shape robustly:
|
|
7
|
+
* - item list at body.results ?? body.data ?? body.embeddings ?? body.items ?? []
|
|
7
8
|
* - each item's vector at item.embedding ?? item.vector ?? item (bare array)
|
|
8
9
|
* - item type label at item.type (e.g. "fusion" | "vl") when present
|
|
9
|
-
* - model from data.model
|
|
10
|
+
* - model from body.model ?? data.model
|
|
10
11
|
*
|
|
11
12
|
* Raw float arrays are never printed — use --json for those.
|
|
12
13
|
*/
|
|
13
14
|
export function renderVlEmbedding(data) {
|
|
14
|
-
|
|
15
|
+
// Unwrap the envelope only when `data.data` is a non-array object (the real
|
|
16
|
+
// API shape). When `data.data` is itself an array (legacy un-enveloped shape),
|
|
17
|
+
// keep `data` as-is so the `?? data` fallback paths below still work.
|
|
18
|
+
const inner = data?.data;
|
|
19
|
+
const body = data && typeof data === "object" && inner && typeof inner === "object" && !Array.isArray(inner)
|
|
20
|
+
? inner
|
|
21
|
+
: data;
|
|
22
|
+
const items = (body?.results ?? body?.data ?? body?.embeddings ?? body?.items ?? []);
|
|
15
23
|
if (!items.length) {
|
|
16
24
|
return pc.dim("No embeddings returned.");
|
|
17
25
|
}
|
|
18
|
-
const model = data?.model;
|
|
26
|
+
const model = body?.model ?? data?.model;
|
|
19
27
|
const modelLabel = model ? pc.dim(` (${model})`) : "";
|
|
20
28
|
const lines = [];
|
|
21
29
|
// Header
|