|
| 1 | +# Restack Agent with Tool Calling |
| 2 | + |
| 3 | +A sample repository with an agent using tool calling. |
| 4 | + |
| 5 | +## Requirements |
| 6 | + |
| 7 | +- **Node 20+** |
| 8 | + |
| 9 | +## Start Restack |
| 10 | + |
| 11 | +To start Restack, use the following Docker command: |
| 12 | + |
| 13 | +```bash |
| 14 | +docker run -d --pull always --name restack -p 5233:5233 -p 6233:6233 -p 7233:7233 ghcr.io/restackio/restack:main |
| 15 | +``` |
| 16 | + |
| 17 | +## Install dependencies and start services |
| 18 | + |
| 19 | +```bash |
| 20 | +npm install |
| 21 | +npm run dev |
| 22 | +``` |
| 23 | + |
| 24 | +This will start a Node.js app with Restack Services. |
| 25 | +Your code will be running and syncing with Restack to execute agents. |
| 26 | + |
| 27 | +## Run agents |
| 28 | + |
| 29 | +### from UI |
| 30 | + |
| 31 | +You can run agents from the UI by clicking the "Run" button. |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +### from API |
| 36 | + |
| 37 | +You can run agents from the API by using the generated endpoint: |
| 38 | + |
| 39 | +`POST http://localhost:6233/api/agents/agentChatTool` |
| 40 | + |
| 41 | +### from any client |
| 42 | + |
| 43 | +You can run agents with any client connected to Restack, for example: |
| 44 | + |
| 45 | +```bash |
| 46 | +npm run schedule |
| 47 | +``` |
| 48 | + |
| 49 | +executes `scheduleAgent.ts` which will connect to Restack and execute the `agentChatTool` agent. |
| 50 | + |
| 51 | +## Send events to the Agent |
| 52 | + |
| 53 | +### from UI |
| 54 | + |
| 55 | +You can send events like message or end from the UI. |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +And see the events in the run: |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +### from API |
| 64 | + |
| 65 | +You can send events to the agent by using the following endpoint: |
| 66 | + |
| 67 | +`PUT http://localhost:6233/api/agents/agentChatTool/:agentId/:runId` |
| 68 | + |
| 69 | +with the payload: |
| 70 | + |
| 71 | +```json |
| 72 | +{ |
| 73 | + "eventName": "message", |
| 74 | + "eventInput": { "content": "Sales on boots?" } |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +to send messages to the agent. |
| 79 | + |
| 80 | +or |
| 81 | + |
| 82 | +```json |
| 83 | +{ |
| 84 | + "eventName": "end" |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +to end the conversation with the agent. |
| 89 | + |
| 90 | +### from any client |
| 91 | + |
| 92 | +You can send event to the agent with any client connected to Restack, for example: |
| 93 | + |
| 94 | +Modify agentId and runId in eventAgent.ts and then run: |
| 95 | + |
| 96 | +```bash |
| 97 | +npm run event |
| 98 | +``` |
| 99 | + |
| 100 | +It will connect to Restack and send 2 events to the agent, one to generate another agent and another one to end the conversation. |
| 101 | + |
| 102 | +## Deploy on Restack Cloud |
| 103 | + |
| 104 | +To deploy the application on Restack, you can create an account at [https://console.restack.io](https://console.restack.io) |
0 commit comments