@bdsh/ask-oxygent
v1.0.4
Published
A starter for creating a TypeScript package.
Readme
Ask OxyGent
A Node.js toolkit for interacting with OxyGent framework, supporting streaming AI responses via SSE (Server-Sent Events).
Installation
npm i @bdsh/ask-oxygentOr using pnpm:
pnpm add @bdsh/ask-oxygentUsage
import { fetchSSEAnswer } from "@bdsh/ask-oxygent";
export const doCalculate = async () => {
const answer = await fetchSSEAnswer("http://your_ip:port/sse/chat", {
query: "Compute the product of 3 and 4",
});
return answer;
};API
fetchSSEAnswer(url, postData)
Extracts answer content from SSE stream.
Parameters:
url(string): SSE endpoint URLpostData(Record<string, unknown>): POST request data, typically contains aqueryfield
Returns:
Promise<string>: Returns the answer content as a string
Notes:
- The function establishes a long connection and returns immediately when encountering data with
type=answer, then closes the connection - Throws an error if answer type data is not found
Development
Start the server
cd demo/server
uv run main.pyRun tests
pnpm testBuild
pnpm buildLicense
MIT
