microsoft / autogen

A programming framework for agentic AI. Discord: https://aka.ms/autogen-dc. Roadmap: https://aka.ms/autogen-roadmap
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
27.96k stars 4.08k forks source link

[Bug]: Optiguide example does not run with current autogen version #3011

Open LouisCastricato opened 6 days ago

LouisCastricato commented 6 days ago

Describe the bug

I installed AutoGen from source and attempted to run the optiguide notebook. I have also tried installing autogen from source for the last version that the optiguide example was updated. Neither run.

Steps to reproduce

install AutoGen 0.2.2 from source and attempt to run the optiguide example notebook.

Model Used

Defaults for the notebook

Expected Behavior

I'm not sure as the notebook doesn't actually run.

Screenshots and logs


{
    "name": "AttributeError",
    "message": "'AssistantAgent' object has no attribute 'source_code'",
    "stack": "---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[8], line 1
----> 1 chat_res = user.initiate_chat(
      2     optiguide_commander, message=\"What if we prohibit shipping from supplier 1 to roastery 2?\"
      3 )
File ~/autogen/autogen/agentchat/conversable_agent.py:987, in ConversableAgent.initiate_chat(self, recipient, clear_history, silent, cache, max_turns, summary_method, summary_args, message, **kwargs)
    985     else:
    986         msg2send = self.generate_init_message(message, **kwargs)
--> 987     self.send(msg2send, recipient, silent=silent)
    988 summary = self._summarize_chat(
    989     summary_method,
    990     summary_args,
    991     recipient,
    992     cache=cache,
    993 )
    994 for agent in [self, recipient]:
File ~/autogen/autogen/agentchat/conversable_agent.py:628, in ConversableAgent.send(self, message, recipient, request_reply, silent)
    626 valid = self._append_oai_message(message, \"assistant\", recipient)
    627 if valid:
--> 628     recipient.receive(message, self, request_reply, silent)
    629 else:
    630     raise ValueError(
    631         \"Message can't be converted into a valid ChatCompletion message. Either content or function_call must be provided.\"
    632     )
File ~/autogen/autogen/agentchat/conversable_agent.py:788, in ConversableAgent.receive(self, message, sender, request_reply, silent)
    786 if request_reply is False or request_reply is None and self.reply_at_receive[sender] is False:
    787     return
--> 788 reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender)
    789 if reply is not None:
    790     self.send(reply, sender, silent=silent)
File ~/autogen/autogen/agentchat/conversable_agent.py:1909, in ConversableAgent.generate_reply(self, messages, sender, **kwargs)
   1907     continue
   1908 if self._match_trigger(reply_func_tuple[\"trigger\"], sender):
-> 1909     final, reply = reply_func(self, messages=messages, sender=sender, config=reply_func_tuple[\"config\"])
   1910     if final:
   1911         return reply
File ~/autogen/autogen/agentchat/conversable_agent.py:385, in ConversableAgent._summary_from_nested_chats(chat_queue, recipient, messages, sender, config)
    383 if not chat_to_run:
    384     return True, None
--> 385 res = initiate_chats(chat_to_run)
    386 return True, res[-1].summary
File ~/autogen/autogen/agentchat/chat.py:188, in initiate_chats(chat_queue)
    186     __post_carryover_processing(chat_info)
    187     sender = chat_info[\"sender\"]
--> 188     chat_res = sender.initiate_chat(**chat_info)
    189     finished_chats.append(chat_res)
    190 return finished_chats
File ~/autogen/autogen/agentchat/conversable_agent.py:987, in ConversableAgent.initiate_chat(self, recipient, clear_history, silent, cache, max_turns, summary_method, summary_args, message, **kwargs)
    985     else:
    986         msg2send = self.generate_init_message(message, **kwargs)
--> 987     self.send(msg2send, recipient, silent=silent)
    988 summary = self._summarize_chat(
    989     summary_method,
    990     summary_args,
    991     recipient,
    992     cache=cache,
    993 )
    994 for agent in [self, recipient]:
File ~/autogen/autogen/agentchat/conversable_agent.py:628, in ConversableAgent.send(self, message, recipient, request_reply, silent)
    626 valid = self._append_oai_message(message, \"assistant\", recipient)
    627 if valid:
--> 628     recipient.receive(message, self, request_reply, silent)
    629 else:
    630     raise ValueError(
    631         \"Message can't be converted into a valid ChatCompletion message. Either content or function_call must be provided.\"
    632     )
File ~/autogen/autogen/agentchat/conversable_agent.py:790, in ConversableAgent.receive(self, message, sender, request_reply, silent)
    788 reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender)
    789 if reply is not None:
--> 790     self.send(reply, sender, silent=silent)
File ~/autogen/autogen/agentchat/conversable_agent.py:628, in ConversableAgent.send(self, message, recipient, request_reply, silent)
    626 valid = self._append_oai_message(message, \"assistant\", recipient)
    627 if valid:
--> 628     recipient.receive(message, self, request_reply, silent)
    629 else:
    630     raise ValueError(
    631         \"Message can't be converted into a valid ChatCompletion message. Either content or function_call must be provided.\"
    632     )
File ~/autogen/autogen/agentchat/conversable_agent.py:788, in ConversableAgent.receive(self, message, sender, request_reply, silent)
    786 if request_reply is False or request_reply is None and self.reply_at_receive[sender] is False:
    787     return
--> 788 reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender)
    789 if reply is not None:
    790     self.send(reply, sender, silent=silent)
File ~/autogen/autogen/agentchat/conversable_agent.py:1909, in ConversableAgent.generate_reply(self, messages, sender, **kwargs)
   1907     continue
   1908 if self._match_trigger(reply_func_tuple[\"trigger\"], sender):
-> 1909     final, reply = reply_func(self, messages=messages, sender=sender, config=reply_func_tuple[\"config\"])
   1910     if final:
   1911         return reply
File ~/autogen/autogen/agentchat/conversable_agent.py:385, in ConversableAgent._summary_from_nested_chats(chat_queue, recipient, messages, sender, config)
    383 if not chat_to_run:
    384     return True, None
--> 385 res = initiate_chats(chat_to_run)
    386 return True, res[-1].summary
File ~/autogen/autogen/agentchat/chat.py:188, in initiate_chats(chat_queue)
    186     __post_carryover_processing(chat_info)
    187     sender = chat_info[\"sender\"]
--> 188     chat_res = sender.initiate_chat(**chat_info)
    189     finished_chats.append(chat_res)
    190 return finished_chats
File ~/autogen/autogen/agentchat/conversable_agent.py:988, in ConversableAgent.initiate_chat(self, recipient, clear_history, silent, cache, max_turns, summary_method, summary_args, message, **kwargs)
    986         msg2send = self.generate_init_message(message, **kwargs)
    987     self.send(msg2send, recipient, silent=silent)
--> 988 summary = self._summarize_chat(
    989     summary_method,
    990     summary_args,
    991     recipient,
    992     cache=cache,
    993 )
    994 for agent in [self, recipient]:
    995     agent.client_cache = agent.previous_cache
File ~/autogen/autogen/agentchat/conversable_agent.py:1109, in ConversableAgent._summarize_chat(self, summary_method, summary_args, recipient, cache)
   1106     summary_method = self._last_msg_as_summary
   1108 if isinstance(summary_method, Callable):
-> 1109     summary = summary_method(self, recipient, summary_args)
   1110 else:
   1111     raise ValueError(
   1112         \"If not None, the summary_method must be a string from [`reflection_with_llm`, `last_msg`] or a callable.\"
   1113     )
Cell In[7], line 55, in safeguard_summary(recipient, sender, *args)
     51 safe_msg = sender.last_message(recipient)[\"content\"].replace(\"TERMINATE\", \"\")
     53 if safe_msg.find(\"DANGER\") < 0:
     54     # Step 4 and 5: Run the code and obtain the results
---> 55     src_code = insert_code(sender.source_code, code)
     56     execution_rst = run_with_exec(src_code)
     57     print(colored(str(execution_rst), \"yellow\"))
AttributeError: 'AssistantAgent' object has no attribute 'source_code'"
}

Additional Information

No response