Skip to content

Commit 7c89411

Browse files
committed
client and screenshots
1 parent cc5c65f commit 7c89411

File tree

9 files changed

+62
-62
lines changed

9 files changed

+62
-62
lines changed

agent_chat/chat_post.png

1.65 KB
Loading

agent_chat/chat_put.png

-10 KB
Loading

agent_chat/chat_run.png

-14.6 KB
Loading
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
import { client } from "./src/client";
22

33
export type EventInput = {
4-
workflowId: string;
4+
agentId: string;
55
runId: string;
66
};
77

8-
async function eventWorkflow(input: EventInput) {
8+
async function eventAgent(input: EventInput) {
99
try {
10-
await client.sendWorkflowEvent({
10+
await client.sendAgentEvent({
1111
event: {
1212
name: "message",
1313
input: { content: "Tell me a joke" },
1414
},
15-
workflow: {
16-
workflowId: input.workflowId,
15+
agent: {
16+
agentId: input.agentId,
1717
runId: input.runId,
1818
},
1919
});
2020

21-
await client.sendWorkflowEvent({
21+
await client.sendAgentEvent({
2222
event: {
2323
name: "end",
2424
},
25-
workflow: {
26-
workflowId: input.workflowId,
25+
agent: {
26+
agentId: input.agentId,
2727
runId: input.runId,
2828
},
2929
});
3030

3131
process.exit(0); // Exit the process successfully
3232
} catch (error) {
33-
console.error("Error sending event to workflow:", error);
33+
console.error("Error sending event to agent:", error);
3434
process.exit(1); // Exit the process with an error code
3535
}
3636
}
3737

38-
eventWorkflow({
39-
workflowId: "your-workflow-id",
38+
eventAgent({
39+
agentId: "your-agent-id",
4040
runId: "your-run-id",
4141
});

agent_chat/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"dev": "open-cli http://localhost:5233 && tsx watch --include src src/services.ts",
77
"build": "tsc --build",
88
"clean": "rm -rf node_modules",
9-
"schedule-workflow": "tsx scheduleWorkflow.ts",
10-
"event-workflow": "tsx eventWorkflow.ts"
9+
"schedule-agent": "tsx scheduleAgent.ts",
10+
"event-agent": "tsx eventAgent.ts"
1111
},
1212
"dependencies": {
13-
"@restackio/ai": "^0.0.101",
13+
"@restackio/ai": "^0.0.102",
1414
"@temporalio/workflow": "1.11.3",
1515
"openai": "^4.80.1"
1616
},

agent_chat/pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agent_chat/readme.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Restack Agent Chat
22

3-
A sample repository with a an agent chat workflow.
3+
A sample repository with a an agent chat.
44

55
## Requirements
66

@@ -22,31 +22,31 @@ npm run dev
2222
```
2323

2424
This will start a Node.js app with Restack Services.
25-
Your code will be running and syncing with Restack to execute workflows or functions.
25+
Your code will be running and syncing with Restack to execute agents.
2626

27-
## Run workflows
27+
## Run agents
2828

2929
### from UI
3030

31-
You can run workflows from the UI by clicking the "Run" button.
31+
You can run agents from the UI by clicking the "Run" button.
3232

33-
![Run workflows from UI](./chat_post.png)
33+
![Run agents from UI](./chat_post.png)
3434

3535
### from API
3636

37-
You can run workflows from the API by using the generated endpoint:
37+
You can run agents from the API by using the generated endpoint:
3838

39-
`POST http://localhost:6233/api/workflows/agentChat`
39+
`POST http://localhost:6233/api/agents/agentChat`
4040

4141
### from any client
4242

43-
You can run workflows with any client connected to Restack, for example:
43+
You can run agents with any client connected to Restack, for example:
4444

4545
```bash
46-
npm schedule-workflow
46+
npm schedule-agent
4747
```
4848

49-
executes `scheduleWorkflow.ts` which will connect to Restack and execute the `agentChat` workflow.
49+
executes `scheduleAgent.ts` which will connect to Restack and execute the `agentChat` agent.
5050

5151
## Send events to the Agent
5252

@@ -64,7 +64,7 @@ And see the events in the run:
6464

6565
You can send events to the agent by using the following endpoint:
6666

67-
`PUT http://localhost:6233/api/workflows/AgentWorkflow/:workflowId/:runId`
67+
`PUT http://localhost:6233/api/agents/AgentChat/:agentId/:runId`
6868

6969
with the payload:
7070

@@ -89,12 +89,12 @@ to end the conversation with the agent.
8989

9090
### from any client
9191

92-
You can send event to the agent workflows with any client connected to Restack, for example:
92+
You can send event to the agent with any client connected to Restack, for example:
9393

94-
Modify workflow_id and run_id in event_workflow.py and then run:
94+
Modify agentId and runId in eventAgent.ts and then run:
9595

9696
```bash
97-
pnpm event-workflow
97+
pnpm event-agent
9898
```
9999

100100
It will connect to Restack and send 2 events to the agent, one to generate another agent and another one to end the conversation.

agent_chat/scheduleAgent.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { client } from "./src/client";
2+
3+
export type InputSchedule = {
4+
name: string;
5+
};
6+
7+
async function scheduleAgent(input: InputSchedule) {
8+
try {
9+
const agentId = `${Date.now()}-AgentChat`;
10+
const runId = await client.scheduleAgent({
11+
agentName: "agentChat",
12+
agentId,
13+
input,
14+
});
15+
16+
const result = await client.getAgentResult({ agentId, runId });
17+
18+
console.log("Agent result:", result);
19+
20+
process.exit(0); // Exit the process successfully
21+
} catch (error) {
22+
console.error("Error scheduling agent:", error);
23+
process.exit(1); // Exit the process with an error code
24+
}
25+
}
26+
27+
scheduleAgent({
28+
name: "test",
29+
});

agent_chat/scheduleWorkflow.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)