Mr-Geo commited on
Commit
463338d
·
verified ·
1 Parent(s): 9370c85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -187,10 +187,20 @@ def log_conversation(timestamp, user_message, assistant_response, model_name, co
187
  api = HfApi(token=hf_token)
188
  filename = f"conversation_logs/daily_{current_date}.json"
189
 
 
 
 
 
 
 
 
 
 
 
190
  try:
191
  # Try to download existing file
192
  existing_file = api.hf_hub_download(
193
- repo_id="Mr-Geo/bas_chat_logs",
194
  filename=filename,
195
  repo_type="dataset",
196
  token=hf_token
@@ -219,7 +229,7 @@ def log_conversation(timestamp, user_message, assistant_response, model_name, co
219
  ]
220
 
221
  api.create_commit(
222
- repo_id="Mr-Geo/bas_chat_logs",
223
  repo_type="dataset",
224
  operations=operations,
225
  commit_message=f"Update conversation logs for {current_date}"
@@ -258,6 +268,9 @@ def log_conversation(timestamp, user_message, assistant_response, model_name, co
258
  def chat_response(message, history, model_name):
259
  """Chat response function for Gradio interface"""
260
  try:
 
 
 
261
  # Get context and timestamp
262
  context = get_context(message)
263
  timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
@@ -294,7 +307,7 @@ Context: {context}"""
294
  # Add history and current message
295
  if history:
296
  for h in history:
297
- messages.append({"role": "user", "content": f"{str(h[0])} at BAS"})
298
  if h[1]: # If there's a response
299
  messages.append({"role": "assistant", "content": str(h[1])})
300
 
@@ -387,7 +400,7 @@ if __name__ == "__main__":
387
  ],
388
  value="llama-3.1-8b-instant",
389
  label="Select AI Large Language Model 🤖",
390
- info="Choose which AI model to use for responses (all models running on [GroqCloud](https://groq.com/groqrack/)"
391
  )
392
 
393
  chatbot = gr.Chatbot(height=600)
 
187
  api = HfApi(token=hf_token)
188
  filename = f"conversation_logs/daily_{current_date}.json"
189
 
190
+ # Check if the dataset repository exists, if not create it
191
+ try:
192
+ api.repo_info(repo_id="Mr-Geo/chroma_db", repo_type="dataset")
193
+ except Exception:
194
+ api.create_repo(
195
+ repo_id="Mr-Geo/chroma_db",
196
+ repo_type="dataset",
197
+ private=True
198
+ )
199
+
200
  try:
201
  # Try to download existing file
202
  existing_file = api.hf_hub_download(
203
+ repo_id="Mr-Geo/chroma_db",
204
  filename=filename,
205
  repo_type="dataset",
206
  token=hf_token
 
229
  ]
230
 
231
  api.create_commit(
232
+ repo_id="Mr-Geo/chroma_db",
233
  repo_type="dataset",
234
  operations=operations,
235
  commit_message=f"Update conversation logs for {current_date}"
 
268
  def chat_response(message, history, model_name):
269
  """Chat response function for Gradio interface"""
270
  try:
271
+ # Append 'at BAS' to the user's message
272
+ message += " at BAS"
273
+
274
  # Get context and timestamp
275
  context = get_context(message)
276
  timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
 
307
  # Add history and current message
308
  if history:
309
  for h in history:
310
+ messages.append({"role": "user", "content": str(h[0])})
311
  if h[1]: # If there's a response
312
  messages.append({"role": "assistant", "content": str(h[1])})
313
 
 
400
  ],
401
  value="llama-3.1-8b-instant",
402
  label="Select AI Large Language Model 🤖",
403
+ info="Choose which AI model to use for responses (all models running on [GroqCloud](https://groq.com/groqrack/))"
404
  )
405
 
406
  chatbot = gr.Chatbot(height=600)