Redmind commited on
Commit
ab0a986
·
verified ·
1 Parent(s): 6aa56fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -45
app.py CHANGED
@@ -1111,13 +1111,6 @@ def chat_with_excel_data_dataframe(question):
1111
  #response_dataframe.to_excel(save_file_path, index=False)
1112
  #save_file_to_hostinger(save_file_path)
1113
 
1114
- # Check if the response is a DataFrame
1115
- """if isinstance(response_dataframe, pd.DataFrame):
1116
- # Convert DataFrame to HTML for display
1117
- df_html = response_dataframe.to_html(classes='dataframe', index=False)
1118
- print(f"dfhtml:{df_html}")
1119
- return df_html"""
1120
-
1121
  #return response_dataframe.head(10)#, len(response_dataframe)
1122
 
1123
  def save_file_to_hostinger(save_file_path):
@@ -1184,45 +1177,12 @@ def handle_large_dataset(df, create_document,isDataFrame):
1184
 
1185
  file_path = os.path.join(current_folder, 'output_data.xlsx')
1186
  df.to_excel(file_path, index=False)
1187
- #if not os.path.exists("/data/"):
1188
- #os.makedirs("/data/")
1189
- #df.to_excel('/data/output_data.xlsx', index=False)
1190
-
1191
- files = os.listdir(current_folder)
1192
- print(f"Files in persistent storage: {files}")
1193
- print(f"The current folder is: {current_folder}")
1194
- """from huggingface_hub import Repository
1195
-
1196
- repo = Repository(
1197
- local_dir="./",
1198
- repo_type="space",
1199
- repo_id="Redmind/NewageNXTGPT",
1200
- use_auth_token=os.getenv("HF_TOKEN"),
1201
- )"""
1202
 
1203
  file_path = "output_data.xlsx"
1204
  #download_url = repo.get_download_url(file_path)
1205
-
1206
- from huggingface_hub import upload_file
1207
-
1208
- # Upload file to the Hugging Face Hub
1209
- repo_id = "Redmind/NewageNXTGPT"
1210
- #file_path = "/app/example.txt" # Path to the file to upload
1211
- from huggingface_hub import login
1212
-
1213
- # Login to Hugging Face Hub
1214
- login(token=os.getenv("HF_TOKEN"))
1215
- from huggingface_hub import HfApi
1216
- api = HfApi()
1217
- #api.upload_file(path_or_fileobj=file_path, repo_id=repo_id, repo_type= "space", path_in_repo="static/output.xlsx")
1218
-
1219
- from huggingface_hub import hf_hub_url
1220
-
1221
- print(hf_hub_url(
1222
- repo_id="Redmind/NewageNXTGPT", filename="static/output.xlsx"
1223
- ))
1224
-
1225
- #print(f"Download the file here: {download_url}")
1226
  #save_file_to_hostinger('output_data.xlsx')
1227
  # 4. Create a summary and table of the first 10 rows for display
1228
 
@@ -1247,7 +1207,7 @@ def handle_large_dataset(df, create_document,isDataFrame):
1247
  else:
1248
  return "Your query returns a large dataset which is not supported in the current version. Please try a different query."
1249
 
1250
- def create_file_HF():
1251
  from huggingface_hub import create_branch, create_tag
1252
  from huggingface_hub import login
1253
 
@@ -1258,7 +1218,7 @@ def create_file_HF():
1258
 
1259
  from huggingface_hub import HfApi
1260
  api = HfApi()
1261
- api.upload_file(path_or_fileobj="Inbound.pdf", repo_id="Redmind/NewageNXTGPT_Repo_trial",revision = "test-branch", repo_type= "space", path_in_repo="Inbound.pdf")
1262
 
1263
 
1264
  def create_pdf(cname,ename,account_number):
 
1111
  #response_dataframe.to_excel(save_file_path, index=False)
1112
  #save_file_to_hostinger(save_file_path)
1113
 
 
 
 
 
 
 
 
1114
  #return response_dataframe.head(10)#, len(response_dataframe)
1115
 
1116
  def save_file_to_hostinger(save_file_path):
 
1177
 
1178
  file_path = os.path.join(current_folder, 'output_data.xlsx')
1179
  df.to_excel(file_path, index=False)
1180
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1181
 
1182
  file_path = "output_data.xlsx"
1183
  #download_url = repo.get_download_url(file_path)
1184
+ create_file_HF(file_path)
1185
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1186
  #save_file_to_hostinger('output_data.xlsx')
1187
  # 4. Create a summary and table of the first 10 rows for display
1188
 
 
1207
  else:
1208
  return "Your query returns a large dataset which is not supported in the current version. Please try a different query."
1209
 
1210
+ def create_file_HF(file_path):
1211
  from huggingface_hub import create_branch, create_tag
1212
  from huggingface_hub import login
1213
 
 
1218
 
1219
  from huggingface_hub import HfApi
1220
  api = HfApi()
1221
+ api.upload_file(path_or_fileobj=file_path, repo_id="Redmind/NewageNXTGPT_Repo_trial",revision = "test-branch", repo_type= "space", path_in_repo='./output')
1222
 
1223
 
1224
  def create_pdf(cname,ename,account_number):