multi-round chat
This commit is contained in:
parent
331e2e434d
commit
c20be407d5
@ -10,22 +10,17 @@ if __name__ == "__main__":
|
||||
# Create the supervisor
|
||||
supervisor = create_sysadmin_supervisor()
|
||||
|
||||
# Example run - demonstrating both invoke and streaming with debug output
|
||||
query = {
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Nginx returns 502 Bad Gateway on my server. What can I do?",
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
print("🚀 Starting multi-agent sysadmin analysis...")
|
||||
print(f"📝 User Query: {query['messages'][0]['content']}")
|
||||
print("=" * 80)
|
||||
|
||||
# Show explanation of the supervisor pattern
|
||||
explain_supervisor_pattern()
|
||||
# Interactive conversation loop
|
||||
messages = []
|
||||
print("Welcome to the multi-agent sysadmin assistant!")
|
||||
print("Type your sysadmin question below. Type 'exit' to quit.")
|
||||
while True:
|
||||
user_input = input("\n📝 User: ")
|
||||
if user_input.strip().lower() == 'exit':
|
||||
print("Goodbye!")
|
||||
break
|
||||
messages.append({"role": "user", "content": user_input})
|
||||
query = {"messages": messages}
|
||||
|
||||
print("\n=== Using invoke() method ===")
|
||||
result = supervisor.invoke(query)
|
||||
@ -34,9 +29,17 @@ if __name__ == "__main__":
|
||||
print("-" * 40)
|
||||
print(result["messages"][-1].content)
|
||||
print("-" * 40)
|
||||
|
||||
print(f"\n📈 Total messages exchanged: {len(result['messages'])}")
|
||||
|
||||
# Add the assistant's reply to the conversation history
|
||||
messages.append({"role": "assistant", "content": result["messages"][-1].content})
|
||||
|
||||
# Ask if the user wants to continue
|
||||
cont = input("\nWould you like to continue the conversation? (y/n): ")
|
||||
if cont.strip().lower() not in ('y', 'yes'):
|
||||
print("Session ended.")
|
||||
break
|
||||
|
||||
print("\n=== Using stream() method for detailed step-by-step analysis ===")
|
||||
step_count = 0
|
||||
max_steps = 20 # Prevent infinite loops
|
||||
|
Loading…
x
Reference in New Issue
Block a user