Spaces:
Paused
Paused
| import requests | |
| import pandas as pd | |
| def fetch_and_update_training_data(train_file): | |
| model_name = "TitanQL" | |
| export_type = "sentence" | |
| request_url = f"http://20.247.235.135/AiBot/BE/api/PromptEnhancer/ExportPEList?modelName={model_name}&exportType={export_type}" | |
| response = requests.get(request_url) | |
| if response.status_code == 200: | |
| try: | |
| # Save response as CSV | |
| with open(train_file + ".csv", "w", encoding="utf-8") as file: | |
| file.write(response.text) | |
| print("Training file updated successfully.") | |
| # Read the updated CSV into a DataFrame | |
| return pd.read_csv(train_file + ".csv") | |
| except Exception as e: | |
| print(f"Error processing the response: {e}") | |
| return None | |
| else: | |
| print(f"Error fetching data: {response.status_code}") | |
| return None | |