Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -65,8 +65,17 @@ class ToolCallingAgentChat:
|
|
65 |
self.model = model
|
66 |
self.llm = None
|
67 |
self.tools = []
|
|
|
68 |
self._setup_agent()
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
def _setup_agent(self):
|
71 |
"""Initialize the tool calling agent"""
|
72 |
try:
|
@@ -306,6 +315,10 @@ def generate_response(message: str, history: List[List[str]], system_prompt: str
|
|
306 |
# Update agent configuration if changed
|
307 |
tool_calling_agent.update_config(ip, port, api_key, model)
|
308 |
|
|
|
|
|
|
|
|
|
309 |
# Generate response
|
310 |
response = tool_calling_agent.chat(message, history)
|
311 |
|
@@ -348,8 +361,8 @@ chatbot = gr.ChatInterface(
|
|
348 |
gr.Textbox(llm_model, label="Model Name",
|
349 |
info="Name of the model to use"),
|
350 |
],
|
351 |
-
title="
|
352 |
-
description="
|
353 |
theme="finlaymacklon/smooth_slate"
|
354 |
)
|
355 |
|
|
|
65 |
self.model = model
|
66 |
self.llm = None
|
67 |
self.tools = []
|
68 |
+
self.conversation_id = None
|
69 |
self._setup_agent()
|
70 |
|
71 |
+
def reset_conversation(self):
|
72 |
+
"""Reset conversation state"""
|
73 |
+
import uuid
|
74 |
+
self.conversation_id = str(uuid.uuid4())
|
75 |
+
if ENABLE_DETAILED_LOGGING:
|
76 |
+
logger.info(f"=== CONVERSATION RESET ===")
|
77 |
+
logger.info(f"New conversation ID: {self.conversation_id}")
|
78 |
+
|
79 |
def _setup_agent(self):
|
80 |
"""Initialize the tool calling agent"""
|
81 |
try:
|
|
|
315 |
# Update agent configuration if changed
|
316 |
tool_calling_agent.update_config(ip, port, api_key, model)
|
317 |
|
318 |
+
# Reset conversation if history is empty (indicates clear button was pressed)
|
319 |
+
if len(history) == 0:
|
320 |
+
tool_calling_agent.reset_conversation()
|
321 |
+
|
322 |
# Generate response
|
323 |
response = tool_calling_agent.chat(message, history)
|
324 |
|
|
|
361 |
gr.Textbox(llm_model, label="Model Name",
|
362 |
info="Name of the model to use"),
|
363 |
],
|
364 |
+
title="🤖 DQ Micro Agent",
|
365 |
+
description="DevQuasar self hosted Micro Agent with websearch capabilities",
|
366 |
theme="finlaymacklon/smooth_slate"
|
367 |
)
|
368 |
|