This is a nested chat re-implementation of OptiGuide which is an LLM-based supply chain optimization framework.
OptiGuide
: Inherits from autogen.AssistantAgent
and serves
as the main class for handling the supply chain optimization logic.
It maintains state information like the source code, debugging
attempts left, success status, and user chat history. Key methods
include set_success
and update_debug_times
, which are used to
update the agent’s state based on the outcomes of interactions.
Writer
: Also inherits from autogen.AssistantAgent
, this
class is tailored to manage the generation and explanation of Python
code solutions. It keeps track of the source code and example Q&A to
assist in generating responses to user queries.
writer
, safeguard
, and optiguide_commander
:
Instances of the classes defined above, each configured with
specific roles in the code generation and evaluation process. These
agents work together to ensure that the user’s questions are
answered with safe, optimized, and understandable Python code
solutions.
user
: An instance of autogen.UserProxyAgent
, representing
the end-user interacting with the notebook. It’s configured to
simulate user inputs and responses, facilitating an interactive and
engaging learning experience.
writer
and safeguard
nested into the commander
agent as the
inner monologue.
This next cell defines critical functions that manage the interactions
between the OptiGuide
system, the user, and the internal logic for
processing and responding to queries. Each function plays a specific
role in guiding the conversation, handling code generation requests,
ensuring code safety, and summarizing outcomes. This ensures that agents
receive clear instructions, immediate feedback, and a secure environment
for exploring supply chain optimization problems through code.
Information about the sequence of chats can be specified in the
chat_queue
argument of the register_nested_chats
function. The
following fields are especially useful: - recipient
(required)
specifies the nested agent; - message
specifies what message to send
to the nested recipient agent. In a sequence of nested chats, if the
message
field is not specified, we will use the last message the
registering agent received as the initial message in the first chat and
will skip any subsequent chat in the queue that does not have the
message
field. You can either provide a string or define a callable
that returns a string. - summary_method
decides what to get out of the
nested chat. You can either select from existing options including
“last_msg” and “reflection_with_llm”, or or define your own way on what
to get from the nested chat with a Callable. - max_turns
determines
how many turns of conversation to have between the concerned agent
pairs.