How to get the output of each agent, when i called kickoff method, so i can show in streamlit the reply of each agent.
I have been just dumping the final results of each task to a separate unique file and that has worked well.
Maybe you could just read those files back into Streamlit or whatever you are using and clean it up or parse out what you want to display.
From the user manual you can access the task output in various forms:
# Accessing the task output
task_output = task.output
print(f"Task Description: {task_output.description}")
print(f"Task Summary: {task_output.summary}")
print(f"Raw Output: {task_output.raw}")
if task_output.json_dict:
print(f"JSON Output: {json.dumps(task_output.json_dict, indent=2)}")
if task_output.pydantic:
print(f"Pydantic Output: {task_output.pydantic}")
There is also a thought of creating an Agent that just keeps track of what the other agents are doing and summarizes that in a single report. This would require some experimenting.
Hi joab, i understand this approach, meanwhile if the whole flow takes 1 minute to complete and dump in the file, at that time ui have to wait, i dont have to wait for that time, may be there is some other solution exist we have to wait for that, if some one else reply,
Agree there probably is a much easier method. For now, maybe you could pipe the verbose output that shows up in the command window in real-time to a file that you keep checking for updates (file size) and parse that info as it is available using a try/except file read in Streamlit to avoid I/O conflicts?
crewai run > verbose_output.txt
from streamlit check for file size change using something like watchdog, and then try/except a file copy statement to a temp file, then read that temp file into streamlit and parse it to show what you want sooner than waiting until the end.
HI @joab.io, My another query instead of using litellm interanl call if i have my own completion calls written how to utilize that, if i can utilize my completion call in the Agents, that will solve this issue?
Hey, guys. You can do something like that:
from crewai.agents.parser import AgentAction, AgentFinish
from crewai.agents.crew_agent_executor import ToolResult
def step_callback(step):
if isinstance(step, AgentAction):
logger.info(f"Action: {step.text}")
elif isinstance(step, AgentFinish):
logger.info(f"Finish: {step.text}")
elif isinstance(step, ToolResult):
logger.info(f"Tool Result: {step.result}")
crew = Crew(..., step_callback=step_callback)
Thanks, i will try the solution
Hey i treid he solution, eventhough it is same in terminal, logging is not working.