@universis/node-agent-sdk
v1.1.0
Published
@universis Open WebUI Agent SDK for Node.js
Readme
@universis/node-agent-sdk
An Open WebUI SDK for Node.js
Test
This template uses jest for testing. To run the tests, use the following command:
npm testBuild
This template uses rollup for building the library. To build the library, use the following command:
npm run buildUsage
Create a chat and send messages
import { Agent } from '@universis/node-agent-sdk';
async function main() {
const agent = new Agent('http://localhost:3000', 'your-api-key');
const chat = await agent.chats.create(
{
model: 'gpt-oss:20b',
messages: [
{
role: 'user',
content: 'Hello, world!',
},
],
});
const response = await chat.send(
{
role: 'user',
content: 'How are you?',
},
(response) => {
console.log(response);
}
);
}
Attach files to a chat
import { Agent } from '@universis/node-agent-sdk';
async function main() {
const agent = new Agent('http://localhost:3000', 'your-api-key');
const chat = await agent.chats.create(
{
model: 'gpt-oss:20b',
messages: [
{
role: 'user',
content: 'Hello, world!',
},
],
});
// Attach a file to the chat
await chat.files.attachFrom('path/to/file.txt', {
contentType: 'text/plain',
});
const response = await chat.send(
{
role: 'user',
content: 'How are you?',
});
await agent.chats.delete(chat.id);
}