Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,33 +13,31 @@ os.environ['AWS_ACCESS_KEY_ID']="AKIAZOU6TJIYU64BCGHE"
|
|
13 |
os.environ['AWS_SECRET_ACCESS_KEY']="RZxYW0WAs53lwdwCXkOo3qCiK7kk5HT+v6deXL7h"
|
14 |
|
15 |
|
|
|
|
|
|
|
|
|
|
|
16 |
s3 = boto3.resource('s3')
|
17 |
bucket_name = "notesinendocrinology"
|
18 |
-
|
|
|
|
|
19 |
|
20 |
-
for prefix in
|
21 |
for obj in s3.Bucket(bucket_name).objects.filter(Prefix=prefix):
|
22 |
file_path = obj.key
|
23 |
s3.Bucket(bucket_name).download_file(file_path, file_path.split("/")[-1])
|
24 |
print(f"Downloaded {file_path}")
|
25 |
|
26 |
-
|
27 |
@cached(cache=TTLCache(maxsize=1, ttl=3600)) # cache for 1 hour
|
28 |
-
|
29 |
-
|
30 |
def keywords(query2):
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
Bucket.download_file(combo_index_path, "osteoporosis.json")
|
38 |
-
index1 = GPTSimpleVectorIndex.load_from_disk('osteoporosis.json')
|
39 |
-
else:
|
40 |
-
Bucket.download_file(combo_index_path, "comboindex.json")
|
41 |
-
index1 = GPTSimpleVectorIndex.load_from_disk('comboindex.json')
|
42 |
-
return index1
|
43 |
|
44 |
def send_message(message_log):
|
45 |
# Use OpenAI's ChatCompletion API to get the chatbot's response
|
|
|
13 |
os.environ['AWS_SECRET_ACCESS_KEY']="RZxYW0WAs53lwdwCXkOo3qCiK7kk5HT+v6deXL7h"
|
14 |
|
15 |
|
16 |
+
import boto3
|
17 |
+
from cachetools.func import cached
|
18 |
+
from cachetools import TTLCache
|
19 |
+
from gpt2_vectors import GPTSimpleVectorIndex
|
20 |
+
|
21 |
s3 = boto3.resource('s3')
|
22 |
bucket_name = "notesinendocrinology"
|
23 |
+
combo_index_path = "comboindex.json"
|
24 |
+
nafld_path = "nafld.json"
|
25 |
+
osteoporosis_path = "osteoporosis.json"
|
26 |
|
27 |
+
for prefix in [combo_index_path, nafld_path, osteoporosis_path]:
|
28 |
for obj in s3.Bucket(bucket_name).objects.filter(Prefix=prefix):
|
29 |
file_path = obj.key
|
30 |
s3.Bucket(bucket_name).download_file(file_path, file_path.split("/")[-1])
|
31 |
print(f"Downloaded {file_path}")
|
32 |
|
|
|
33 |
@cached(cache=TTLCache(maxsize=1, ttl=3600)) # cache for 1 hour
|
|
|
|
|
34 |
def keywords(query2):
|
35 |
+
index1 = GPTSimpleVectorIndex.load_from_disk(combo_index_path)
|
36 |
+
if "NASH" in query2 or "NAFLD" in query2 or "Non-alcoholic fatty live disease" in query2:
|
37 |
+
index1 = GPTSimpleVectorIndex.load_from_disk(nafld_path)
|
38 |
+
elif "osteoporosis" in query2 or 'osteopenia' in query2 or 'low bone mass' in query2 or 'DEXA-BMD' in query2 or 'BMD' in query2:
|
39 |
+
index1 = GPTSimpleVectorIndex.load_from_disk(osteoporosis_path)
|
40 |
+
return index1
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
def send_message(message_log):
|
43 |
# Use OpenAI's ChatCompletion API to get the chatbot's response
|