Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,36 @@
|
|
1 |
-
from
|
|
|
2 |
|
3 |
print("π Welcome to HuggingWhale.AI")
|
4 |
print("Drop your chaos here and we'll pretend to make sense of it...\n")
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
9 |
|
10 |
-
# Load
|
11 |
-
agent_cfgs = agents.load_agents("config.yaml")
|
12 |
|
13 |
-
#
|
14 |
-
responses = agents.run_agents_on_text(agent_cfgs, doc)
|
15 |
|
16 |
-
#
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from whale_core import parser, agents
|
2 |
+
import gradio as gr
|
3 |
|
4 |
print("π Welcome to HuggingWhale.AI")
|
5 |
print("Drop your chaos here and we'll pretend to make sense of it...\n")
|
6 |
|
7 |
+
def process_file(uploaded_file):
|
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 |
+
# Load agent configs
|
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 |
+
# Format response output
|
20 |
+
output = ""
|
21 |
+
for name, reply in responses.items():
|
22 |
+
output += f"\nπ€ {name} says:\n{reply}\n"
|
23 |
+
|
24 |
+
return output.strip()
|
25 |
+
|
26 |
+
except Exception as e:
|
27 |
+
return f"π₯ Oops! Something went wrong:\n{str(e)}"
|
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()
|