Skip to content

Commit 5b48ebd

Browse files
Merge pull request #90 from restackio/simplifyChat
Simplify agent chat
2 parents c5ae664 + b6e8d74 commit 5b48ebd

File tree

5 files changed

+10
-22
lines changed

5 files changed

+10
-22
lines changed

agent_chat/chat_put.png

8.46 KB
Loading

agent_chat/eventWorkflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async function eventWorkflow(input: EventInput) {
1010
await client.sendWorkflowEvent({
1111
event: {
1212
name: "message",
13-
input: { content: "Telle ma another one" },
13+
input: { content: "Tell me a joke" },
1414
},
1515
workflow: {
1616
workflowId: input.workflowId,

agent_chat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"event-workflow": "tsx eventWorkflow.ts"
1111
},
1212
"dependencies": {
13-
"@restackio/ai": "^0.0.97",
13+
"@restackio/ai": "^0.0.99",
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/src/workflows/workflow.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,14 @@ export type EndEvent = {
66
end: boolean;
77
};
88

9-
export const messageEvent = defineEvent<functions.Message>("message");
10-
9+
export const messageEvent = defineEvent<functions.Message[]>("message");
1110
export const endEvent = defineEvent("end");
1211

13-
type AgentChatInput = {
14-
message: string;
15-
};
16-
1712
type AgentChatOutput = {
1813
messages: functions.Message[];
1914
};
2015

21-
export async function agentChat({
22-
message = "Hello, can you tell me a joke?",
23-
}: AgentChatInput): Promise<AgentChatOutput> {
16+
export async function agentChat(): Promise<AgentChatOutput> {
2417
let endReceived = false;
2518
let messages: functions.Message[] = [];
2619

@@ -30,18 +23,13 @@ export async function agentChat({
3023
messages,
3124
});
3225
messages.push(result);
33-
return result;
26+
return messages;
3427
});
3528

3629
onEvent(endEvent, async () => {
3730
endReceived = true;
3831
});
3932

40-
const result = await step<typeof functions>({}).llmChat({
41-
messages: [{ role: "user", content: message }],
42-
});
43-
messages.push(result);
44-
4533
// We use the `condition` function to wait for the event goodbyeReceived to return `True`.
4634
await condition(() => endReceived);
4735

0 commit comments

Comments
 (0)