botsi commited on
Commit
b8ddc1d
·
verified ·
1 Parent(s): a4adc1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -13
app.py CHANGED
@@ -20,23 +20,45 @@ import mysql.connector
20
  import urllib.parse
21
  import urllib.request
22
 
23
- # For Prompt Engineering
24
- # import requests
25
- # from huggingface_hub import AsyncInferenceClient
26
 
27
  # Save chat history as JSON
28
  import atexit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
- # Add this global variable to store the chat history
31
- # global_chat_history = []
32
- # Add this function to store the chat history
33
- #def save_chat_history():
34
- # """Save the chat history to a JSON file."""
35
- # with open("chat_history.json", "w") as json_file:
36
- # json.dump(global_chat_history, json_file)
37
-
38
- #from huggingface_hub import login
39
- #HF_TOKEN = os.getenv('HF_TOKEN')
40
 
41
  MAX_MAX_NEW_TOKENS = 2048
42
  DEFAULT_MAX_NEW_TOKENS = 1024
 
20
  import urllib.parse
21
  import urllib.request
22
 
 
 
 
23
 
24
  # Save chat history as JSON
25
  import atexit
26
+ import os
27
+ from huggingface_hub import HfApi, HfFolder
28
+
29
+ # Define dataset repository URL and ID
30
+ DATASET_REPO_URL = "https://huggingface.co/datasets/botsi/trust-game-llama-2-7b-chat"
31
+ DATASET_REPO_ID = "botsi/trust-game-llama-2-7b-chat"
32
+
33
+ # Define data file information
34
+ DATA_FILENAME = "history_trust-game-llama-2-7b-chat.csv"
35
+ DATA_FILE = os.path.join("data", DATA_FILENAME)
36
+
37
+ # Get Hugging Face token from environment variable
38
+ HF_TOKEN = os.environ.get("HF_TOKEN")
39
+
40
+ # Check if the data file exists
41
+ if os.path.exists(DATA_FILE):
42
+ # Initialize Hugging Face API
43
+ api = HfApi()
44
+
45
+ # Upload file to dataset repository
46
+ with open(DATA_FILE, "rb") as f:
47
+ dataset_files = HfFolder.upload(
48
+ folder_or_file=f,
49
+ path_in_repo=DATA_FILENAME,
50
+ repo_id=DATASET_REPO_ID,
51
+ token=HF_TOKEN
52
+ )
53
+
54
+ # Print uploaded file information
55
+ print("Uploaded file to dataset repository:")
56
+ for file_info in dataset_files:
57
+ print(f"File path in repo: {file_info.path}")
58
+ print(f"File ID: {file_info.id}")
59
+ else:
60
+ print("Data file does not exist.")
61
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  MAX_MAX_NEW_TOKENS = 2048
64
  DEFAULT_MAX_NEW_TOKENS = 1024