From 2437ce3f8b79a7f9d987862b633f3340bfa2c1c4 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Mon, 19 May 2025 19:29:38 -0400 Subject: toolz --- js/example/cli.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 js/example/cli.ts (limited to 'js/example/cli.ts') diff --git a/js/example/cli.ts b/js/example/cli.ts new file mode 100644 index 000000000..bb7522cbb --- /dev/null +++ b/js/example/cli.ts @@ -0,0 +1,27 @@ +import { hc } from "hono/client"; +import type { Server } from "../src/server/server"; + +const message = process.argv.slice(2).join(" "); +console.log(message); + +const client = hc(`http://localhost:16713`); +const session = await client.session_create.$post().then((res) => res.json()); +const result = await client.session_chat + .$post({ + json: { + sessionID: session.id, + parts: [ + { + type: "text", + text: message, + }, + ], + }, + }) + .then((res) => res.json()); + +for (const part of result.parts) { + if (part.type === "text") { + console.log(part.text); + } +} -- cgit v1.2.3