File size: 1,735 Bytes
b7526f0
 
 
 
 
5357451
b7526f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ff0a03a
b7526f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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()