awacke1 commited on
Commit
7f42a4d
Β·
1 Parent(s): 6400aab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -34
app.py CHANGED
@@ -48,9 +48,8 @@ if (!window.hasBeenRun) {
48
  UseMemory=True
49
 
50
 
51
- DATASET_REPO_URL="https://huggingface.co/datasets/awacke1/ChatbotMemory.csv"
52
- DATASET_REPO_ID="awacke1/ChatbotMemory.csv"
53
- DATA_FILENAME="ChatbotMemory.csv"
54
  DATA_FILE=os.path.join("data", DATA_FILENAME)
55
  HF_TOKEN=os.environ.get("HF_TOKEN")
56
 
@@ -72,7 +71,6 @@ def get_df(name: str):
72
  dataset = load_dataset(str, split="train")
73
  return dataset
74
 
75
- #def store_message(name: str, message: str) -> str:
76
  def store_message(name: str, message: str):
77
  if name and message:
78
  with open(DATA_FILE, "a") as csvfile:
@@ -81,16 +79,7 @@ def store_message(name: str, message: str):
81
  {"time": str(datetime.now()), "message": message.strip(), "name": name.strip() }
82
  )
83
  commit_url = repo.push_to_hub()
84
-
85
- # test api retrieval of any dataset that is saved, then return it...
86
- # app = FastAPI()
87
- # see: https://gradio.app/sharing_your_app/#api-page
88
-
89
- # f=get_df(DATASET_REPO_ID)
90
- # print(f)
91
- #return commit_url
92
  return ""
93
- # ----------------------------------------------- For Memory
94
 
95
 
96
  repo = Repository(
@@ -98,27 +87,6 @@ repo = Repository(
98
  )
99
 
100
 
101
- def generate_html() -> str:
102
- with open(DATA_FILE) as csvfile:
103
- reader = csv.DictReader(csvfile)
104
- rows = []
105
- for row in reader:
106
- rows.append(row)
107
- rows.reverse()
108
- if len(rows) == 0:
109
- return "no messages yet"
110
- else:
111
- html = "<div class='chatbot'>"
112
- for row in rows:
113
- html += "<div>"
114
- html += f"<span>{row['name']}</span>"
115
- html += f"<span class='message'>{row['message']}</span>"
116
- html += "</div>"
117
- html += "</div>"
118
- return html
119
-
120
- return generate_html()
121
-
122
 
123
 
124
 
 
48
  UseMemory=True
49
 
50
 
51
+ DATASET_REPO_URL = "https://huggingface.co/datasets/awacke1/BookComposer"
52
+ DATA_FILENAME = "BookComposer.csv"
 
53
  DATA_FILE=os.path.join("data", DATA_FILENAME)
54
  HF_TOKEN=os.environ.get("HF_TOKEN")
55
 
 
71
  dataset = load_dataset(str, split="train")
72
  return dataset
73
 
 
74
  def store_message(name: str, message: str):
75
  if name and message:
76
  with open(DATA_FILE, "a") as csvfile:
 
79
  {"time": str(datetime.now()), "message": message.strip(), "name": name.strip() }
80
  )
81
  commit_url = repo.push_to_hub()
 
 
 
 
 
 
 
 
82
  return ""
 
83
 
84
 
85
  repo = Repository(
 
87
  )
88
 
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
 
92