diff --git a/example/src/surprise_trip.ts b/example/src/surprise_trip.ts index cff82aa..b241267 100644 --- a/example/src/surprise_trip.ts +++ b/example/src/surprise_trip.ts @@ -57,7 +57,8 @@ const researchTripWorkflow = workflow({ - highly-rated restaurants and dining experiences. - landmarks with historic context. - picturesque and entertaining locations. - + `, + knowledge: ` Traveler's information: - Origin: New York, USA - Destination: Wrocław, Poland @@ -70,7 +71,6 @@ const researchTripWorkflow = workflow({ Comprehensive day-by-day itinerary for the trip to Wrocław, Poland. Ensure the itinerary integrates flights, hotel information, and all planned activities and dining experiences. `, - snapshot: logger, }) const result = await teamwork(researchTripWorkflow) diff --git a/packages/framework/src/agent.ts b/packages/framework/src/agent.ts index 7819a21..87274d0 100644 --- a/packages/framework/src/agent.ts +++ b/packages/framework/src/agent.ts @@ -28,7 +28,7 @@ export const agent = (options: AgentOptions = {}): Agent => { provider, run: options.run ?? - (async (state, context) => { + (async (state, context, workflow) => { const mappedTools = tools ? Object.entries(tools).map(([name, tool]) => zodFunction({ @@ -39,6 +39,8 @@ export const agent = (options: AgentOptions = {}): Agent => { ) : [] + const [, ...messages] = context + const response = await provider.completions({ messages: [ { @@ -62,7 +64,17 @@ export const agent = (options: AgentOptions = {}): Agent => { }, { role: 'user', - content: `Here is all the work done so far by other agents: ${JSON.stringify(context)}`, + content: `Here is all the work done so far by other agents: ${JSON.stringify(messages)}`, + }, + { + role: 'assistant', + content: 'Is there anything else I need to know?', + }, + { + role: 'user', + content: workflow.knowledge + ? `Here is all the knowledge available: ${workflow.knowledge}` + : 'No, I do not have any additional information.', }, { role: 'assistant', diff --git a/packages/framework/src/workflow.ts b/packages/framework/src/workflow.ts index 7864eb6..ca912db 100644 --- a/packages/framework/src/workflow.ts +++ b/packages/framework/src/workflow.ts @@ -11,6 +11,7 @@ type WorkflowOptions = { team: Team + knowledge?: string provider?: Provider maxIterations?: number snapshot?: Telemetry @@ -37,4 +38,6 @@ export const workflow = (options: WorkflowOptions): Workflow => { } } -export type Workflow = Required +export type Workflow = Required> & { + knowledge?: string +}