Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ if not hf_token:
|
|
| 11 |
raise ValueError("Hugging Face API token is not set. Please set the HF_API_TOKEN environment variable.")
|
| 12 |
|
| 13 |
# Set the inference endpoint URL
|
| 14 |
-
|
| 15 |
|
| 16 |
# Define your prompt template
|
| 17 |
prompt_template = """\
|
|
@@ -43,12 +43,17 @@ def format_prompt(description, columns):
|
|
| 43 |
prompt = prompt_template.format(description=processed_description, columns=",".join(columns))
|
| 44 |
return prompt
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
def generate_synthetic_data(description, columns):
|
| 47 |
try:
|
| 48 |
# Format the prompt
|
| 49 |
formatted_prompt = format_prompt(description, columns)
|
| 50 |
|
| 51 |
-
# Send a POST request to the
|
| 52 |
headers = {
|
| 53 |
"Authorization": f"Bearer {hf_token}",
|
| 54 |
"Content-Type": "application/json"
|
|
@@ -68,13 +73,14 @@ def generate_synthetic_data(description, columns):
|
|
| 68 |
return f"Error: {response.status_code}, {response.text}"
|
| 69 |
|
| 70 |
# Extract the generated text from the response
|
| 71 |
-
generated_text = response.json()[
|
| 72 |
return generated_text
|
| 73 |
|
| 74 |
except Exception as e:
|
| 75 |
print(f"Error in generate_synthetic_data: {e}")
|
| 76 |
return f"Error: {e}"
|
| 77 |
|
|
|
|
| 78 |
def generate_large_synthetic_data(description, columns, num_rows=1000, rows_per_generation=100):
|
| 79 |
data_frames = []
|
| 80 |
num_iterations = num_rows // rows_per_generation
|
|
|
|
| 11 |
raise ValueError("Hugging Face API token is not set. Please set the HF_API_TOKEN environment variable.")
|
| 12 |
|
| 13 |
# Set the inference endpoint URL
|
| 14 |
+
|
| 15 |
|
| 16 |
# Define your prompt template
|
| 17 |
prompt_template = """\
|
|
|
|
| 43 |
prompt = prompt_template.format(description=processed_description, columns=",".join(columns))
|
| 44 |
return prompt
|
| 45 |
|
| 46 |
+
import requests
|
| 47 |
+
|
| 48 |
+
# Define your Streamlit Space inference URL
|
| 49 |
+
inference_endpoint = "https://yakine-llama31.hf.space/predict"
|
| 50 |
+
|
| 51 |
def generate_synthetic_data(description, columns):
|
| 52 |
try:
|
| 53 |
# Format the prompt
|
| 54 |
formatted_prompt = format_prompt(description, columns)
|
| 55 |
|
| 56 |
+
# Send a POST request to the Streamlit Space API
|
| 57 |
headers = {
|
| 58 |
"Authorization": f"Bearer {hf_token}",
|
| 59 |
"Content-Type": "application/json"
|
|
|
|
| 73 |
return f"Error: {response.status_code}, {response.text}"
|
| 74 |
|
| 75 |
# Extract the generated text from the response
|
| 76 |
+
generated_text = response.json()['data'] # Adjust based on your Streamlit Space response structure
|
| 77 |
return generated_text
|
| 78 |
|
| 79 |
except Exception as e:
|
| 80 |
print(f"Error in generate_synthetic_data: {e}")
|
| 81 |
return f"Error: {e}"
|
| 82 |
|
| 83 |
+
|
| 84 |
def generate_large_synthetic_data(description, columns, num_rows=1000, rows_per_generation=100):
|
| 85 |
data_frames = []
|
| 86 |
num_iterations = num_rows // rows_per_generation
|