Commit
Β·
bca0f3b
1
Parent(s):
cff141c
Enhance permissions in settings.local.json and improve session handling in app.py
Browse files- .claude/settings.local.json +3 -1
- chat/providers/gemini_provider.py +2 -2
- ui/app.py +13 -3
.claude/settings.local.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
{
|
| 2 |
"permissions": {
|
| 3 |
"allow": [
|
| 4 |
-
"WebSearch"
|
|
|
|
|
|
|
| 5 |
],
|
| 6 |
"deny": [],
|
| 7 |
"ask": []
|
|
|
|
| 1 |
{
|
| 2 |
"permissions": {
|
| 3 |
"allow": [
|
| 4 |
+
"WebSearch",
|
| 5 |
+
"Bash(python app.py:*)",
|
| 6 |
+
"WebFetch(domain:github.com)"
|
| 7 |
],
|
| 8 |
"deny": [],
|
| 9 |
"ask": []
|
chat/providers/gemini_provider.py
CHANGED
|
@@ -511,8 +511,8 @@ To use Gemini:
|
|
| 511 |
if not self.api_available:
|
| 512 |
return self._handle_no_api()
|
| 513 |
|
| 514 |
-
#
|
| 515 |
-
|
| 516 |
|
| 517 |
return """π Hello! I'm your AI dispatch assistant powered by **Google Gemini 2.0 Flash**.
|
| 518 |
|
|
|
|
| 511 |
if not self.api_available:
|
| 512 |
return self._handle_no_api()
|
| 513 |
|
| 514 |
+
# Don't initialize model yet - wait for first actual message
|
| 515 |
+
# This allows the welcome message to load instantly
|
| 516 |
|
| 517 |
return """π Hello! I'm your AI dispatch assistant powered by **Google Gemini 2.0 Flash**.
|
| 518 |
|
ui/app.py
CHANGED
|
@@ -462,12 +462,16 @@ def create_interface():
|
|
| 462 |
# Conversation state - use session ID instead of complex object
|
| 463 |
session_id_state = gr.State(value=None)
|
| 464 |
|
| 465 |
-
# Initialize with welcome message
|
| 466 |
-
chatbot.value, tool_display.value, session_id_state.value = get_initial_chat()
|
| 467 |
-
|
| 468 |
# Event handlers
|
| 469 |
def send_message(message, sess_id):
|
| 470 |
"""Handle send button click"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 471 |
chat_history, tools, new_sess_id = handle_chat_message(message, sess_id)
|
| 472 |
return chat_history, tools, new_sess_id, "" # Clear input
|
| 473 |
|
|
@@ -536,6 +540,12 @@ def create_interface():
|
|
| 536 |
gr.Markdown("---")
|
| 537 |
gr.Markdown("*FleetMind MCP v1.0.0 - Built with Gradio, PostgreSQL, and FastMCP*")
|
| 538 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 539 |
return app
|
| 540 |
|
| 541 |
|
|
|
|
| 462 |
# Conversation state - use session ID instead of complex object
|
| 463 |
session_id_state = gr.State(value=None)
|
| 464 |
|
|
|
|
|
|
|
|
|
|
| 465 |
# Event handlers
|
| 466 |
def send_message(message, sess_id):
|
| 467 |
"""Handle send button click"""
|
| 468 |
+
# Auto-initialize session if None
|
| 469 |
+
if sess_id is None:
|
| 470 |
+
sess_id = str(uuid.uuid4())
|
| 471 |
+
SESSIONS[sess_id] = ConversationManager()
|
| 472 |
+
welcome = chat_engine.get_welcome_message()
|
| 473 |
+
SESSIONS[sess_id].add_message("assistant", welcome)
|
| 474 |
+
|
| 475 |
chat_history, tools, new_sess_id = handle_chat_message(message, sess_id)
|
| 476 |
return chat_history, tools, new_sess_id, "" # Clear input
|
| 477 |
|
|
|
|
| 540 |
gr.Markdown("---")
|
| 541 |
gr.Markdown("*FleetMind MCP v1.0.0 - Built with Gradio, PostgreSQL, and FastMCP*")
|
| 542 |
|
| 543 |
+
# Initialize chat on app load (deferred to avoid blocking)
|
| 544 |
+
app.load(
|
| 545 |
+
fn=get_initial_chat,
|
| 546 |
+
outputs=[chatbot, tool_display, session_id_state]
|
| 547 |
+
)
|
| 548 |
+
|
| 549 |
return app
|
| 550 |
|
| 551 |
|