Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add live printhandler by default #70

Merged
merged 1 commit into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/controlflow/core/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,21 @@ async def _run_agent(self, agent: Agent, tasks: list[Task]):
system_message = SystemMessage(content=instructions)
messages = self.history.load_messages(thread_id=self.flow.thread_id)

# setup handler
if controlflow.settings.enable_tui:
handlers = [TUIHandler()]
elif controlflow.settings.enable_print_handler:
handlers = [PrintHandler()]
else:
handlers = []

# call llm
response_messages = []
async for msg in await completion_async(
messages=[system_message] + messages,
model=agent.model,
tools=tools,
handlers=[TUIHandler()]
if controlflow.settings.enable_tui
else [PrintHandler()],
handlers=handlers,
max_iterations=1,
stream=True,
message_preprocessor=add_agent_name_to_message,
Expand Down
14 changes: 9 additions & 5 deletions src/controlflow/core/controller/instruction_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,15 @@ class CommunicationTemplate(Template):

On each turn, you must use a tool or post a message. Do not post
messages unless you need to record information in addition to what you
provide as a task's result. This might include your thought process, if
appropriate. You may also post messages if you need to communicate with
other agents to complete a task. You may see other agents post messages;
they may have different instructions than you do, so do not follow their
example automatically.
provide as a task's result, or for the following reasons:

- You need to post a message or otherwise communicate to complete a task.
- You need to communicate with other agents to complete a task.
- You want to write your thought process for future reference.

Note that You may see other agents post messages; they may have
different instructions than you do, so do not follow their example
automatically.

When you use a tool, the tool call and tool result are automatically
posted as messages to the thread, so you never need to write out task
Expand Down
Loading
Loading