File size: 2,498 Bytes
4ade08c d5c72cc 16a33a8 d5c72cc ec230fe d5c72cc ec230fe d5c72cc 16a33a8 d5c72cc 16a33a8 d5c72cc ec230fe 4ade08c ec230fe 4ade08c 16a33a8 ec230fe 16a33a8 |
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
import gradio as gr
from llama_cpp import Llama
from huggingface_hub import hf_hub_download
def load_model():
repo_id = "forestav/gguf_lora_model"
model_file = "unsloth.F16.gguf"
local_path = hf_hub_download(
repo_id=repo_id,
filename=model_file
)
print(f"Loading model from: {local_path}")
model = Llama(
model_path=local_path,
n_ctx=2048,
n_threads=8
)
return model
def generate_career_response(message, history):
# Enhance the prompt with career guidance context
enhanced_prompt = f"""As a career development advisor, help the user with their professional growth.
Consider:
1. Skill development opportunities
2. Industry trends
3. Practical next steps
4. Resources and learning paths
User Query: {message}
Provide a structured response with actionable advice."""
response = model.create_chat_completion(
messages=[
{"role": "system", "content": "You are a professional career advisor focused on providing practical, actionable guidance for career development."},
{"role": "user", "content": enhanced_prompt}
],
max_tokens=512,
temperature=0.7,
top_p=0.95,
)
return response['choices'][0]['message']['content']
# Load model globally
print("Starting model loading...")
model = load_model()
print("Model loaded successfully!")
# Create Gradio interface with career-focused examples
demo = gr.ChatInterface(
fn=generate_career_response,
title="Career Growth Navigator 🚀",
description="""Your AI career development partner. Ask about:
• Skill development paths
• Career transition strategies
• Industry trends and opportunities
• Resume and interview preparation
• Professional networking advice
• Work-life balance
Let's shape your professional future together!""",
examples=[
"I'm a software developer wanting to transition into AI/ML. What skills should I focus on?",
"How can I improve my leadership skills in my current role?",
"What are the key trends in digital marketing I should be aware of?",
"I want to start freelancing in web development. Where should I begin?",
"How can I negotiate a promotion in my current position?"
]
)
# Add proper Gradio launch configuration for Spaces
demo.launch(
server_name="0.0.0.0",
server_port=7860,
share=False
) |