Spaces:
Sleeping
Sleeping
Commit Β·
b35cb9c
1
Parent(s): 6822668
fixing compatibility isuse
Browse files- README.md +3 -3
- app.py +15 -31
- requirements.txt +1 -1
README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
---
|
| 2 |
title: DocsNavigatorMCP
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 6.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
-
short_description:
|
| 12 |
---
|
| 13 |
|
| 14 |
# Docs Navigator MCP
|
|
|
|
| 1 |
---
|
| 2 |
title: DocsNavigatorMCP
|
| 3 |
+
emoji: π
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.6.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
+
short_description: AI-powered documentation assistant with Claude!
|
| 12 |
---
|
| 13 |
|
| 14 |
# Docs Navigator MCP
|
app.py
CHANGED
|
@@ -8,7 +8,7 @@ An elegant, AI-powered documentation assistant with advanced features.
|
|
| 8 |
import os
|
| 9 |
import gradio as gr
|
| 10 |
from pathlib import Path
|
| 11 |
-
from typing import List,
|
| 12 |
from anthropic import Anthropic
|
| 13 |
from dotenv import load_dotenv
|
| 14 |
from document_intelligence import DocumentIntelligence
|
|
@@ -81,7 +81,7 @@ def get_available_files() -> List[str]:
|
|
| 81 |
return sorted(files)
|
| 82 |
|
| 83 |
|
| 84 |
-
def chat_with_docs(message: str, history: List
|
| 85 |
"""Process user message and generate AI response."""
|
| 86 |
if not ANTHROPIC_API_KEY:
|
| 87 |
return "β οΈ Please set your ANTHROPIC_API_KEY in the .env file."
|
|
@@ -89,13 +89,14 @@ def chat_with_docs(message: str, history: List[dict], system_prompt: str = None)
|
|
| 89 |
# Load documentation context
|
| 90 |
docs_context = load_documentation()
|
| 91 |
|
| 92 |
-
# Build conversation history from
|
| 93 |
messages = []
|
| 94 |
-
for
|
| 95 |
-
if
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
| 99 |
|
| 100 |
messages.append({"role": "user", "content": message})
|
| 101 |
|
|
@@ -530,25 +531,12 @@ label, .label {
|
|
| 530 |
"""
|
| 531 |
|
| 532 |
# Create the Gradio interface with dark theme
|
| 533 |
-
|
| 534 |
-
theme=gr.themes.Base(
|
| 535 |
-
primary_hue="purple",
|
| 536 |
-
secondary_hue="indigo",
|
| 537 |
-
neutral_hue="slate",
|
| 538 |
-
font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"]
|
| 539 |
-
).set(
|
| 540 |
-
body_background_fill="#0d1117",
|
| 541 |
-
body_background_fill_dark="#0d1117",
|
| 542 |
-
block_background_fill="#161b22",
|
| 543 |
-
block_background_fill_dark="#161b22",
|
| 544 |
-
input_background_fill="#21262d",
|
| 545 |
-
input_background_fill_dark="#21262d",
|
| 546 |
-
button_primary_background_fill="linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%)",
|
| 547 |
-
button_primary_background_fill_dark="linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%)",
|
| 548 |
-
),
|
| 549 |
css=custom_css,
|
| 550 |
title="Docs Navigator MCP - AI Documentation Assistant",
|
| 551 |
-
)
|
|
|
|
|
|
|
| 552 |
|
| 553 |
# Header with modern dark gradient
|
| 554 |
gr.HTML("""
|
|
@@ -570,12 +558,9 @@ with gr.Blocks(
|
|
| 570 |
|
| 571 |
chatbot = gr.Chatbot(
|
| 572 |
height=550,
|
| 573 |
-
placeholder="<div style='text-align: center; padding: 3rem; color: #8b949e;'><div style='font-size: 3rem; margin-bottom: 1rem;'>π¬</div><div style='font-size: 1.2rem; font-weight: 600; color: #e6edf3; margin-bottom: 0.5rem;'>Start a Conversation</div><div>Ask me anything about your documentation!</div></div>",
|
| 574 |
show_label=False,
|
| 575 |
avatar_images=("π€", "π€"),
|
| 576 |
-
|
| 577 |
-
layout="bubble",
|
| 578 |
-
show_copy_button=True
|
| 579 |
)
|
| 580 |
|
| 581 |
with gr.Row():
|
|
@@ -724,8 +709,7 @@ with gr.Blocks(
|
|
| 724 |
return "", chat_history
|
| 725 |
|
| 726 |
response = chat_with_docs(message, chat_history, system_prompt if system_prompt.strip() else None)
|
| 727 |
-
chat_history.append(
|
| 728 |
-
chat_history.append({"role": "assistant", "content": response})
|
| 729 |
return "", chat_history
|
| 730 |
|
| 731 |
msg.submit(respond, [msg, chatbot, custom_system_prompt], [msg, chatbot])
|
|
|
|
| 8 |
import os
|
| 9 |
import gradio as gr
|
| 10 |
from pathlib import Path
|
| 11 |
+
from typing import List, Tuple, Optional
|
| 12 |
from anthropic import Anthropic
|
| 13 |
from dotenv import load_dotenv
|
| 14 |
from document_intelligence import DocumentIntelligence
|
|
|
|
| 81 |
return sorted(files)
|
| 82 |
|
| 83 |
|
| 84 |
+
def chat_with_docs(message: str, history: List, system_prompt: str = None) -> str:
|
| 85 |
"""Process user message and generate AI response."""
|
| 86 |
if not ANTHROPIC_API_KEY:
|
| 87 |
return "β οΈ Please set your ANTHROPIC_API_KEY in the .env file."
|
|
|
|
| 89 |
# Load documentation context
|
| 90 |
docs_context = load_documentation()
|
| 91 |
|
| 92 |
+
# Build conversation history from tuple format
|
| 93 |
messages = []
|
| 94 |
+
for chat_item in history:
|
| 95 |
+
if isinstance(chat_item, tuple) and len(chat_item) == 2:
|
| 96 |
+
user_msg, assistant_msg = chat_item
|
| 97 |
+
messages.append({"role": "user", "content": user_msg})
|
| 98 |
+
if assistant_msg:
|
| 99 |
+
messages.append({"role": "assistant", "content": assistant_msg})
|
| 100 |
|
| 101 |
messages.append({"role": "user", "content": message})
|
| 102 |
|
|
|
|
| 531 |
"""
|
| 532 |
|
| 533 |
# Create the Gradio interface with dark theme
|
| 534 |
+
demo = gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 535 |
css=custom_css,
|
| 536 |
title="Docs Navigator MCP - AI Documentation Assistant",
|
| 537 |
+
)
|
| 538 |
+
|
| 539 |
+
with demo:
|
| 540 |
|
| 541 |
# Header with modern dark gradient
|
| 542 |
gr.HTML("""
|
|
|
|
| 558 |
|
| 559 |
chatbot = gr.Chatbot(
|
| 560 |
height=550,
|
|
|
|
| 561 |
show_label=False,
|
| 562 |
avatar_images=("π€", "π€"),
|
| 563 |
+
bubble_full_width=False
|
|
|
|
|
|
|
| 564 |
)
|
| 565 |
|
| 566 |
with gr.Row():
|
|
|
|
| 709 |
return "", chat_history
|
| 710 |
|
| 711 |
response = chat_with_docs(message, chat_history, system_prompt if system_prompt.strip() else None)
|
| 712 |
+
chat_history.append((message, response))
|
|
|
|
| 713 |
return "", chat_history
|
| 714 |
|
| 715 |
msg.submit(respond, [msg, chatbot, custom_system_prompt], [msg, chatbot])
|
requirements.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
mcp[cli]>=0.1.0
|
| 2 |
anthropic>=0.36.0
|
| 3 |
python-dotenv>=1.0.1
|
| 4 |
-
gradio
|
| 5 |
PyPDF2>=3.0.0
|
|
|
|
| 1 |
mcp[cli]>=0.1.0
|
| 2 |
anthropic>=0.36.0
|
| 3 |
python-dotenv>=1.0.1
|
| 4 |
+
gradio==5.6.0
|
| 5 |
PyPDF2>=3.0.0
|