Skip to content

Commit

Permalink
bug fix on replanning
Browse files Browse the repository at this point in the history
  • Loading branch information
tim connors committed May 30, 2023
1 parent 34bdfb3 commit 60c4e14
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 68 deletions.
80 changes: 30 additions & 50 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,83 +1,63 @@
{
"world_name": "Jest Jockeys",
"world_name": "Paper Trail Inc.",
"locations": [
{
"name": "Lobby",
"description": "The entrance to the company's office. Features a reception desk, a sign-in sheet for visitors, and brochures about the company."
"name": "Executive Office",
"description": "Marty's prestigious workspace. A room with a solid oak desk, a glass bookcase filled with business books Marty has never read, and a commanding view of the paper mill outside. Not to forget, the only room in the office with a ceiling fan."
},
{
"name": "Water Cooler",
"description": "A place where employees gather to chat and exchange gossip. Features a bulletin board for posting company announcements."
},
{
"name": "Conference Room",
"description": "A room for holding meetings and presentations. Features video conference equipment, a whiteboard, and a projector."
"name": "Corridor",
"description": "A seemingly never-ending stretch of office space flanked by cubicles and a few office plants, which were Rebecca's idea. Has a vintage water cooler and a few office paintings that desperately need an update."
},
{
"name": "Break Room",
"description": "A place for employees to take a break and grab a snack. Features a fridge, a microwave, a coffee maker, and a snack vending machine."
},
{
"name": "Copy Room",
"description": "A room for making copies and other document-related tasks. Features a copy machine, a scanner, a fax machine, and a paper shredder."
},
{
"name": "Executive Suite",
"description": "An exclusive area for the company's executives. Features a PA system, a personal secretary, a mini-fridge, and executive lounge chairs."
},
{
"name": "Work Zone",
"description": "An open area for employees to work. Features cubicles, desks, and a printer."
},
{
"name": "Park",
"description": "A place for people to relax and enjoy nature. Features a picnic table, a water fountain, a walking path, and a small outdoor amphitheater."
"description": "The social hub of the office, equipped with a fridge stocked with communal condiments, a microwave that's seen better days, and a mismatched assortment of mugs. The snack vending machine, known for stealing quarters, sits in the corner."
}
],
"agents": [
{
"first_name": "Marty",
"private_bio": "Marty is an energetic, light-hearted, and naive improviser. At 52 years old, he is the heart of the improv troupe, bringing an infectious enthusiasm that keeps spirits high. He's always ready with a joke or a funny story and can turn any situation into an entertaining scene. He loves to entertain and thrives on audience laughter. In his downtime, he walks his dog, Fido, and regales his wife Susan and their kids, David and Sarah, with hilarious antics.",
"public_bio": "Marty, the ringmaster of our improv troupe, keeps the team together with his infectious energy and endless humor. He doesn't have the sharpest wit or the quickest comeback, but his old-school charm and light-heartedness keep the audience in stitches. He is always ready to make a fool of himself for a laugh.",
"private_bio": "Marty, 52, is the hapless CEO of Paper Trail Inc., a company that sells all sorts of paper products. He prides himself on being a business savant, but his success is mostly due to his dedicated team working tirelessly behind the scenes. He frequently confuses idioms and mangles common sayings to the amusement of his employees. Despite his managerial shortcomings, his heart is in the right place and he cares about his employees.",
"public_bio": "As the CEO of Paper Trail Inc., Marty is the guiding force behind our successful business. Despite his unconventional leadership style, he manages to keep our company thriving and our clients satisfied.",
"directives": [
"Keep the energy high during performances.",
"Ensure everyone in the troupe is having fun",
"Engage the audience with humor and charm."
"Maintain the image of a successful CEO.",
"Unknowingly entertain your employees with your misinterpretations.",
"Remain oblivious to Rebecca's distractions."
],
"initial_plan": {
"description": "Participate in an improv performance at the park.",
"stop_condition": "The performance has ended.",
"location": "Park"
"description": "Head back to the executive office to sulk and wallow in self-pity about his forgotten birthday.",
"stop_condition": "Marty enters his office.",
"location": "Corridor"
}
},
{
"first_name": "Rebecca",
"private_bio": "Rebecca is a sharp, fast-thinking improviser who is always ready with a quick comeback. As the troupe's 'straight man,' she balances out Marty's silliness with her dry wit and clever banter. Rebecca is always seeking the perfect punchline and loves to keep the audience on their toes. Offstage, she enjoys strategizing the troupe's next steps with her husband Jacob.",
"public_bio": "Rebecca, the sharp-witted member of our troupe, is known for her quick comebacks and clever banter. She balances out the troupe's humor with her dry wit and keeps the performance dynamic. She is always looking for the perfect punchline and knows how to keep the audience guessing.",
"private_bio": "Rebecca, a smart and savvy sales manager, is the real brains behind Paper Trail Inc. She's known for her quick thinking and ability to handle Marty's eccentricities. She's particularly adept at employing diversion tactics, frequently having to shield Marty from office realities that he isn't equipped to handle.",
"public_bio": "Rebecca, our dedicated sales manager, is instrumental in navigating Paper Trail Inc. through the complex world of paper commerce. Her agility and quick thinking have been crucial to our success.",
"directives": [
"Come up with quick and witty responses during performances.",
"Ensure Marty is grounded",
"Keep the performance dynamic and engaging."
"Keep Marty from entering his office until Ricardo finishes decorating.",
"Be creative with your distractions while keeping Marty oblivious.",
"Keep the office atmosphere light and fun."
],
"initial_plan": {
"description": "Participate in an improv performance at the park.",
"stop_condition": "The performance has ended.",
"location": "Park"
"description": "Distract Marty in the corridor with a mix of office chatter, impromptu sales strategies meeting, and spontaneous paper airplane contests.",
"stop_condition": "Ricardo signals that he has finished decorating Marty's office.",
"location": "Corridor"
}
},
{
"first_name": "Ricardo",
"private_bio": "Ricardo is a compassionate improviser known for his endearing characters and heartfelt scenes. At 42 years old, his calming presence and warm demeanor make him a beloved member of the troupe. Offstage, he enjoys gardening and volunteering at a local animal shelter with his partner Alex and their daughter, Emma.",
"public_bio": "Ricardo, the heart of our troupe, brings an emotional depth to our performances with his heartfelt scenes and endearing characters. His calming presence and warm demeanor are a welcome contrast to the high-energy comedy, and his characters always leave a lasting impression on the audience.",
"private_bio": "Ricardo is the office's kind-hearted and somewhat timid HR manager. He is always ready to lend an ear to his co-workers and is the unofficial office party organizer. He has a knack for interior design, and his office is the most welcoming space in the building.",
"public_bio": "Ricardo, our affable HR manager, is a crucial member of Paper Trail Inc., known for his excellent people skills and ability to create a welcoming work environment.",
"directives": [
"Bring emotional depth to the performances.",
"Ensure the performances have a good balance of comedy and heartfelt scenes.",
"Create memorable characters that resonate with the audience."
"Decorate Marty's office without getting caught.",
"Ensure that the birthday surprise will uplift Marty's spirits.",
"Maintain a positive and friendly demeanor."
],
"initial_plan": {
"description": "Participate in an improv performance at the park.",
"stop_condition": "The performance has ended.",
"location": "Park"
"description": "Sneak into Marty's executive office to set up surprise decorations for his birthday, while avoiding detection.",
"stop_condition": "Marty's office is fully decorated and ready for the surprise.",
"location": "Executive Office"
}
}
]
Expand Down
4 changes: 3 additions & 1 deletion src/agent/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,9 @@ async def run_for_one_step(self):

# If the reaction calls to postpone the current plan, insert the new plan at the top
elif self.react_response.reaction == Reaction.POSTPONE:
self.plans.insert(0, self.react_response.new_plan)
# create a new plan from the LLMSinglePlan
new_plan = await SinglePlan.from_llm_single_plan(self.id, self.react_response.new_plan)
self.plans.insert(0, new_plan)

# Work through the plans
await self._do_first_plan()
Expand Down
47 changes: 30 additions & 17 deletions src/agent/plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ class PlanStatus(Enum):
DONE = "done"
FAILED = "failed"

class LLMSinglePlan(BaseModel):
index: int = Field(description="The plan number")
description: str = Field(description="A description of the plan")
start_time: datetime = Field(description="The starting time, in UTC, of the plan")
stop_condition: str = Field(
description="The condition that will cause this plan to be completed"
)
max_duration_hrs: float = Field(
description="The maximum amount of time to spend on this activity before reassessing"
)
location_name: str = Field(
description="The name of the location. Must match the location name exactly."
)


class LLMPlanResponse(BaseModel):
plans: list[LLMSinglePlan] = Field(description="A numbered list of plans")


class SinglePlan(BaseModel):
id: UUID
Expand Down Expand Up @@ -90,6 +108,18 @@ async def from_id(cls, id: UUID):

return cls(**plan_data)

@classmethod
async def from_llm_single_plan(cls, agent_id: UUID, llm_plan: LLMSinglePlan):
location = await Location.from_name(llm_plan.location_name)

return cls(
description = llm_plan.description,
max_duration_hrs = llm_plan.max_duration_hrs,
stop_condition = llm_plan.stop_condition,
agent_id = agent_id,
location = location
)

async def delete(self):
return await (await get_database()).get_by_id(Tables.Plan, str(self.id))

Expand Down Expand Up @@ -118,20 +148,3 @@ def make_plan_prompt(self):
return f"\nDo this: {self.description}\nAt this location: {self.location.name}\nStop when this happens: {self.stop_condition}\nIf do not finish within {self.max_duration_hrs} hours, stop."


class LLMSinglePlan(BaseModel):
index: int = Field(description="The plan number")
description: str = Field(description="A description of the plan")
start_time: datetime = Field(description="The starting time, in UTC, of the plan")
stop_condition: str = Field(
description="The condition that will cause this plan to be completed"
)
max_duration_hrs: float = Field(
description="The maximum amount of time to spend on this activity before reassessing"
)
location_id: Optional[UUID] = Field(
description="Optional. The id of the location if known. If included, it must be a valid UUID from the available locations."
)


class LLMPlanResponse(BaseModel):
plans: list[LLMSinglePlan] = Field(description="A numbered list of plans")
25 changes: 25 additions & 0 deletions src/location/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,30 @@ async def from_id(cls, id: UUID):
world_id=location["world_id"],
)

@classmethod
async def from_name(cls, name: str):
data = await (await get_database()).get_by_field(Tables.Locations, "name", name)

if len(data) == 0:
raise ValueError(f"Location with name {name} not found")

location = data[0]

available_tools = list(
map(lambda name: ToolName(name), location.get("available_tools"))
)

return cls(
id=location["id"],
name=location["name"],
description=location["description"],
available_tools=available_tools,
channel_id=location["channel_id"],
allowed_agent_ids=list(
map(lambda id: UUID(id), location.get("allowed_agent_ids"))
),
world_id=location["world_id"],
)

def context_string(self):
return f"- {self.name}: {self.description}\n"

0 comments on commit 60c4e14

Please sign in to comment.