Package Exports
- @yourgpt/llmspark-nodejs
- @yourgpt/llmspark-nodejs/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@yourgpt/llmspark-nodejs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@yourgpt/llmspark-nodejs
This @yourgpt/llmspark-nodejs package provides convenient access to the LLM Spark REST API from JavaScript. It allows you to interact with the API and harness the power of AI for various tasks.
Installation
You can install this package using npm:
npm install @yourgpt/llmspark-nodejs
Setup API Keys:
Visit https://llmspark.yourgpt.ai and generate your API keys
const { LLMSpark } = require("@yourgpt/llmspark-nodejs");
const api = new LLMSpark({
apiKey: 'My Api Key'
});
Generate API Response with Stream:
The code below shows how to get started using the stream function with the stream set to true.
const main = async () => {
let data = await api.generate({
deployment_uid: "d5b67a9c-2768-4b06-b0b1-5eca4a15a0e",
variables: { "query_str":"how are you doing?"},
tags: ["user-123"],
stream: true
}});
for await(const stream of result.getOutput()){
console.log(stream)
}
console.log(data.getMetrics()); // for getting metrics
console.log(data.getNodes()); // for getting nodes
};
main();
Generate API Response without Stream:
The code below shows how to get started using the stream function with the default stream set to false.
const main = async () => {
let data = await api.generate({
deployment_uid: "d5b67a9c-2768-4b06-b0b1-5eca4a15a0e",
variables: { "query_str":"how are you doing?" },
tags: ["user-123"]
}});
console.log(data.getOutput()); // for getting output
console.log(data.getMetrics()); // for getting metrics
console.log(data.getNodes()); // for getting nodes
};
main();
Search API Response:
const search = async () => {
let data = await api.search({limit: 3, query: "what information you have?"});
return data;
};
search();