Closed drewskidang closed 3 months ago
don't forget we have https://chat.openai.com/g/g-qqTuUWsBY-crewai-assistant to help and also the discord community https://discord.com/invite/X4JWnZnxPb
it is possible , just store the output , then extract the part you want to append and use the json library to append the extracted part
@sc00rpi0n can you show me code example. Trying to save the output as a conversation
Trying to get the output of both agents as a collum
at the latest crewai update now the output have each agent name next to its output , assume the results is saved in "output" variable then here's an example code
# Extract agent answers and create a JSON conversation
conversation = []
# Split the output into blocks based on the working agent
blocks = output.split('[DEBUG]: Working Agent: ')
for block in blocks[1:]:
agent_name, task_output = block.split('[DEBUG]: [', 1)
agent_name = agent_name.strip()
task_output = task_output.split('] Task output: ')[1].strip()
conversation.append({
"agent_name": agent_name,
"answer": task_output
})
# Create a JSON conversation
json_conversation = json.dumps(conversation, indent=2)
# Print the JSON conversation
print(json_conversation)
that's is just an example you can edit it to match your needs
@sc00rpi0n would outputs be the result if i did result = crew.kickoff()
yes , but make sure to change the name f the variable in the script as i used output = crew.kickoff()
can we append the model output into a json/jsonl??