Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,10 +4,10 @@ import pandas as pd
|
|
4 |
import numpy as np
|
5 |
import csv
|
6 |
import os
|
7 |
-
from sentence_transformers.util import semantic_search
|
8 |
-
import torch
|
9 |
from datasets import load_dataset
|
10 |
openai.api_key= os.environ.get("openai.api_key")
|
|
|
|
|
11 |
import requests
|
12 |
model_id = "sentence-transformers/all-MiniLM-L6-v2"
|
13 |
import json
|
@@ -22,17 +22,17 @@ def generate_embeddings(texts, model_id, hf_token):
|
|
22 |
embeddings = response.json()
|
23 |
return embeddings
|
24 |
AP_Bio = load_dataset('vjain/biology_AP_embeddings')
|
25 |
-
|
|
|
26 |
|
|
|
|
|
|
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
#dataframes = {
|
33 |
-
# "AP_Bio": df1,
|
34 |
-
# "AP_Physics": df2
|
35 |
-
#}
|
36 |
|
37 |
#df = pd.read_csv("TA_embeddings.csv")
|
38 |
#df["embedding"]=df["embedding"].apply(eval).apply(np.array)
|
@@ -58,9 +58,7 @@ def reply(input, dataset_name):
|
|
58 |
prompt = f"""
|
59 |
Answer the following question using the context given below.If you don't know the answer for certain, say I don't know.
|
60 |
Context: {context}
|
61 |
-
|
62 |
Q: {input}
|
63 |
-
|
64 |
"""
|
65 |
response= openai.Completion.create(
|
66 |
prompt=prompt,
|
|
|
4 |
import numpy as np
|
5 |
import csv
|
6 |
import os
|
|
|
|
|
7 |
from datasets import load_dataset
|
8 |
openai.api_key= os.environ.get("openai.api_key")
|
9 |
+
from openai.embeddings_utils import get_embedding
|
10 |
+
from openai.embeddings_utils import cosine_similarity
|
11 |
import requests
|
12 |
model_id = "sentence-transformers/all-MiniLM-L6-v2"
|
13 |
import json
|
|
|
22 |
embeddings = response.json()
|
23 |
return embeddings
|
24 |
AP_Bio = load_dataset('vjain/biology_AP_embeddings')
|
25 |
+
df1 = pd.DataFrame(AP_Bio['train'])
|
26 |
+
df1["similarity"] = 0
|
27 |
|
28 |
+
AP_Physics = load_dataset('vjain/AP_physics_embeddings')
|
29 |
+
df2 = pd.DataFrame(AP_Physics['train'])
|
30 |
+
df2["similarity"] = 0
|
31 |
|
32 |
+
dataframes = {
|
33 |
+
"AP_Bio": df1,
|
34 |
+
"AP_Physics": df2
|
35 |
+
}
|
|
|
|
|
|
|
|
|
36 |
|
37 |
#df = pd.read_csv("TA_embeddings.csv")
|
38 |
#df["embedding"]=df["embedding"].apply(eval).apply(np.array)
|
|
|
58 |
prompt = f"""
|
59 |
Answer the following question using the context given below.If you don't know the answer for certain, say I don't know.
|
60 |
Context: {context}
|
|
|
61 |
Q: {input}
|
|
|
62 |
"""
|
63 |
response= openai.Completion.create(
|
64 |
prompt=prompt,
|