yakine commited on
Commit
13454c6
·
verified ·
1 Parent(s): 5a3f786

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -46,7 +46,7 @@ model_llama = AutoModelForCausalLM.from_pretrained(
46
  token=hf_token
47
  )
48
 
49
- # Define your prompt template
50
  prompt_template = """\
51
  You are an expert in generating synthetic data for machine learning models.
52
  Your task is to generate a synthetic tabular dataset based on the description provided below.
@@ -54,6 +54,7 @@ Description: {description}
54
  The dataset should include the following columns: {columns}
55
  Please provide the data in CSV format with a minimum of 100 rows per generation.
56
  Ensure that the data is realistic, does not contain any duplicate rows, and follows any specific conditions mentioned.
 
57
  Example Description:
58
  Generate a dataset for predicting house prices with columns: 'Size', 'Location', 'Number of Bedrooms', 'Price'
59
  Example Output:
@@ -143,12 +144,14 @@ def generate_data(request: DataGenerationRequest):
143
  if "Error" in generated_data:
144
  return JSONResponse(content={"error": generated_data}, status_code=500)
145
 
 
 
 
 
146
  # Process the generated CSV data into a DataFrame
147
  df_synthetic = process_generated_data(generated_data)
148
  return JSONResponse(content={"data": df_synthetic.to_dict(orient="records")})
149
 
150
-
151
-
152
  @app.get("/")
153
  def greet_json():
154
- return {"Hello": "World!"}
 
46
  token=hf_token
47
  )
48
 
49
+ # Define your prompt template with a check for the purpose of dataset generation
50
  prompt_template = """\
51
  You are an expert in generating synthetic data for machine learning models.
52
  Your task is to generate a synthetic tabular dataset based on the description provided below.
 
54
  The dataset should include the following columns: {columns}
55
  Please provide the data in CSV format with a minimum of 100 rows per generation.
56
  Ensure that the data is realistic, does not contain any duplicate rows, and follows any specific conditions mentioned.
57
+ If the description is not related to generating synthetic datasets, please return the message: "This request is not for generating synthetic datasets."
58
  Example Description:
59
  Generate a dataset for predicting house prices with columns: 'Size', 'Location', 'Number of Bedrooms', 'Price'
60
  Example Output:
 
144
  if "Error" in generated_data:
145
  return JSONResponse(content={"error": generated_data}, status_code=500)
146
 
147
+ # Check if the model generated a message about incorrect purpose
148
+ if "This request is not for generating synthetic datasets." in generated_data:
149
+ return JSONResponse(content={"message": "This request is not for generating synthetic datasets."}, status_code=400)
150
+
151
  # Process the generated CSV data into a DataFrame
152
  df_synthetic = process_generated_data(generated_data)
153
  return JSONResponse(content={"data": df_synthetic.to_dict(orient="records")})
154
 
 
 
155
  @app.get("/")
156
  def greet_json():
157
+ return {"Hello": "World!"}