Spaces:
Sleeping
Sleeping
File size: 739 Bytes
ce3dad7 08aa304 ce3dad7 08aa304 ce3dad7 08aa304 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import os
from huggingface_hub import InferenceClient
client = InferenceClient(
model="google/flan-t5-large",
token=os.getenv("HUGGINGFACEHUB_API_TOKEN")
)
def generate_code(prompt):
full_prompt = f"""You are a professional Python Pandas developer.
Write a complete, executable, valid Python Pandas script to perform the following task on a DataFrame named df:
Task: {prompt}
Make sure the code can be executed without any syntax errors.
Output only valid Python code. No explanation, no comments."""
response = client.text_generation(
prompt=full_prompt,
max_new_tokens=200, # Updated token limit
temperature=0.2,
top_p=0.9,
repetition_penalty=1.05
)
return response
|