HemanM commited on
Commit
f39d1fb
Β·
verified Β·
1 Parent(s): 3402f63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -32
app.py CHANGED
@@ -1,40 +1,36 @@
1
  import gradio as gr
2
- from transformers import AutoTokenizer
3
- from inference import load_model, predict
4
-
5
- # Load tokenizer and model
6
- tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
7
- model, device = load_model("evo_hellaswag.pt")
8
-
9
- # Interface logic
10
- def evo_decision(prompt, option1, option2):
11
- result = predict(model, tokenizer, prompt, option1, option2, device)
12
- choice = option1 if result["choice"] == 0 else option2
13
- score_0 = round(result["scores"][0] * 100, 2)
14
- score_1 = round(result["scores"][1] * 100, 2)
15
- return (
16
- f"βœ… Evo Suggests: **{choice}**\n\n"
17
- f"🧠 Confidence Scores:\n"
18
- f"- Option 1: {score_0}%\n"
19
- f"- Option 2: {score_1}%"
20
- )
21
-
22
- # UI
23
- with gr.Blocks() as demo:
24
- gr.Markdown("# 🧬 EvoTransformer – Reasoning API\nAsk Evo a question with 2 choices.")
25
 
 
 
 
 
 
 
 
 
 
 
 
26
  with gr.Row():
27
- prompt = gr.Textbox(label="🧠 Scenario or Question", placeholder="e.g. You spilled juice on the floor.")
 
28
  with gr.Row():
29
- option1 = gr.Textbox(label="Option 1", placeholder="Wipe it with a cloth.")
30
- option2 = gr.Textbox(label="Option 2", placeholder="Ignore and walk away.")
31
-
32
  with gr.Row():
33
- output = gr.Markdown()
34
-
35
  with gr.Row():
36
- btn = gr.Button("Ask Evo")
37
- btn.click(fn=evo_decision, inputs=[prompt, option1, option2], outputs=[output])
 
 
 
38
 
39
- # Launch app
40
  demo.launch()
 
1
  import gradio as gr
2
+ from inference import get_evo_response, get_gpt_response
3
+ from logger import log_feedback
4
+ from utils import extract_text_from_file
5
+
6
+ def advisor_interface(question, file, feedback_choice):
7
+ context = extract_text_from_file(file) if file else ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ evo_answer = get_evo_response(question, context)
10
+ gpt_answer = get_gpt_response(question, context)
11
+
12
+ if feedback_choice != "No feedback":
13
+ log_feedback(question, context, evo_answer, feedback_choice)
14
+
15
+ return evo_answer, gpt_answer
16
+
17
+ with gr.Blocks() as demo:
18
+ gr.Markdown("## 🧠 EvoRAG – Retrieval-Augmented Adaptive AI")
19
+
20
  with gr.Row():
21
+ question = gr.Textbox(label="πŸ“ Ask anything", placeholder="e.g. Should we diversify the portfolio?")
22
+
23
  with gr.Row():
24
+ file = gr.File(label="πŸ“‚ Upload memo (.pdf or .txt)", file_types=[".pdf", ".txt"], type="binary")
25
+
 
26
  with gr.Row():
27
+ feedback = gr.Radio(["πŸ‘ Helpful", "πŸ‘Ž Not Helpful", "No feedback"], label="Was Evo’s answer useful?", value="No feedback")
28
+
29
  with gr.Row():
30
+ evo_out = gr.Textbox(label="πŸ”¬ EvoRAG Suggestion")
31
+ gpt_out = gr.Textbox(label="πŸ€– GPT-3.5 Suggestion")
32
+
33
+ submit_btn = gr.Button("Run Advisors")
34
+ submit_btn.click(fn=advisor_interface, inputs=[question, file, feedback], outputs=[evo_out, gpt_out])
35
 
 
36
  demo.launch()