Open Adibahaq opened 3 months ago
@Adibahaq This issue is most likely the following error introduced by more strict JSON checking:
https://community.openai.com/t/error-the-model-produced-invalid-content/747511
I will create a pull request shortly and I would appreciate if you could test your example against it.
@Adibahaq please check if your code works with the fix in PR #3429
Also see this issue from .net end. Will push a fix in AutoGen.Net as well
Describe the issue
Hello, I am trying to use Autogen for this multiagent healthcare system. The code looks like this:
config_list = [ { "model": "gpt-3.5-turbo-16k", "api_key": "key", "api_type": "openai", }
]
llm_config = { "timeout": 600, "seed": 42, "config_list": config_list, "temperature": 0, "max_tokens": 400, }
Define the agents
PrimaryAG = autogen.AssistantAgent( name="Primary_Agent", llm_config=llm_config, system_message="""You are an assistant that processes patient reports. Extract the following general information from the given text:
Also, identify and extract the following sections:
CKDAG = autogen.AssistantAgent( name="CKD_Agent", llm_config=llm_config, system_message="Chronic kidney disease specialist agent", code_execution_config={"work_dir": "web", "use_docker": False} )
HFAG = autogen.AssistantAgent( name="HF_Agent", llm_config=llm_config, system_message="Heart failure specialist agent", code_execution_config={"work_dir": "web", "use_docker": False} )
LABAG = autogen.AssistantAgent( name="LAB_Agent", llm_config=llm_config, system_message=""" You are a medical lab specialist. In a conversation when the Primary agent identifies the Lab Results from a patient report, you analyze the informaion in that section (only that section), and provide a comprehensive and concise analysis of the patient's condition based on the lab results or tests""", code_execution_config={"work_dir": "web", "use_docker": False} )
MEDAG = autogen.AssistantAgent( name="Med_Agent", llm_config=llm_config, system_message=""" You are a drugs and medicine specialist with extensive pharmaceutical knowledge. In a conversation when the Primary agent identifies the Medications section from a patient report, you analyze the information in that section (only that section), and provide a comprehensive and concise analysis. Include the following in your analysis:
Critic = autogen.AssistantAgent( name="Critic_Agent", llm_config=llm_config, system_message="You are a critic, known for your thoroughness and commitment to standards. Your task is to scrutinize answers for correctness and any harmful elements, and provide short feedback", code_execution_config={"work_dir": "web", "use_docker": False} )
Initialize the UserProxyAgent
user_proxy = autogen.UserProxyAgent( name="user_proxy", code_execution_config={"work_dir": "web", "use_docker": False}, llm_config=llm_config, )
Function to reflect on messages
def reflection_message(messages, sender, config): return f"Reflect and provide critique on the following answers:\n\n" + "\n".join( f"Role: {msg['role']}\nContent: {msg['content']}" for msg in messages )
Function to handle user input
def handle_user_input(conversation_history, user_input): if user_input.lower() == "exit": print("Exiting the conversation.") return False
Main conversation loop
def main(): print("Start your conversation. Type 'exit' to end.") conversation_history = [] while True: user_input = input("User: ") if not handle_user_input(conversation_history, user_input): break
if name == "main": main()
Can anyone please tell me why I am getting this error message: An error occurred: Error code: 500 - {'error': {'message': 'The model produced invalid content. Consider modifying your prompt if you are seeing this error persistently.', 'type': 'model_error', 'param': None, 'code': None}}
I get an output first, which looks like this:
Primary_Agent (to user_proxy):
Patient Name: Not mentioned Age: 41 years old Sex: Male Admission Date: November 3, 2203 Discharge Date: November 12, 2203
Sections:
Next speaker: LAB_Agent
LAB_Agent (to chat_manager):
Based on the lab results provided in the patient report, here is a comprehensive analysis of the patient's condition:
Hematology:
Chemistry:
Cardiac Markers:
Coagulation:
Other findings:
Based on these results, the patient's primary diagnosis is cardiac tamponade, which is a medical emergency requiring immediate intervention. The pericardial effusion is likely the cause of the patient's symptoms of shortness of breath and chest pain. The underlying cause of the effusion needs further investigation, as no specific cause was identified in the report.
Other notable findings include anemia, possible gastrointestinal bleeding, impaired kidney function, and elevated glucose levels. These findings may require further evaluation and management.
The patient's medical history of HIV/AIDS, previous endocarditis, and tricuspid regurgitation are important factors to consider in the overall management and treatment plan.
Further monitoring of the patient's cardiac function, including regular echocardiograms, is recommended to assess for fluid reaccumulation and to evaluate the severity of tricuspid regurgitation.
Overall, the patient's condition is complex and requires a multidisciplinary approach involving cardiology, infectious disease, gastroenterology, and orthopedics to address the various medical issues identified in the report.
Next speaker: Med_Agent
and then I get the error message.
Steps to reproduce
No response
Screenshots and logs
No response
Additional Information
No response