Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
tanveeshsingh
commited on
Commit
•
24ec30d
1
Parent(s):
9ce665a
Changes to push to ds
Browse files
app.py
CHANGED
@@ -5,6 +5,8 @@ import json
|
|
5 |
import time
|
6 |
from openai import AsyncOpenAI
|
7 |
from jinja2 import Template
|
|
|
|
|
8 |
collinear = Collinear(access_token=os.getenv('COLLINEAR_API_KEY'),space_id=os.getenv('COLLINEAR_SPACE_ID'))
|
9 |
prompt = Template("""
|
10 |
iven the following QUESTION, DOCUMENT and ANSWER you must analyze the provided answer and determine whether it is faithful to the contents of the DOCUMENT. The ANSWER must not offer new information beyond the context provided in the DOCUMENT. The ANSWER also must not contradict information provided in the DOCUMENT. Output your final verdict by strictly following this format: "PASS" if the answer is faithful to the DOCUMENT and "FAIL" if the answer is not faithful to the DOCUMENT. Show your reasoning.
|
@@ -41,7 +43,7 @@ def update_inputs(input_style):
|
|
41 |
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=True)
|
42 |
|
43 |
|
44 |
-
async def lynx(input_style_dropdown,document_input,question_input,answer_input,result_output):
|
45 |
start_time = time.time()
|
46 |
if input_style_dropdown=='QA format':
|
47 |
client = AsyncOpenAI(
|
@@ -79,7 +81,7 @@ Your output should be in JSON FORMAT with the keys "REASONING" and "SCORE":
|
|
79 |
else:
|
80 |
results = 'NA'
|
81 |
lynx_time = round(time.time() - start_time, 2) # Calculate time taken for Lynx
|
82 |
-
await add_to_dataset(input_style_dropdown,document_input,question_input,answer_input,claim_input,results,result_output)
|
83 |
return results, lynx_time
|
84 |
# Function to judge reliability based on the selected input format
|
85 |
|
@@ -242,7 +244,7 @@ assistant:Yes, it is about $38Bn.""")
|
|
242 |
outputs=[result_output,veritas_time_output]
|
243 |
).then(
|
244 |
fn=lynx,
|
245 |
-
inputs=[input_style_dropdown,document_input,question_input,answer_input,result_output],
|
246 |
outputs=[lynx_output, lynx_time_output]
|
247 |
)
|
248 |
|
|
|
5 |
import time
|
6 |
from openai import AsyncOpenAI
|
7 |
from jinja2 import Template
|
8 |
+
from datasets import load_dataset, Dataset, DatasetDict
|
9 |
+
import pandas as pd
|
10 |
collinear = Collinear(access_token=os.getenv('COLLINEAR_API_KEY'),space_id=os.getenv('COLLINEAR_SPACE_ID'))
|
11 |
prompt = Template("""
|
12 |
iven the following QUESTION, DOCUMENT and ANSWER you must analyze the provided answer and determine whether it is faithful to the contents of the DOCUMENT. The ANSWER must not offer new information beyond the context provided in the DOCUMENT. The ANSWER also must not contradict information provided in the DOCUMENT. Output your final verdict by strictly following this format: "PASS" if the answer is faithful to the DOCUMENT and "FAIL" if the answer is not faithful to the DOCUMENT. Show your reasoning.
|
|
|
43 |
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=True)
|
44 |
|
45 |
|
46 |
+
async def lynx(input_style_dropdown,document_input,question_input,answer_input,claim_input,conversation_input,result_output):
|
47 |
start_time = time.time()
|
48 |
if input_style_dropdown=='QA format':
|
49 |
client = AsyncOpenAI(
|
|
|
81 |
else:
|
82 |
results = 'NA'
|
83 |
lynx_time = round(time.time() - start_time, 2) # Calculate time taken for Lynx
|
84 |
+
await add_to_dataset(input_style_dropdown,document_input,question_input,answer_input,claim_input,conversation_input,results,result_output)
|
85 |
return results, lynx_time
|
86 |
# Function to judge reliability based on the selected input format
|
87 |
|
|
|
244 |
outputs=[result_output,veritas_time_output]
|
245 |
).then(
|
246 |
fn=lynx,
|
247 |
+
inputs=[input_style_dropdown,document_input,question_input,answer_input,claim_input,conversation_input,result_output],
|
248 |
outputs=[lynx_output, lynx_time_output]
|
249 |
)
|
250 |
|