File size: 1,063 Bytes
22146b1
 
a871ecb
22146b1
a871ecb
 
 
 
 
 
 
 
 
22146b1
 
 
 
 
 
 
 
a871ecb
22146b1
 
 
 
 
a871ecb
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
29
30
31
32
33
34
35
36
import requests
import pandas as pd
import json

# Load configuration file 
with open('config.json', 'r') as config_file:
    config = json.load(config_file) 

arg2 = config.get('arg2', 'train_fleet') 
arg7 = config.get('arg7', 'Model')

def fetch_and_update_training_data(arg2):
    model_name = arg7
    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(arg2 + ".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(arg2 + ".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