File size: 881 Bytes
22146b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests
import pandas as pd

def fetch_and_update_training_data(train_file):
    model_name = "TYT"
    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