Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,40 +1,36 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
from
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
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 |
-
|
|
|
28 |
with gr.Row():
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
with gr.Row():
|
33 |
-
|
34 |
-
|
35 |
with gr.Row():
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
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()
|