Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,7 +28,7 @@ from huggingface_hub import HfApi, login, upload_folder, create_repo
|
|
| 28 |
import os
|
| 29 |
from flask import Flask, jsonify, request
|
| 30 |
import requests
|
| 31 |
-
|
| 32 |
|
| 33 |
# Load configuration file
|
| 34 |
with open('config.json', 'r') as config_file:
|
|
@@ -45,37 +45,6 @@ arg5 = config.get('arg5', '1')
|
|
| 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.
|
|
@@ -115,7 +84,7 @@ if (should_train_model=='1'): #train model
|
|
| 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 |
|
| 121 |
|
|
|
|
| 28 |
import os
|
| 29 |
from flask import Flask, jsonify, request
|
| 30 |
import requests
|
| 31 |
+
from fetch_data import fetch_and_update_training_data
|
| 32 |
|
| 33 |
# Load configuration file
|
| 34 |
with open('config.json', 'r') as config_file:
|
|
|
|
| 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.
|
|
|
|
| 84 |
# Read the CSV files into pandas DataFrames they will later by converted to DataTables and used to train and evaluate the model
|
| 85 |
#file_train_df = pd.read_csv(file_path_train)
|
| 86 |
|
| 87 |
+
file_train_df = fetch_and_update_training_data(file_path_train)
|
| 88 |
file_test_df = pd.read_csv(file_path_test)
|
| 89 |
|
| 90 |
|