Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -57,50 +57,50 @@ def query_tqa(query, search_level):
|
|
57 |
)
|
58 |
|
59 |
|
60 |
-
def eval_llm(query, rag_response, grag_response):
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
|
73 |
-
|
74 |
-
|
75 |
|
76 |
-
|
77 |
-
|
78 |
|
79 |
|
80 |
-
def reason_and_plot(query, grag_response, grag_reference):
|
81 |
-
|
82 |
-
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
|
98 |
-
|
99 |
-
|
100 |
|
101 |
-
|
102 |
|
103 |
-
|
104 |
|
105 |
|
106 |
def show_graph():
|
@@ -170,43 +170,43 @@ with gr.Blocks() as demo:
|
|
170 |
with gr.Column():
|
171 |
gr.Markdown("### Graph-RAG")
|
172 |
grag_output = gr.Textbox(label="Response", lines=5)
|
173 |
-
grag_reference = gr.Textbox(label="Triplets", lines=3)
|
174 |
-
with gr.Accordion("Extracted Reference (Raw)", open=False):
|
175 |
-
|
176 |
|
177 |
-
with gr.Column():
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
gr.Markdown("### Coupon")
|
185 |
-
with gr.Row():
|
186 |
-
with gr.Column():
|
187 |
-
coupon = gr.Text(label="Coupon", lines=1)
|
188 |
-
with gr.Column():
|
189 |
-
reveal = gr.Button("Reveal Coupon", variant="secondary")
|
190 |
|
191 |
-
|
192 |
-
|
|
|
|
|
|
|
|
|
193 |
|
194 |
-
with gr.Row():
|
195 |
-
|
196 |
|
197 |
-
|
|
|
198 |
|
199 |
-
|
200 |
-
gr.Markdown("### Graph Reasoning")
|
201 |
|
202 |
-
with gr.Row():
|
203 |
-
|
204 |
|
205 |
-
with gr.Row():
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
|
|
|
|
|
|
210 |
|
211 |
with gr.Row():
|
212 |
plot_button = gr.Button("Plot Knowledge Graph", variant="secondary")
|
@@ -218,35 +218,35 @@ with gr.Blocks() as demo:
|
|
218 |
inputs=[query_input, search_level],
|
219 |
outputs=[
|
220 |
grag_output,
|
221 |
-
grag_reference,
|
222 |
-
grag_reference_text,
|
223 |
-
rag_output,
|
224 |
-
rag_reference,
|
225 |
-
rag_reference_text,
|
226 |
],
|
227 |
)
|
228 |
|
229 |
-
eval_button.click(
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
)
|
234 |
|
235 |
-
reason_button.click(
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
)
|
240 |
|
241 |
plot_button.click(
|
242 |
show_graph,
|
243 |
outputs=[kg_output],
|
244 |
)
|
245 |
|
246 |
-
reveal.click(
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
)
|
251 |
|
252 |
demo.launch(auth=(os.getenv("ID"), os.getenv("PASS")), share=False)
|
|
|
57 |
)
|
58 |
|
59 |
|
60 |
+
# def eval_llm(query, rag_response, grag_response):
|
61 |
+
# """
|
62 |
+
# Evaluate the Graph-RAG and RAG responses using an LLM.
|
63 |
|
64 |
+
# Args:
|
65 |
+
# query (str): The query that was asked.
|
66 |
+
# rag_response (str): The response from the Vanilla-RAG model.
|
67 |
+
# grag_response (str): The response from the Graph-RAG model.
|
68 |
|
69 |
+
# Returns:
|
70 |
+
# str: The evaluation text on various criteria from the LLM.
|
71 |
+
# """
|
72 |
|
73 |
+
# if not query.strip() or not rag_response.strip() or not grag_response.strip():
|
74 |
+
# raise gr.Error("Please ask a query and get responses before evaluating.")
|
75 |
|
76 |
+
# eval_text = evaluate_llm(query, grag_response, rag_response)
|
77 |
+
# return eval_text
|
78 |
|
79 |
|
80 |
+
# def reason_and_plot(query, grag_response, grag_reference):
|
81 |
+
# """
|
82 |
+
# Get the reasoning graph for a query and plot the knowledge graph.
|
83 |
|
84 |
+
# Args:
|
85 |
+
# query (str): The query to ask the Graph-RAG.
|
86 |
+
# grag_response (str): The response from the Graph-RAG model.
|
87 |
+
# grag_reference (str): The reference text from the Graph-RAG model.
|
88 |
|
89 |
+
# Returns:
|
90 |
+
# tuple: The reasoning graph and the HTML to plot the knowledge graph.
|
91 |
+
# """
|
92 |
|
93 |
+
# if not query.strip() or not grag_response.strip() or not grag_reference.strip():
|
94 |
+
# raise gr.Error(
|
95 |
+
# "Please ask a query and get a Graph-RAG response before reasoning."
|
96 |
+
# )
|
97 |
|
98 |
+
# graph_reasoning = reasoning_graph(query, grag_response, grag_reference)
|
99 |
+
# escaped_html = plot_subgraph(grag_reference)
|
100 |
|
101 |
+
# iframe_html = f'<iframe srcdoc="{escaped_html}" width="100%" height="400px" frameborder="0"></iframe>'
|
102 |
|
103 |
+
# return graph_reasoning, iframe_html
|
104 |
|
105 |
|
106 |
def show_graph():
|
|
|
170 |
with gr.Column():
|
171 |
gr.Markdown("### Graph-RAG")
|
172 |
grag_output = gr.Textbox(label="Response", lines=5)
|
173 |
+
# grag_reference = gr.Textbox(label="Triplets", lines=3)
|
174 |
+
# with gr.Accordion("Extracted Reference (Raw)", open=False):
|
175 |
+
# grag_reference_text = gr.Textbox(label="Raw Reference", lines=5)
|
176 |
|
177 |
+
# with gr.Column():
|
178 |
+
# gr.Markdown("### Vanilla RAG")
|
179 |
+
# rag_output = gr.Textbox(label="Response", lines=5)
|
180 |
+
# rag_reference = gr.Textbox(label="Extracted Reference", lines=3)
|
181 |
+
# with gr.Accordion("Extracted Reference (Raw)", open=False):
|
182 |
+
# rag_reference_text = gr.Textbox(label="Raw Reference", lines=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
+
# gr.Markdown("### Coupon")
|
185 |
+
# with gr.Row():
|
186 |
+
# with gr.Column():
|
187 |
+
# coupon = gr.Text(label="Coupon", lines=1)
|
188 |
+
# with gr.Column():
|
189 |
+
# reveal = gr.Button("Reveal Coupon", variant="secondary")
|
190 |
|
191 |
+
# with gr.Row():
|
192 |
+
# gr.Markdown("### Evaluate and Compare")
|
193 |
|
194 |
+
# with gr.Row():
|
195 |
+
# eval_button = gr.Button("Evaluate LLMs", variant="secondary")
|
196 |
|
197 |
+
# grag_performance = gr.Textbox(label="Evaluation", lines=3)
|
|
|
198 |
|
199 |
+
# with gr.Row():
|
200 |
+
# gr.Markdown("### Graph Reasoning")
|
201 |
|
202 |
+
# with gr.Row():
|
203 |
+
# reason_button = gr.Button("Get Graph Reasoning", variant="secondary")
|
204 |
+
|
205 |
+
# with gr.Row():
|
206 |
+
# with gr.Column():
|
207 |
+
# grag_reasoning = gr.Textbox(label="Graph-RAG Reasoning", lines=5)
|
208 |
+
# with gr.Column():
|
209 |
+
# subgraph_plot = gr.HTML()
|
210 |
|
211 |
with gr.Row():
|
212 |
plot_button = gr.Button("Plot Knowledge Graph", variant="secondary")
|
|
|
218 |
inputs=[query_input, search_level],
|
219 |
outputs=[
|
220 |
grag_output,
|
221 |
+
# grag_reference,
|
222 |
+
# grag_reference_text,
|
223 |
+
# rag_output,
|
224 |
+
# rag_reference,
|
225 |
+
# rag_reference_text,
|
226 |
],
|
227 |
)
|
228 |
|
229 |
+
# eval_button.click(
|
230 |
+
# eval_llm,
|
231 |
+
# inputs=[query_input, rag_output, grag_output],
|
232 |
+
# outputs=[grag_performance],
|
233 |
+
# )
|
234 |
|
235 |
+
# reason_button.click(
|
236 |
+
# reason_and_plot,
|
237 |
+
# inputs=[query_input, grag_output, grag_reference],
|
238 |
+
# outputs=[grag_reasoning, subgraph_plot],
|
239 |
+
# )
|
240 |
|
241 |
plot_button.click(
|
242 |
show_graph,
|
243 |
outputs=[kg_output],
|
244 |
)
|
245 |
|
246 |
+
# reveal.click(
|
247 |
+
# reveal_coupon,
|
248 |
+
# inputs=[query_input, grag_output],
|
249 |
+
# outputs=[coupon],
|
250 |
+
# )
|
251 |
|
252 |
demo.launch(auth=(os.getenv("ID"), os.getenv("PASS")), share=False)
|