Spaces:
Running
Running
File size: 1,649 Bytes
83bf094 |
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 |
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()
|