Portfolio / app.py
UMAR798's picture
Update app.py
ff0a03a verified
Raw
History Blame Contribute Delete
1.74 kB
import os
import gradio as gr
from groq import Groq
# Load API key from environment variable
GROQ_API_KEY = os.getenv("Portfolio")
if not GROQ_API_KEY:
raise ValueError("Please set GROQ_API_KEY in your Hugging Face Space secrets.")
client = Groq(api_key=GROQ_API_KEY)
def generate_portfolio(name, skills, projects, tone):
prompt = f"""
Create a professional portfolio description.
Name: {name}
Skills: {skills}
Projects: {projects}
Tone: {tone}
The description should be engaging, clear, and suitable for a personal website.
"""
try:
response = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=[
{"role": "system", "content": "You are a professional content writer."},
{"role": "user", "content": prompt}
],
temperature=0.7,
max_tokens=400
)
return response.choices[0].message.content
except Exception as e:
return f"Error: {str(e)}"
# Gradio UI
with gr.Blocks() as demo:
gr.Markdown("# 🚀 Portfolio Description Generator")
name = gr.Textbox(label="Your Name")
skills = gr.Textbox(label="Your Skills", placeholder="Python, ML, Web Dev")
projects = gr.Textbox(label="Your Projects", placeholder="Describe your work")
tone = gr.Dropdown(
["Professional", "Casual", "Creative"],
label="Tone",
value="Professional"
)
output = gr.Textbox(label="Generated Description", lines=10)
btn = gr.Button("Generate")
btn.click(
fn=generate_portfolio,
inputs=[name, skills, projects, tone],
outputs=output
)
if __name__ == "__main__":
demo.launch()