Replies: 1 comment
-
I think as people plan to run crewai in production, one of the biggest hurdles in chat like interface is the response time. Its given that the output of crew will take a while, however, it will be good user experience if the user also sees the interim logs. I currently didnt find any good way of doing the same with crewai. The above sounds like a good suggestion, but I am open to here what others think as well ? My Need: I want to keep crewai behind the API and I have a UI which access this API via REST calls. I want send back logs as they occur to UI as SSE {"type":"logs": "text": "this is log 123"} @joaomdmoura Can you please help what needs to be done in such scenario ? Or can you help with how people generally approach this ? |
Beta Was this translation helpful? Give feedback.
-
Description
I want to utilise the debug log to see the chain's thinking process.
Is there a way to get the log of crew.kickoff()?
for example:
[2024-08-29 09:43:47][DEBUG]: == Working Agent: Interviewer Agent
[2024-08-29 09:43:47][INFO]: == Starting Task:
Steps to Reproduce
result = crew.kickoff(inputs=inputs)
Expected behavior
na
Screenshots/Code snippets
na
Operating System
Windows 10
Python Version
3.11
crewAI Version
0.51.1
crewAI Tools Version
0.8.3
Virtual Environment
Venv
Evidence
na
Possible Solution
import logging
import sys
from io import StringIO
Set up logging to a file
logging.basicConfig(filename='debug_output.log', level=logging.DEBUG, format='[%(asctime)s][%(levelname)s]: %(message)s')
Optionally, log to both file and console
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setLevel(logging.DEBUG)
console_handler.setFormatter(logging.Formatter('[%(asctime)s][%(levelname)s]: %(message)s'))
logging.getLogger().addHandler(console_handler)
Capture the output as a string (for storing in a variable)
log_stream = StringIO()
stream_handler = logging.StreamHandler(log_stream)
logging.getLogger().addHandler(stream_handler)
Run your crew.kickoff code
result = crew.kickoff(inputs=inputs)
Retrieve the logs as a string
log_output = log_stream.getvalue()
Optionally, print or process the log output
print(log_output)
Additional context
na
Beta Was this translation helpful? Give feedback.
All reactions