You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from tenacity import retry, stop_after_attempt, wait_exponential
class Planner:
def __init__(self,
llm: ChatOpenAI) -> None:
self.llm = llm
self.prompt_template = """Given the following complex task, break it down into a list of smaller, modular, and actionable subtasks (each task should be approximately accomplished in 20 steps). Each subtask should be concise and self-contained, suitable for direct execution without further decomposition. Present the subtasks as bullet points, without nesting or embedding.
**Task:** {task}
**Output:**
- [First finer-grained subtask]
- [Second finer-grained subtask]
- [Third finer-grained subtask]
- ...
(No additional contents are allowed.)
"""
@retry(
stop=stop_after_attempt(3),
wait=wait_exponential(min=1, max=10)
)
def call_llm(self, messages):
return self.llm.invoke(messages).content
def plan(self, task:str):
messages = [
{"role":"system", "content": "You are a helpful assistant good at decomposing complex tasks into practical steps."},