Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,36 +11,37 @@ from huggingface_hub import Repository, hf_hub_download, upload_file
|
|
11 |
from datetime import datetime
|
12 |
|
13 |
# created new dataset as awacke1/MindfulStory.csv
|
14 |
-
DATASET_REPO_URL = "https://huggingface.co/datasets/awacke1/MindfulStory.csv"
|
15 |
-
DATASET_REPO_ID = "awacke1/MindfulStory.csv"
|
16 |
-
DATA_FILENAME = "MindfulStory.csv"
|
17 |
-
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
18 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
|
|
19 |
# Download dataset repo using hub download
|
20 |
-
try:
|
21 |
-
hf_hub_download(
|
22 |
-
repo_id=DATASET_REPO_ID,
|
23 |
-
filename=DATA_FILENAME,
|
24 |
-
cache_dir=DATA_DIRNAME,
|
25 |
-
force_filename=DATA_FILENAME
|
26 |
-
)
|
27 |
-
except:
|
28 |
-
print("file not found")
|
29 |
|
30 |
-
def AIMemory(title: str, story: str):
|
31 |
-
if title and story:
|
32 |
-
with open(DATA_FILE, "a") as csvfile:
|
33 |
-
writer = csv.DictWriter(csvfile, fieldnames=["title", "story", "time"])
|
34 |
-
writer.writerow({"title": title, "story": story, "time": str(datetime.now())})
|
35 |
# uncomment line below to begin saving your changes
|
36 |
#commit_url = repo.push_to_hub()
|
37 |
-
return ""
|
38 |
|
39 |
|
40 |
# Set up cloned dataset from repo for operations
|
41 |
-
repo = Repository(
|
42 |
-
local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
43 |
-
)
|
44 |
|
45 |
#generator1 = gr.Interface.load("bigscience/bloom", api_key=HF_TOKEN)
|
46 |
|
@@ -54,23 +55,23 @@ def calculator(intro, operator, outro):
|
|
54 |
if operator == "add":
|
55 |
output = generator2(intro) + generator3(outro)
|
56 |
title = intro + " " + outro
|
57 |
-
saved = AIMemory(title, output)
|
58 |
return output
|
59 |
elif operator == "subtract":
|
60 |
output = generator2(outro) + generator3(intro)
|
61 |
title = outro + " " + intro
|
62 |
-
saved = AIMemory(title, output)
|
63 |
output = output.replace(intro, "").replace(outro, "")
|
64 |
return output
|
65 |
elif operator == "multiply":
|
66 |
output = generator1(intro) + generator2(outro) + generator3(intro)
|
67 |
title = intro + " " + outro + " " + intro
|
68 |
-
saved = AIMemory(title, output)
|
69 |
return output
|
70 |
elif operator == "divide":
|
71 |
output = generator1(outro) + generator2(intro) + generator3(outro)
|
72 |
title = outro + " " + intro + " " + outro
|
73 |
-
saved = AIMemory(title, output)
|
74 |
output = output.replace(intro, "").replace(outro, "")
|
75 |
return output
|
76 |
|
|
|
11 |
from datetime import datetime
|
12 |
|
13 |
# created new dataset as awacke1/MindfulStory.csv
|
14 |
+
#DATASET_REPO_URL = "https://huggingface.co/datasets/awacke1/MindfulStory.csv"
|
15 |
+
#DATASET_REPO_ID = "awacke1/MindfulStory.csv"
|
16 |
+
#DATA_FILENAME = "MindfulStory.csv"
|
17 |
+
#DATA_FILE = os.path.join("data", DATA_FILENAME)
|
18 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
19 |
+
|
20 |
# Download dataset repo using hub download
|
21 |
+
#try:
|
22 |
+
# hf_hub_download(
|
23 |
+
# repo_id=DATASET_REPO_ID,
|
24 |
+
# filename=DATA_FILENAME,
|
25 |
+
# cache_dir=DATA_DIRNAME,
|
26 |
+
# force_filename=DATA_FILENAME
|
27 |
+
# )
|
28 |
+
#except:
|
29 |
+
# print("file not found")
|
30 |
|
31 |
+
#def AIMemory(title: str, story: str):
|
32 |
+
# if title and story:
|
33 |
+
# with open(DATA_FILE, "a") as csvfile:
|
34 |
+
# writer = csv.DictWriter(csvfile, fieldnames=["title", "story", "time"])
|
35 |
+
# writer.writerow({"title": title, "story": story, "time": str(datetime.now())})
|
36 |
# uncomment line below to begin saving your changes
|
37 |
#commit_url = repo.push_to_hub()
|
38 |
+
# return ""
|
39 |
|
40 |
|
41 |
# Set up cloned dataset from repo for operations
|
42 |
+
#repo = Repository(
|
43 |
+
# local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
44 |
+
#)
|
45 |
|
46 |
#generator1 = gr.Interface.load("bigscience/bloom", api_key=HF_TOKEN)
|
47 |
|
|
|
55 |
if operator == "add":
|
56 |
output = generator2(intro) + generator3(outro)
|
57 |
title = intro + " " + outro
|
58 |
+
# saved = AIMemory(title, output)
|
59 |
return output
|
60 |
elif operator == "subtract":
|
61 |
output = generator2(outro) + generator3(intro)
|
62 |
title = outro + " " + intro
|
63 |
+
# saved = AIMemory(title, output)
|
64 |
output = output.replace(intro, "").replace(outro, "")
|
65 |
return output
|
66 |
elif operator == "multiply":
|
67 |
output = generator1(intro) + generator2(outro) + generator3(intro)
|
68 |
title = intro + " " + outro + " " + intro
|
69 |
+
# saved = AIMemory(title, output)
|
70 |
return output
|
71 |
elif operator == "divide":
|
72 |
output = generator1(outro) + generator2(intro) + generator3(outro)
|
73 |
title = outro + " " + intro + " " + outro
|
74 |
+
# saved = AIMemory(title, output)
|
75 |
output = output.replace(intro, "").replace(outro, "")
|
76 |
return output
|
77 |
|