From d0cd219b7f34bf71aeb3b2b1a2d0719ffa467f98 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Thu, 13 Jun 2024 23:05:00 -0400 Subject: [PATCH] Update introduction.mdx --- docs/introduction.mdx | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/docs/introduction.mdx b/docs/introduction.mdx index aeebc9ad..18840001 100644 --- a/docs/introduction.mdx +++ b/docs/introduction.mdx @@ -20,44 +20,47 @@ ControlFlow provides a structured and intuitive way to create sophisticated agen from controlflow import flow, Task from pydantic import BaseModel +class Preferences(BaseModel): + location: str + cuisine: str class Restaurant(BaseModel): name: str description: str - @flow -def restaurant_recs(n:int) -> list[Restaurant]: +def restaurant_recommendations(n:int) -> list[Restaurant]: """ - An agentic workflow that asks the user for their location and - cuisine preference, then recommends n restaurants based on their input. + An agentic workflow that asks the user for preferences, + then recommends restaurants based on their input. """ - # get the user's location - location = Task("Get a location", user_access=True) - - # get the user's preferred cuisine - cuisine = Task("Get a preferred cuisine", user_access=True) + # get preferences from the user + preferences = Task( + "Get the user's preferences", + result_type=Preferences, + user_access=True, + ) - # generate the recommendations from the user's input - recs = Task( + # generate the recommendations + recommendations = Task( f"Recommend {n} restaurants to the user", - context=dict(location=location, cuisine=cuisine), + context=dict(preferences=preferences), result_type=list[Restaurant], ) - return recs + return recommendations recs = restaurant_recs(n=3) +print(recs) ``` ```python Result -# >> Agent: Hi! Could you please tell me your current location? Also, -# what type of cuisine are you in the mood for? +# >> Agent: Hi there! To help find the best restaurant +# for you, could you please tell me your location and +# the type of cuisine you're interested in? # >> User: I'm in DC looking for a cafe -# ------------------------------------------------- - [ Restaurant( name="Compass Coffee",