Reyad-Ahmmed commited on
Commit
496a78a
·
verified ·
1 Parent(s): c91da73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -34
app.py CHANGED
@@ -45,6 +45,37 @@ arg5 = config.get('arg5', '1')
45
  arg6 = config.get('arg6', 'saved_fleet_model')
46
  arg7 = config.get('arg7', 'Model')
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  if num_args == 7:
49
  # cmd args
50
  # sys.argv[0] is the script name, sys.argv[1] is the first argument, etc.
@@ -81,11 +112,9 @@ if (should_train_model=='1'): #train model
81
  file_path_train = train_file + ".csv"
82
  file_path_test = test_file + ".csv"
83
 
84
-
85
- file_train_df = fetch_and_update_training_data()
86
-
87
  # Read the CSV files into pandas DataFrames they will later by converted to DataTables and used to train and evaluate the model
88
  #file_train_df = pd.read_csv(file_path_train)
 
89
  file_train_df = fetch_and_update_training_data()
90
  file_test_df = pd.read_csv(file_path_test)
91
 
@@ -338,38 +367,7 @@ label_mapping_reverse = {value: key for key, value in label_mapping.items()}
338
 
339
 
340
 
341
- # create function for fetch data
342
- def fetch_and_update_training_data():
343
- model_name = f"{arg7}"
344
- export_type = "sentence"
345
-
346
- print(arg2)
347
- print(arg7)
348
-
349
- request_url = f"http://20.247.235.135/AiBot/BE/api/PromptEnhancer/ExportPEList?modelName={model_name}&exportType={export_type}"
350
-
351
- response = requests.get(request_url)
352
-
353
- if response.status_code == 200:
354
- try:
355
- # Save response as CSV
356
- with open(arg2 + ".csv", "w", encoding="utf-8") as file:
357
- file.write(response.text)
358
-
359
- print("Training file updated successfully.")
360
-
361
- # Read the updated CSV into a DataFrame
362
- return pd.read_csv(arg2 + ".csv")
363
 
364
- except Exception as e:
365
- print(f"Error processing the response: {e}")
366
- return None
367
- else:
368
- print(f"Error fetching data: {response.status_code}")
369
- return None
370
-
371
- # run the function
372
- fetch_and_update_training_data()
373
 
374
  #Function to classify user input
375
  def classify_user_input():
 
45
  arg6 = config.get('arg6', 'saved_fleet_model')
46
  arg7 = config.get('arg7', 'Model')
47
 
48
+ # create function for fetch data
49
+ def fetch_and_update_training_data():
50
+ model_name = f"{arg7}"
51
+ export_type = "sentence"
52
+
53
+ print(arg2)
54
+ print(arg7)
55
+
56
+ request_url = f"http://20.247.235.135/AiBot/BE/api/PromptEnhancer/ExportPEList?modelName={model_name}&exportType={export_type}"
57
+
58
+ response = requests.get(request_url)
59
+
60
+ if response.status_code == 200:
61
+ try:
62
+ # Save response as CSV
63
+ with open(arg2 + ".csv", "w", encoding="utf-8") as file:
64
+ file.write(response.text)
65
+
66
+ print("Training file updated successfully.")
67
+
68
+ # Read the updated CSV into a DataFrame
69
+ return pd.read_csv(arg2 + ".csv")
70
+
71
+ except Exception as e:
72
+ print(f"Error processing the response: {e}")
73
+ return None
74
+ else:
75
+ print(f"Error fetching data: {response.status_code}")
76
+ return None
77
+
78
+
79
  if num_args == 7:
80
  # cmd args
81
  # sys.argv[0] is the script name, sys.argv[1] is the first argument, etc.
 
112
  file_path_train = train_file + ".csv"
113
  file_path_test = test_file + ".csv"
114
 
 
 
 
115
  # Read the CSV files into pandas DataFrames they will later by converted to DataTables and used to train and evaluate the model
116
  #file_train_df = pd.read_csv(file_path_train)
117
+
118
  file_train_df = fetch_and_update_training_data()
119
  file_test_df = pd.read_csv(file_path_test)
120
 
 
367
 
368
 
369
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
370
 
 
 
 
 
 
 
 
 
 
371
 
372
  #Function to classify user input
373
  def classify_user_input():