Skip to content

Commit

Permalink
completed tree of thought
Browse files Browse the repository at this point in the history
  • Loading branch information
mahyar12 authored and mahyar12 committed Jan 6, 2024
1 parent 3012793 commit 905aa6f
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 205 deletions.
18 changes: 5 additions & 13 deletions CHA.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CHA(BaseModel):
orchestrator: Orchestrator = None
sync_browser: Any = None
planner_llm: str = LLMType.OPENAI
planner: str = PlannerType.ZERO_SHOT_REACT_PLANNER
planner: str = PlannerType.TREE_OF_THOUGHT
datapipe: str = DatapipeType.MEMORY
promptist: str = ""
response_generator_llm: str = LLMType.OPENAI
Expand All @@ -38,21 +38,13 @@ def _generate_history(
) -> str:
if chat_history is None:
chat_history = []
print("chat history", chat_history)

history = "".join(
[
f"\n------------\nUser: {chat[0]}\nCHA: {chat[1]}\n------------\n"
for chat in chat_history
]
)
if len(self.previous_actions) > 0:
history += "Previous Actions: " + "".join(
[
f"\n------------\naction: {action.task}\naction_response: {action.task_response}\n------------\n"
for action in self.previous_actions
if action.task != "Exception"
]
)
return history

def _run(
Expand Down Expand Up @@ -84,17 +76,17 @@ def _run(
response_generator_name=self.response_generator,
available_tasks=tasks_list,
sync_browser=self.sync_browser,
previous_actions=self.previous_actions,
verbose=self.verbose,
**kwargs,
)

response, actions = self.orchestrator.run(
response = self.orchestrator.run(
query=query,
history=history,
meta=self.meta,
history=history,
use_history=use_history,
)
self.previous_actions += actions

return response

Expand Down
Loading

0 comments on commit 905aa6f

Please sign in to comment.