Skip to content
Open
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
40 changes: 20 additions & 20 deletions flight-booking-app/workflows/chat/index.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import {
convertToModelMessages,
type UIMessage,
type UIMessageChunk,
} from "ai";
import { getWritable } from "workflow";
import { DurableAgent } from "@workflow/ai/agent";
import { FLIGHT_ASSISTANT_PROMPT, flightBookingTools } from "./steps/tools";
convertToModelMessages,
type UIMessage,
type UIMessageChunk,
} from 'ai';
import { getWritable } from 'workflow';
import { DurableAgent } from '@workflow/ai';
import { FLIGHT_ASSISTANT_PROMPT, flightBookingTools } from './steps/tools';

/**
* The main chat workflow
*/
export async function chat(messages: UIMessage[]) {
"use workflow";
'use workflow';

console.log("Starting workflow");
console.log('Starting workflow');

const writable = getWritable<UIMessageChunk>();
const writable = getWritable<UIMessageChunk>();

const agent = new DurableAgent({
model: "bedrock/claude-4-sonnet-20250514-v1",
system: FLIGHT_ASSISTANT_PROMPT,
tools: flightBookingTools,
});
const agent = new DurableAgent({
model: 'bedrock/claude-4-sonnet-20250514-v1',
system: FLIGHT_ASSISTANT_PROMPT,
tools: flightBookingTools,
});

await agent.stream({
messages: convertToModelMessages(messages),
writable,
});
await agent.stream({
messages: convertToModelMessages(messages),
writable,
});

console.log("Finished workflow");
console.log('Finished workflow');
}
2 changes: 1 addition & 1 deletion rag-agent/workflows/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type UIMessageChunk,
} from "ai";
import { getWritable } from "workflow";
import { DurableAgent } from "@workflow/ai/agent";
import { DurableAgent } from "@workflow/ai";
import { z } from "zod";
import { createResource } from "./createResource";
import { findRelevant } from "./findRelevant";
Expand Down