File size: 1,041 Bytes
e25b98f
 
 
 
 
 
 
 
c42d3ee
e25b98f
 
27a436f
cfcaaf4
27a436f
 
e25b98f
 
 
27a436f
 
e25b98f
27a436f
 
cfcaaf4
e25b98f
 
 
 
27a436f
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
# 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()