Redmind commited on
Commit
aa1626a
·
verified ·
1 Parent(s): fccd330

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -112,6 +112,10 @@ api= HfApi()
112
  token = os.getenv("HF_TOKEN")
113
  login(token=os.getenv("HF_TOKEN"))
114
 
 
 
 
 
115
  langfuse_handler = CallbackHandler()
116
  langfuse_handler.auth_check() # Optional: Checks if the authentication is successful
117
 
@@ -1276,11 +1280,7 @@ def handle_large_dataset(df, create_document,isDataFrame):
1276
  return "Your query returns a large dataset which is not supported in the current version. Please try a different query."
1277
 
1278
  def create_file_HF(file_path,directory,document_created = False):
1279
-
1280
-
1281
-
1282
- repo_id = "Redmind/NewageNXTGPT_Repo_trial"
1283
-
1284
 
1285
  if document_created:
1286
  directory = directory + "/" + "document"
@@ -1292,13 +1292,9 @@ def create_file_HF(file_path,directory,document_created = False):
1292
  else:
1293
  directory = directory + "/" + file_path
1294
 
 
1295
 
1296
- #create_branch("Redmind/NewageNXTGPT_Repo_trial", repo_type="space", branch="test-branch")
1297
-
1298
- #create_tag("bigcode/the-stack", repo_type="dataset", revision="v0.1-release", tag="v0.1.1", tag_message="Bump release version.")
1299
-
1300
-
1301
- api.upload_file(path_or_fileobj=file_path, repo_id="Redmind/NewageNXTGPT_Repo_trial",revision = "test-branch", repo_type= "space", path_in_repo=directory)
1302
 
1303
 
1304
 
@@ -1354,7 +1350,8 @@ def directory_exists(repo_id, directory, token):
1354
 
1355
  def get_download_link(file_path,file_name):
1356
  # Hugging Face Spaces uses this URL format for repository-hosted files
1357
- base_url = "https://huggingface.co/spaces/Redmind/NewageNXTGPT_Repo_trial/resolve/test-branch"
 
1358
  # Replace <your-space-id> with your actual Space name
1359
  return f"{base_url}/{file_path}/{file_name}"
1360
 
 
112
  token = os.getenv("HF_TOKEN")
113
  login(token=os.getenv("HF_TOKEN"))
114
 
115
+ repo_id = os.getenv("repo_id")
116
+ branch = os.getenv("branch")
117
+
118
+
119
  langfuse_handler = CallbackHandler()
120
  langfuse_handler.auth_check() # Optional: Checks if the authentication is successful
121
 
 
1280
  return "Your query returns a large dataset which is not supported in the current version. Please try a different query."
1281
 
1282
  def create_file_HF(file_path,directory,document_created = False):
1283
+ global repo_id, branch
 
 
 
 
1284
 
1285
  if document_created:
1286
  directory = directory + "/" + "document"
 
1292
  else:
1293
  directory = directory + "/" + file_path
1294
 
1295
+
1296
 
1297
+ api.upload_file(path_or_fileobj=file_path, repo_id=repo_id,revision = branch, repo_type= "space", path_in_repo=directory)
 
 
 
 
 
1298
 
1299
 
1300
 
 
1350
 
1351
  def get_download_link(file_path,file_name):
1352
  # Hugging Face Spaces uses this URL format for repository-hosted files
1353
+ global repo_id,branch
1354
+ base_url = "https://huggingface.co/spaces/" + repo_id + "/resolve/" + branch
1355
  # Replace <your-space-id> with your actual Space name
1356
  return f"{base_url}/{file_path}/{file_name}"
1357