Skip to content

Commit c5ae664

Browse files
Merge pull request #89 from restackio/agentChat
Add agent chat
2 parents 4e3331a + 29e797c commit c5ae664

File tree

19 files changed

+4974
-0
lines changed

19 files changed

+4974
-0
lines changed

agent_chat/.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
# For inference
3+
RESTACK_API_KEY=
4+
5+
# For Restack Cloud deployment
6+
RESTACK_ENGINE_ID=
7+
RESTACK_ENGINE_ADDRESS=
8+
RESTACK_ENGINE_API_KEY=
9+
RESTACK_ENGINE_API_ADDRESS=
10+

agent_chat/Dockerfile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Build stage
2+
FROM node:20-bullseye AS builder
3+
4+
WORKDIR /app
5+
6+
# Install pnpm
7+
RUN npm install -g pnpm
8+
9+
# Copy package files and env file if it exists
10+
COPY package*.json .env* ./
11+
12+
# Copy package files
13+
COPY package*.json ./
14+
15+
# Install dependencies including TypeScript
16+
RUN pnpm install
17+
RUN pnpm add -D typescript
18+
19+
# Copy source code
20+
COPY . .
21+
22+
# Build TypeScript code
23+
RUN pnpm run build
24+
25+
# Production stage
26+
FROM node:20-bullseye
27+
28+
WORKDIR /app
29+
30+
# Install pnpm
31+
RUN npm install -g pnpm
32+
33+
# Copy package files and built code
34+
COPY --from=builder /app/package*.json ./
35+
COPY --from=builder /app/dist ./dist
36+
37+
# Install production dependencies only
38+
RUN pnpm install --prod
39+
40+
# Define environment variables
41+
ARG RESTACK_ENGINE_ID
42+
ENV RESTACK_ENGINE_ID=${RESTACK_ENGINE_ID}
43+
44+
ARG RESTACK_ENGINE_ADDRESS
45+
ENV RESTACK_ENGINE_ADDRESS=${RESTACK_ENGINE_ADDRESS}
46+
47+
ARG RESTACK_ENGINE_API_KEY
48+
ENV RESTACK_ENGINE_API_KEY=${RESTACK_ENGINE_API_KEY}
49+
50+
ARG RESTACK_ENGINE_API_ADDRESS
51+
ENV RESTACK_ENGINE_API_ADDRESS=${RESTACK_ENGINE_API_ADDRESS}
52+
53+
EXPOSE 3000
54+
55+
CMD ["node", "dist/services.js"]

agent_chat/chat_post.png

37.2 KB
Loading

agent_chat/chat_put.png

51.8 KB
Loading

agent_chat/chat_run.png

88.3 KB
Loading

agent_chat/eventWorkflow.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { client } from "./src/client";
2+
3+
export type EventInput = {
4+
workflowId: string;
5+
runId: string;
6+
};
7+
8+
async function eventWorkflow(input: EventInput) {
9+
try {
10+
await client.sendWorkflowEvent({
11+
event: {
12+
name: "message",
13+
input: { content: "Telle ma another one" },
14+
},
15+
workflow: {
16+
workflowId: input.workflowId,
17+
runId: input.runId,
18+
},
19+
});
20+
21+
await client.sendWorkflowEvent({
22+
event: {
23+
name: "end",
24+
},
25+
workflow: {
26+
workflowId: input.workflowId,
27+
runId: input.runId,
28+
},
29+
});
30+
31+
process.exit(0); // Exit the process successfully
32+
} catch (error) {
33+
console.error("Error sending event to workflow:", error);
34+
process.exit(1); // Exit the process with an error code
35+
}
36+
}
37+
38+
eventWorkflow({
39+
workflowId: "your-workflow-id",
40+
runId: "your-run-id",
41+
});

0 commit comments

Comments
 (0)