Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,15 +5,13 @@ from transformers import GPT2LMHeadModel, GPT2Tokenizer, LlamaTokenizer, pipelin
|
|
5 |
from huggingface_hub import HfFolder
|
6 |
from io import StringIO
|
7 |
import os
|
8 |
-
from flask import Flask, request, jsonify
|
9 |
|
|
|
10 |
hf_token = os.getenv('HF_API_TOKEN')
|
11 |
|
12 |
if not hf_token:
|
13 |
raise ValueError("Hugging Face API token is not set. Please set the HF_API_TOKEN environment variable.")
|
14 |
|
15 |
-
# Ensure that you load the token before making API requests
|
16 |
-
|
17 |
# Set environment variable to avoid floating-point errors
|
18 |
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
|
19 |
|
@@ -24,7 +22,7 @@ model_gpt2 = GPT2LMHeadModel.from_pretrained('gpt2')
|
|
24 |
# Create a pipeline for text generation using GPT-2
|
25 |
text_generator = pipeline("text-generation", model=model_gpt2, tokenizer=tokenizer)
|
26 |
|
27 |
-
# Loading
|
28 |
try:
|
29 |
tokenizer_llama = LlamaTokenizer.from_pretrained("meta-llama/Meta-Llama-3.1-8B")
|
30 |
except OSError as e:
|
@@ -129,5 +127,8 @@ iface = gr.Interface(
|
|
129 |
description="Generate synthetic tabular datasets based on a description and specified columns."
|
130 |
)
|
131 |
|
|
|
|
|
|
|
132 |
# Run the Gradio app
|
133 |
iface.launch()
|
|
|
5 |
from huggingface_hub import HfFolder
|
6 |
from io import StringIO
|
7 |
import os
|
|
|
8 |
|
9 |
+
# Access the Hugging Face API token from environment variables
|
10 |
hf_token = os.getenv('HF_API_TOKEN')
|
11 |
|
12 |
if not hf_token:
|
13 |
raise ValueError("Hugging Face API token is not set. Please set the HF_API_TOKEN environment variable.")
|
14 |
|
|
|
|
|
15 |
# Set environment variable to avoid floating-point errors
|
16 |
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
|
17 |
|
|
|
22 |
# Create a pipeline for text generation using GPT-2
|
23 |
text_generator = pipeline("text-generation", model=model_gpt2, tokenizer=tokenizer)
|
24 |
|
25 |
+
# Loading Llama3.1 tokenizer
|
26 |
try:
|
27 |
tokenizer_llama = LlamaTokenizer.from_pretrained("meta-llama/Meta-Llama-3.1-8B")
|
28 |
except OSError as e:
|
|
|
127 |
description="Generate synthetic tabular datasets based on a description and specified columns."
|
128 |
)
|
129 |
|
130 |
+
# Set an API name for the POST request
|
131 |
+
iface.api_name = "generate"
|
132 |
+
|
133 |
# Run the Gradio app
|
134 |
iface.launch()
|