Reyad-Ahmmed commited on
Commit
a871ecb
·
verified ·
1 Parent(s): 1db1ffc

Update fetch_data.py

Browse files
Files changed (1) hide show
  1. fetch_data.py +12 -4
fetch_data.py CHANGED
@@ -1,8 +1,16 @@
1
  import requests
2
  import pandas as pd
 
3
 
4
- def fetch_and_update_training_data(train_file):
5
- model_name = "TYT"
 
 
 
 
 
 
 
6
  export_type = "sentence"
7
  request_url = f"http://20.247.235.135/AiBot/BE/api/PromptEnhancer/ExportPEList?modelName={model_name}&exportType={export_type}"
8
 
@@ -11,13 +19,13 @@ def fetch_and_update_training_data(train_file):
11
  if response.status_code == 200:
12
  try:
13
  # Save response as CSV
14
- with open(train_file + ".csv", "w", encoding="utf-8") as file:
15
  file.write(response.text)
16
 
17
  print("Training file updated successfully.")
18
 
19
  # Read the updated CSV into a DataFrame
20
- return pd.read_csv(train_file + ".csv")
21
 
22
  except Exception as e:
23
  print(f"Error processing the response: {e}")
 
1
  import requests
2
  import pandas as pd
3
+ import json
4
 
5
+ # Load configuration file
6
+ with open('config.json', 'r') as config_file:
7
+ config = json.load(config_file)
8
+
9
+ arg2 = config.get('arg2', 'train_fleet')
10
+ arg7 = config.get('arg7', 'Model')
11
+
12
+ def fetch_and_update_training_data(arg2):
13
+ model_name = arg7
14
  export_type = "sentence"
15
  request_url = f"http://20.247.235.135/AiBot/BE/api/PromptEnhancer/ExportPEList?modelName={model_name}&exportType={export_type}"
16
 
 
19
  if response.status_code == 200:
20
  try:
21
  # Save response as CSV
22
+ with open(arg2 + ".csv", "w", encoding="utf-8") as file:
23
  file.write(response.text)
24
 
25
  print("Training file updated successfully.")
26
 
27
  # Read the updated CSV into a DataFrame
28
+ return pd.read_csv(arg2 + ".csv")
29
 
30
  except Exception as e:
31
  print(f"Error processing the response: {e}")