Usage
Client-side Usage
Make sure you have a ready setup on your server-side and client-side before you continue with this page.
Intialize
import { Client, Agent } from "@scoopika/client";
const client = new Client("http://localhost:4149/scoopika"); // Full URL to your API route that handles Scoopika functionalities
const agent = new Agent("AGENT_ID", client);
Run Agent
const response = await agent.run({
inputs: {message: "Hello!"},
hooks: {
onToken: (t) => console.log(t) // Capture agent output tokens in real-time
}
});
console.log(response);
Access Agent Data
You can load and access agent data on the client-side:
const agentData = await agent.load();
console.log(agentData);
Add Client-side Actions (Tools)
Client-side actions are external tools that are defined and executed on the client-side. giving your agents the power to execute actions on the client-side in real-time.
Notice that this page does not show how you can build a client-side action schema, check Tools documentation for that.
const actionSchema = {...}; // Replace with your tool schema
function actionFunc = () => {}; // Replace with your custom function
agent.addClientAction(actionFunc, actionSchema);
Was this page helpful?