Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ from config import file_id_htl_biotech, file_id_kamera_express, file_id_smart_sd
|
|
5 |
import gdown
|
6 |
import pandas as pd
|
7 |
from hogwarts import get_answer
|
|
|
8 |
from evaluator import eval_answer
|
9 |
import nltk
|
10 |
nltk.download('punkt')
|
@@ -119,6 +120,25 @@ Score of **{eval_score["score"]}/5**
|
|
119 |
|
120 |
Rationale:
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
{eval_score["rationale_based_on_scoring_rules"]}
|
123 |
"""
|
124 |
|
@@ -143,11 +163,14 @@ with gr.Blocks(title=title,theme='nota-ai/theme') as demo:
|
|
143 |
with gr.Accordion("Accuracy score", open=False):
|
144 |
evaluator = gr.Markdown("Waiting for answer to evaluate...")
|
145 |
chat_output = gr.Markdown("Waiting for question...")
|
146 |
-
with gr.Tab("Chat - ICL", interactive=
|
147 |
-
with gr.
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
|
|
151 |
chat_output_gemini = gr.Markdown("Waiting for question...")
|
152 |
with gr.Tab("Data", interactive = True):
|
153 |
with gr.Tab("Sunday Naturals"):
|
@@ -191,7 +214,7 @@ with gr.Blocks(title=title,theme='nota-ai/theme') as demo:
|
|
191 |
|
192 |
fn = partial(get_data_room_overview)
|
193 |
fn_chat = partial(generate_chat_answer)
|
194 |
-
|
195 |
submit_button.click(fn=fn, inputs=[company_name], outputs=[
|
196 |
data_room_overview,
|
197 |
sunday_naturals_web,
|
@@ -209,7 +232,7 @@ with gr.Blocks(title=title,theme='nota-ai/theme') as demo:
|
|
209 |
|
210 |
|
211 |
chat_submit_button.click(fn=fn_chat, inputs=[company_name, chat_input], outputs=[chat_output, evaluator])
|
212 |
-
|
213 |
login = os.environ.get("login")
|
214 |
pwd = os.environ.get("pwd")
|
215 |
|
|
|
5 |
import gdown
|
6 |
import pandas as pd
|
7 |
from hogwarts import get_answer
|
8 |
+
from hogwats_gemini import get_answer as get_answer_gemini
|
9 |
from evaluator import eval_answer
|
10 |
import nltk
|
11 |
nltk.download('punkt')
|
|
|
120 |
|
121 |
Rationale:
|
122 |
|
123 |
+
{eval_score["rationale_based_on_scoring_rules"]}
|
124 |
+
"""
|
125 |
+
|
126 |
+
return response, eval_md
|
127 |
+
|
128 |
+
def generate_chat_answer_gemini(company_name, query):
|
129 |
+
|
130 |
+
df = dico[name_to_id_mapper[company_name]]["data"]
|
131 |
+
content = df["content"].values
|
132 |
+
response = get_answer_gemini(query, company_name, content)
|
133 |
+
print("=====> Evaluating answer quality...")
|
134 |
+
eval_score = eval(eval_answer(query, response))
|
135 |
+
eval_md = f"""
|
136 |
+
### Evalation of how well the response answer the intial question
|
137 |
+
|
138 |
+
Score of **{eval_score["score"]}/5**
|
139 |
+
|
140 |
+
Rationale:
|
141 |
+
|
142 |
{eval_score["rationale_based_on_scoring_rules"]}
|
143 |
"""
|
144 |
|
|
|
163 |
with gr.Accordion("Accuracy score", open=False):
|
164 |
evaluator = gr.Markdown("Waiting for answer to evaluate...")
|
165 |
chat_output = gr.Markdown("Waiting for question...")
|
166 |
+
with gr.Tab("Chat - ICL", interactive=True):
|
167 |
+
with gr.Row():
|
168 |
+
with gr.Column(scale=5):
|
169 |
+
chat_input_gemini = gr.Textbox(placeholder="Chat input", lines=2, label="Retrieve anything from the dataroom")
|
170 |
+
with gr.Column(scale=1):
|
171 |
+
chat_submit_button_gemini = gr.Button(value="Submit")
|
172 |
+
with gr.Accordion("Accuracy score", open=False):
|
173 |
+
evaluator_gemini = gr.Markdown("Waiting for answer to evaluate...")
|
174 |
chat_output_gemini = gr.Markdown("Waiting for question...")
|
175 |
with gr.Tab("Data", interactive = True):
|
176 |
with gr.Tab("Sunday Naturals"):
|
|
|
214 |
|
215 |
fn = partial(get_data_room_overview)
|
216 |
fn_chat = partial(generate_chat_answer)
|
217 |
+
fn_chat_gemini = partial(generate_chat_answer_gemini)
|
218 |
submit_button.click(fn=fn, inputs=[company_name], outputs=[
|
219 |
data_room_overview,
|
220 |
sunday_naturals_web,
|
|
|
232 |
|
233 |
|
234 |
chat_submit_button.click(fn=fn_chat, inputs=[company_name, chat_input], outputs=[chat_output, evaluator])
|
235 |
+
chat_submit_button_gemini.click(fn=fn_chat_gemini, inputs=[company_name, chat_input_gemini], outputs=[chat_output_gemini, evaluator_gemini])
|
236 |
login = os.environ.get("login")
|
237 |
pwd = os.environ.get("pwd")
|
238 |
|