Spaces:
Runtime error
Runtime error
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:
|
@@ -43,8 +43,9 @@ arg3 = config.get('arg3', 'test_fleet')
|
|
43 |
arg4 = config.get('arg4', '1')
|
44 |
arg5 = config.get('arg5', '1')
|
45 |
arg6 = config.get('arg6', 'saved_fleet_model')
|
|
|
46 |
|
47 |
-
if num_args ==
|
48 |
# cmd args
|
49 |
# sys.argv[0] is the script name, sys.argv[1] is the first argument, etc.
|
50 |
should_train_model = arg1 # should train model?
|
@@ -352,6 +353,35 @@ label_mapping = model.config.label_mapping
|
|
352 |
label_mapping_reverse = {value: key for key, value in label_mapping.items()}
|
353 |
|
354 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
#Function to classify user input
|
356 |
def classify_user_input():
|
357 |
while True:
|
|
|
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:
|
|
|
43 |
arg4 = config.get('arg4', '1')
|
44 |
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.
|
51 |
should_train_model = arg1 # should train model?
|
|
|
353 |
label_mapping_reverse = {value: key for key, value in label_mapping.items()}
|
354 |
|
355 |
|
356 |
+
|
357 |
+
# fetch data
|
358 |
+
def fetch_and_update_training_data(arg2):
|
359 |
+
model_name = f"{arg7}"
|
360 |
+
export_type = "sentence"
|
361 |
+
|
362 |
+
request_url = f"http://20.247.235.135/AiBot/BE/api/PromptEnhancer/ExportPEList?modelName={model_name}&exportType={export_type}"
|
363 |
+
|
364 |
+
response = requests.get(request_url)
|
365 |
+
|
366 |
+
if response.status_code == 200:
|
367 |
+
try:
|
368 |
+
# Save response as CSV
|
369 |
+
with open(train_file + ".csv", "w", encoding="utf-8") as file:
|
370 |
+
file.write(response.text)
|
371 |
+
|
372 |
+
print("Training file updated successfully.")
|
373 |
+
|
374 |
+
# Read the updated CSV into a DataFrame
|
375 |
+
return pd.read_csv(train_file + ".csv")
|
376 |
+
|
377 |
+
except Exception as e:
|
378 |
+
print(f"Error processing the response: {e}")
|
379 |
+
return None
|
380 |
+
else:
|
381 |
+
print(f"Error fetching data: {response.status_code}")
|
382 |
+
return None
|
383 |
+
|
384 |
+
|
385 |
#Function to classify user input
|
386 |
def classify_user_input():
|
387 |
while True:
|