Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -338,10 +338,13 @@ label_mapping_reverse = {value: key for key, value in label_mapping.items()}
|
|
338 |
|
339 |
|
340 |
|
341 |
-
# fetch data
|
342 |
-
def fetch_and_update_training_data(
|
343 |
model_name = f"{arg7}"
|
344 |
export_type = "sentence"
|
|
|
|
|
|
|
345 |
|
346 |
request_url = f"http://20.247.235.135/AiBot/BE/api/PromptEnhancer/ExportPEList?modelName={model_name}&exportType={export_type}"
|
347 |
|
@@ -350,13 +353,13 @@ def fetch_and_update_training_data(train_file):
|
|
350 |
if response.status_code == 200:
|
351 |
try:
|
352 |
# Save response as CSV
|
353 |
-
with open(
|
354 |
file.write(response.text)
|
355 |
|
356 |
print("Training file updated successfully.")
|
357 |
|
358 |
# Read the updated CSV into a DataFrame
|
359 |
-
return pd.read_csv(
|
360 |
|
361 |
except Exception as e:
|
362 |
print(f"Error processing the response: {e}")
|
@@ -364,7 +367,9 @@ def fetch_and_update_training_data(train_file):
|
|
364 |
else:
|
365 |
print(f"Error fetching data: {response.status_code}")
|
366 |
return None
|
367 |
-
|
|
|
|
|
368 |
|
369 |
#Function to classify user input
|
370 |
def classify_user_input():
|
|
|
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 |
|
|
|
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}")
|
|
|
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():
|