from autogen import UserProxyAgent, ConversableAgent, register_function # Define the configuration for the GPT-4 model. llm_config_gpt4 = { "model": "gpt-4", "temperature": 0.7, # "max_tokens": 2048, "api_key" : "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", } # The user proxy agent is used for interacting with the assistant agent # and executes tool calls. user_proxy = ConversableAgent( name="User", llm_config=False, is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"], human_input_mode="NEVER", ) assistant = ConversableAgent( name="Assistant", system_message="You are a helpful AI assistant. " "You can help with simple calculations. " "Return 'TERMINATE' when the task is done.", llm_config=llm_config_gpt4, ) def calculator(): print("helloo") # Register the calculator function to the two agents. register_function( calculator, caller=assistant, # The assistant agent can suggest calls to the calculator. executor=user_proxy, # The user proxy agent can execute the calculator calls. name="calculator", # By default, the function name is used as the tool name. description="A simple calculator", # A description of the tool. ) chat_result = user_proxy.initiate_chat(assistant, message="What is (44232 + 13312 / (232 - 32)) * 5?")