Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,36 +1,24 @@
|
|
|
|
|
| 1 |
from whale_core import parser, agents
|
| 2 |
-
import gradio as gr
|
| 3 |
|
| 4 |
-
|
| 5 |
-
print("Drop your chaos here and we'll pretend to make sense of it...\n")
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
try:
|
| 9 |
-
# Parse and embed the file
|
| 10 |
doc = parser.parse_file(uploaded_file.name)
|
| 11 |
chunks = parser.chunk_and_embed(doc)
|
| 12 |
|
| 13 |
-
|
| 14 |
-
agent_cfgs = agents.load_agents("agents/config.yaml")
|
| 15 |
-
|
| 16 |
-
# Run simulated agent conversations
|
| 17 |
responses = agents.run_agents_on_text(agent_cfgs, doc)
|
| 18 |
|
| 19 |
-
|
| 20 |
-
output = ""
|
| 21 |
for name, reply in responses.items():
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
return output.strip()
|
| 25 |
|
| 26 |
except Exception as e:
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
# Launch Gradio GUI
|
| 30 |
-
gr.Interface(
|
| 31 |
-
fn=process_file,
|
| 32 |
-
inputs=gr.File(label="π Upload your PDF or Text file"),
|
| 33 |
-
outputs=gr.Textbox(label="π§ Agent Responses", lines=20),
|
| 34 |
-
title="HuggingWhale.AI",
|
| 35 |
-
description="Drop a chaotic file. Let our agents attempt to decode the madness."
|
| 36 |
-
).launch()
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
from whale_core import parser, agents
|
|
|
|
| 3 |
|
| 4 |
+
st.set_page_config(page_title="HuggingWhale.AI", page_icon="π")
|
|
|
|
| 5 |
|
| 6 |
+
st.title("π HuggingWhale.AI")
|
| 7 |
+
st.write("Drop your chaos here and we'll pretend to make sense of it...")
|
| 8 |
+
|
| 9 |
+
uploaded_file = st.file_uploader("π Upload your PDF or Text file", type=["pdf", "txt"])
|
| 10 |
+
|
| 11 |
+
if uploaded_file:
|
| 12 |
try:
|
|
|
|
| 13 |
doc = parser.parse_file(uploaded_file.name)
|
| 14 |
chunks = parser.chunk_and_embed(doc)
|
| 15 |
|
| 16 |
+
agent_cfgs = agents.load_agents("config.yaml")
|
|
|
|
|
|
|
|
|
|
| 17 |
responses = agents.run_agents_on_text(agent_cfgs, doc)
|
| 18 |
|
| 19 |
+
st.subheader("π§ Agent Responses")
|
|
|
|
| 20 |
for name, reply in responses.items():
|
| 21 |
+
st.markdown(f"**π€ {name} says:**\n\n{reply}")
|
|
|
|
|
|
|
| 22 |
|
| 23 |
except Exception as e:
|
| 24 |
+
st.error(f"π₯ Oops! Something went wrong:\n{str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|