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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -11
app.py CHANGED
@@ -1,18 +1,36 @@
1
- from whalecore import parser, agents
 
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
- # Fake file parsing (replace with actual PDF path)
7
- doc = parser.parse_file("sample.pdf")
8
- chunks = parser.chunk_and_embed(doc)
 
 
9
 
10
- # Load your agents
11
- agent_cfgs = agents.load_agents("config.yaml")
12
 
13
- # Simulate agent convo
14
- responses = agents.run_agents_on_text(agent_cfgs, doc)
15
 
16
- # Output agent responses
17
- for name, reply in responses.items():
18
- print(f"\nπŸ€– {name} says:\n{reply}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()