cli.ts 624 B

123456789101112131415161718192021222324252627
  1. import { hc } from "hono/client";
  2. import type { Server } from "../src/server/server";
  3. const message = process.argv.slice(2).join(" ");
  4. console.log(message);
  5. const client = hc<Server.App>(`http://localhost:16713`);
  6. const session = await client.session_create.$post().then((res) => res.json());
  7. const result = await client.session_chat
  8. .$post({
  9. json: {
  10. sessionID: session.id,
  11. parts: [
  12. {
  13. type: "text",
  14. text: message,
  15. },
  16. ],
  17. },
  18. })
  19. .then((res) => res.json());
  20. for (const part of result.parts) {
  21. if (part.type === "text") {
  22. console.log(part.text);
  23. }
  24. }