Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -844,8 +844,8 @@ def create_interface():
|
|
844 |
with gr.Column():
|
845 |
gr.HTML("""
|
846 |
<div class="header">
|
847 |
-
<h1
|
848 |
-
<p
|
849 |
</div>
|
850 |
""")
|
851 |
|
@@ -865,25 +865,25 @@ def create_interface():
|
|
865 |
processing_status = gr.HTML(visible=False)
|
866 |
|
867 |
process_btn = gr.Button(
|
868 |
-
"
|
869 |
variant="primary",
|
870 |
elem_classes=["primary-btn"]
|
871 |
)
|
872 |
|
873 |
gr.Markdown("""
|
874 |
-
###
|
875 |
|
876 |
**Multi-Agent System:**
|
877 |
-
-
|
878 |
-
-
|
879 |
-
-
|
880 |
-
-
|
881 |
|
882 |
**β¨ Features:**
|
883 |
-
-
|
884 |
-
-
|
885 |
-
-
|
886 |
-
-
|
887 |
""", elem_classes=["markdown-content"])
|
888 |
|
889 |
# Right side - Chat interface
|
@@ -911,7 +911,7 @@ def create_interface():
|
|
911 |
autofocus=True
|
912 |
)
|
913 |
send_btn = gr.Button(
|
914 |
-
"
|
915 |
scale=1,
|
916 |
elem_classes=["send-btn"],
|
917 |
size="sm"
|
@@ -920,16 +920,16 @@ def create_interface():
|
|
920 |
# Enhanced Examples
|
921 |
gr.Examples(
|
922 |
examples=[
|
923 |
-
"
|
924 |
-
"
|
925 |
-
"
|
926 |
-
"
|
927 |
-
"
|
928 |
-
"
|
929 |
],
|
930 |
inputs=msg_input,
|
931 |
-
label="
|
932 |
-
elem_classes=["examples"]
|
933 |
)
|
934 |
|
935 |
# State to track document processing
|
@@ -943,7 +943,7 @@ def create_interface():
|
|
943 |
# Show processing indicator
|
944 |
processing_html = f"""
|
945 |
<div class="processing-indicator">
|
946 |
-
|
947 |
</div>
|
948 |
"""
|
949 |
|
@@ -960,7 +960,7 @@ def create_interface():
|
|
960 |
border: 2px solid rgba(76, 175, 80, 0.3); border-radius: 12px; padding: 1rem 1.5rem;
|
961 |
color: #4caf50; text-align: center; backdrop-filter: blur(10px);
|
962 |
box-shadow: 0 0 20px rgba(76, 175, 80, 0.1);">
|
963 |
-
|
964 |
</div>
|
965 |
"""
|
966 |
return gr.update(value=success_html, visible=True), True
|
@@ -971,7 +971,7 @@ def create_interface():
|
|
971 |
border: 2px solid rgba(244, 67, 54, 0.3); border-radius: 12px; padding: 1rem 1.5rem;
|
972 |
color: #f44336; text-align: center; backdrop-filter: blur(10px);
|
973 |
box-shadow: 0 0 20px rgba(244, 67, 54, 0.1);">
|
974 |
-
|
975 |
</div>
|
976 |
"""
|
977 |
return gr.update(value=error_html, visible=True), False
|
@@ -980,7 +980,7 @@ def create_interface():
|
|
980 |
if not doc_ready:
|
981 |
# Show error message
|
982 |
history.append({"role": "user", "content": message})
|
983 |
-
history.append({"role": "assistant", "content": "
|
984 |
return history, ""
|
985 |
|
986 |
if not message.strip():
|
@@ -996,7 +996,7 @@ def create_interface():
|
|
996 |
history[-1]["content"] += token
|
997 |
yield history, ""
|
998 |
except Exception as e:
|
999 |
-
history[-1]["content"] = f"
|
1000 |
yield history, ""
|
1001 |
|
1002 |
# Event bindings
|
|
|
844 |
with gr.Column():
|
845 |
gr.HTML("""
|
846 |
<div class="header">
|
847 |
+
<h1> Agentic RAG Assistant</h1>
|
848 |
+
<p>Upload documents and ask questions - powered by Multi-Agent Architecture with streaming responses</p>
|
849 |
</div>
|
850 |
""")
|
851 |
|
|
|
865 |
processing_status = gr.HTML(visible=False)
|
866 |
|
867 |
process_btn = gr.Button(
|
868 |
+
" Process Documents",
|
869 |
variant="primary",
|
870 |
elem_classes=["primary-btn"]
|
871 |
)
|
872 |
|
873 |
gr.Markdown("""
|
874 |
+
### Architecture
|
875 |
|
876 |
**Multi-Agent System:**
|
877 |
+
- **IngestionAgent**: Document parsing
|
878 |
+
- **RetrievalAgent**: Semantic search
|
879 |
+
- **LLMAgent**: Response generation
|
880 |
+
- **CoordinatorAgent**: Workflow orchestration
|
881 |
|
882 |
**β¨ Features:**
|
883 |
+
- Streaming responses
|
884 |
+
- Multi-format support
|
885 |
+
- Context-aware answers
|
886 |
+
- Real-time processing
|
887 |
""", elem_classes=["markdown-content"])
|
888 |
|
889 |
# Right side - Chat interface
|
|
|
911 |
autofocus=True
|
912 |
)
|
913 |
send_btn = gr.Button(
|
914 |
+
" Send",
|
915 |
scale=1,
|
916 |
elem_classes=["send-btn"],
|
917 |
size="sm"
|
|
|
920 |
# Enhanced Examples
|
921 |
gr.Examples(
|
922 |
examples=[
|
923 |
+
" What are the main topics discussed?",
|
924 |
+
" Summarize the key findings",
|
925 |
+
" What metrics are mentioned?",
|
926 |
+
" What are the recommendations?",
|
927 |
+
" Find specific information about...",
|
928 |
+
" Create a summary of the content"
|
929 |
],
|
930 |
inputs=msg_input,
|
931 |
+
label=" Example Questions",
|
932 |
+
# elem_classes=["examples"]
|
933 |
)
|
934 |
|
935 |
# State to track document processing
|
|
|
943 |
# Show processing indicator
|
944 |
processing_html = f"""
|
945 |
<div class="processing-indicator">
|
946 |
+
Processing {len(files)} documents... Please wait while we analyze your content.
|
947 |
</div>
|
948 |
"""
|
949 |
|
|
|
960 |
border: 2px solid rgba(76, 175, 80, 0.3); border-radius: 12px; padding: 1rem 1.5rem;
|
961 |
color: #4caf50; text-align: center; backdrop-filter: blur(10px);
|
962 |
box-shadow: 0 0 20px rgba(76, 175, 80, 0.1);">
|
963 |
+
Documents processed successfully! You can now ask questions about your content.
|
964 |
</div>
|
965 |
"""
|
966 |
return gr.update(value=success_html, visible=True), True
|
|
|
971 |
border: 2px solid rgba(244, 67, 54, 0.3); border-radius: 12px; padding: 1rem 1.5rem;
|
972 |
color: #f44336; text-align: center; backdrop-filter: blur(10px);
|
973 |
box-shadow: 0 0 20px rgba(244, 67, 54, 0.1);">
|
974 |
+
Error processing documents: {str(e)}
|
975 |
</div>
|
976 |
"""
|
977 |
return gr.update(value=error_html, visible=True), False
|
|
|
980 |
if not doc_ready:
|
981 |
# Show error message
|
982 |
history.append({"role": "user", "content": message})
|
983 |
+
history.append({"role": "assistant", "content": " Please upload and process documents first before asking questions."})
|
984 |
return history, ""
|
985 |
|
986 |
if not message.strip():
|
|
|
996 |
history[-1]["content"] += token
|
997 |
yield history, ""
|
998 |
except Exception as e:
|
999 |
+
history[-1]["content"] = f" Error generating response: {str(e)}"
|
1000 |
yield history, ""
|
1001 |
|
1002 |
# Event bindings
|