Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,14 +36,13 @@ dataframes = {
|
|
36 |
|
37 |
#df = pd.read_csv("TA_embeddings.csv")
|
38 |
#df["embedding"]=df["embedding"].apply(eval).apply(np.array)
|
39 |
-
def reply(input,
|
40 |
-
global csv_dropdown
|
41 |
try:
|
42 |
#if dataset_name not in dataframes:
|
43 |
# return "Invalid dataset selected. Please select a valid dataset."
|
44 |
if not input:
|
45 |
return "Please Enter a Question to get an Answer"
|
46 |
-
df = dataframes
|
47 |
input = input
|
48 |
input_vector = generate_embeddings(input, model_id,hf_token)
|
49 |
df["similarities"]=df["embedding"].apply(lambda x: cosine_similarity([x],[input_vector])[0][0])
|
@@ -70,12 +69,7 @@ def reply(input, dataset_name):
|
|
70 |
model="text-davinci-003"
|
71 |
)["choices"][0]["text"].strip(" \n")
|
72 |
return response
|
73 |
-
|
74 |
-
label="Select the Book",
|
75 |
-
choices=["AP_Bio", "AP_Physics"],
|
76 |
-
default="AP_Bio"
|
77 |
-
|
78 |
-
)
|
79 |
except Exception as e:
|
80 |
return f"An error occurred: {e}"
|
81 |
|
@@ -83,7 +77,12 @@ def reply(input, dataset_name):
|
|
83 |
|
84 |
|
85 |
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
87 |
input_text = gr.inputs.Textbox(
|
88 |
label="Enter your questions here",
|
89 |
placeholder="E.g. What is DNA?",
|
|
|
36 |
|
37 |
#df = pd.read_csv("TA_embeddings.csv")
|
38 |
#df["embedding"]=df["embedding"].apply(eval).apply(np.array)
|
39 |
+
def reply(input, dataframes):
|
|
|
40 |
try:
|
41 |
#if dataset_name not in dataframes:
|
42 |
# return "Invalid dataset selected. Please select a valid dataset."
|
43 |
if not input:
|
44 |
return "Please Enter a Question to get an Answer"
|
45 |
+
df = dataframes
|
46 |
input = input
|
47 |
input_vector = generate_embeddings(input, model_id,hf_token)
|
48 |
df["similarities"]=df["embedding"].apply(lambda x: cosine_similarity([x],[input_vector])[0][0])
|
|
|
69 |
model="text-davinci-003"
|
70 |
)["choices"][0]["text"].strip(" \n")
|
71 |
return response
|
72 |
+
|
|
|
|
|
|
|
|
|
|
|
73 |
except Exception as e:
|
74 |
return f"An error occurred: {e}"
|
75 |
|
|
|
77 |
|
78 |
|
79 |
|
80 |
+
csv_dropdown = gr.inputs.Dropdown(
|
81 |
+
label="Select the Book",
|
82 |
+
choices=["AP_Bio", "AP_Physics"],
|
83 |
+
default="AP_Bio"
|
84 |
+
|
85 |
+
)
|
86 |
input_text = gr.inputs.Textbox(
|
87 |
label="Enter your questions here",
|
88 |
placeholder="E.g. What is DNA?",
|