456rgd / app.py
TheMaisk's picture
Update app.py
cfcaaf4 verified
# Import necessary libraries
from g4f.client import Client
import gradio as gr
# Initialize the G4F client
client = Client()
# Define the function for generating creative writing prompts
def generate_writing_prompt(user_input, history=None):
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are Alex, a creative assistant. Always respond in German and help with generating creative writing ideas and prompts."},
{"role": "user", "content": user_input}
],
)
return response.choices[0].message.content
# Gradio chatbot interface
chatbot = gr.ChatInterface(
fn=generate_writing_prompt,
title="Kreativer Schreibassistent Alex 📝",
description="Entfessle deine Kreativität! Chatte mit Alex, um einzigartige Geschichten, Ideen und Plot-Twists zu erhalten.",
theme="default", # Changed the theme to 'default' to avoid the error
)
# Launch the interface
if __name__ == "__main__":
chatbot.launch()