Schmitz005 commited on
Commit
c35baac
·
verified ·
1 Parent(s): ee8f311

Create huggingparser.py

Browse files
Files changed (1) hide show
  1. whalecore/huggingparser.py +36 -0
whalecore/huggingparser.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()