Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified agent_chat/chat_post.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified agent_chat/chat_put.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified agent_chat/chat_run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 11 additions & 11 deletions agent_chat/eventWorkflow.ts → agent_chat/eventAgent.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { client } from "./src/client";

export type EventInput = {
workflowId: string;
agentId: string;
runId: string;
};

async function eventWorkflow(input: EventInput) {
async function eventAgent(input: EventInput) {
try {
await client.sendWorkflowEvent({
await client.sendAgentEvent({
event: {
name: "message",
input: { content: "Tell me a joke" },
},
workflow: {
workflowId: input.workflowId,
agent: {
agentId: input.agentId,
runId: input.runId,
},
});

await client.sendWorkflowEvent({
await client.sendAgentEvent({
event: {
name: "end",
},
workflow: {
workflowId: input.workflowId,
agent: {
agentId: input.agentId,
runId: input.runId,
},
});

process.exit(0); // Exit the process successfully
} catch (error) {
console.error("Error sending event to workflow:", error);
console.error("Error sending event to agent:", error);
process.exit(1); // Exit the process with an error code
}
}

eventWorkflow({
workflowId: "your-workflow-id",
eventAgent({
agentId: "your-agent-id",
runId: "your-run-id",
});
6 changes: 3 additions & 3 deletions agent_chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"dev": "open-cli http://localhost:5233 && tsx watch --include src src/services.ts",
"build": "tsc --build",
"clean": "rm -rf node_modules",
"schedule-workflow": "tsx scheduleWorkflow.ts",
"event-workflow": "tsx eventWorkflow.ts"
"schedule-agent": "tsx scheduleAgent.ts",
"event-agent": "tsx eventAgent.ts"
},
"dependencies": {
"@restackio/ai": "^0.0.99",
"@restackio/ai": "^0.0.102",
"@temporalio/workflow": "1.11.3",
"openai": "^4.80.1"
},
Expand Down
Loading