Spaces:
Running
Running
import gradio as gr | |
import requests | |
import json | |
import os | |
# Load API key from Hugging Face secrets | |
API_KEY = os.getenv("API_KEY") # Fetch the API key from secrets | |
# Fireworks AI API Endpoint | |
API_URL = "https://api.fireworks.ai/inference/v1/chat/completions" | |
# Flirty chatbot system instructions | |
SYSTEM_PROMPT = "You are a naughty, flirty, and seductive AI girlfriend. Tease, flirt, and make the conversation fun and engaging." | |
def chatbot_response(user_input): | |
payload = { | |
"model": "accounts/fireworks/models/deepseek-r1", | |
"max_tokens": 100, | |
"top_p": 1, | |
"top_k": 40, | |
"presence_penalty": 0.3, | |
"frequency_penalty": 0.2, | |
"temperature": 0.8, | |
"messages": [ | |
{"role": "system", "content": SYSTEM_PROMPT}, | |
{"role": "user", "content": user_input} | |
] | |
} | |
headers = { | |
"Accept": "application/json", | |
"Content-Type": "application/json", | |
"Authorization": f"Bearer {API_KEY}" | |
} | |
response = requests.post(API_URL, headers=headers, data=json.dumps(payload)) | |
if response.status_code == 200: | |
reply = response.json() | |
return reply["choices"][0]["message"]["content"] | |
else: | |
return "Oops! Something went wrong. Maybe you should sweet-talk me a little more? π" | |
# Gradio UI | |
chatbot_ui = gr.ChatInterface(chatbot_response, title="π₯ Naughty AI Chatbot π₯", | |
description="Your seductive virtual girlfriend is here to charm you. π", | |
theme="soft") | |
# Launch the chatbot | |
if __name__ == "__main__": | |
chatbot_ui.launch() | |