mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-12 14:52:11 +02:00
init
This commit is contained in:
parent
c386f68743
commit
b6536eca38
100 changed files with 17680 additions and 377 deletions
27
ts/packages/cli/src/commands/embeddings.ts
Normal file
27
ts/packages/cli/src/commands/embeddings.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* Embeddings CLI commands.
|
||||
*
|
||||
* Generate text embeddings using the configured embedding model.
|
||||
*/
|
||||
|
||||
import type { Command } from "commander";
|
||||
import { createSocket, getOpts } from "./util.js";
|
||||
|
||||
export function registerEmbeddingsCommands(program: Command): void {
|
||||
program
|
||||
.command("embeddings")
|
||||
.description("Generate text embeddings")
|
||||
.argument("<text...>", "Text(s) to embed")
|
||||
.action(async (texts: string[], _opts, cmd) => {
|
||||
const opts = getOpts(cmd);
|
||||
const socket = await createSocket(opts);
|
||||
|
||||
try {
|
||||
const flow = socket.flow(opts.flow);
|
||||
const vectors = await flow.embeddings(texts);
|
||||
console.log(JSON.stringify(vectors, null, 2));
|
||||
} finally {
|
||||
socket.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue