TheMaisk commited on
Commit
e25b98f
·
verified ·
1 Parent(s): 59e51f6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Import necessary libraries
2
+ from g4f.client import Client
3
+ import gradio as gr
4
+
5
+ # Initialize the G4F client
6
+ client = Client()
7
+
8
+ # Define the function for generating creative writing prompts
9
+ def generate_writing_prompt(user_input):
10
+ response = client.chat.completions.create(
11
+ model="gpt-3.5-turbo",
12
+ messages=[{"role": "user", "content": user_input}],
13
+ )
14
+ return response.choices[0].message.content
15
+
16
+ # Gradio userinterface...
17
+ interface = gr.Interface(
18
+ fn=generate_writing_prompt,
19
+ inputs=gr.Textbox(lines=3, placeholder="Enter a genre, tone, or initial plot point..."),
20
+ outputs="text",
21
+ title="Creative Writing Assistant 📝",
22
+ description="Unleash your creativity! Get inspired with unique story ideas, prompts, and plot twists.",
23
+ theme="huggingface",
24
+ examples=[
25
+ ["A story about a lost civilization discovering technology."],
26
+ ["Compose a poem about the changing seasons."],
27
+ ["A suspense thriller set in an abandoned mansion."],
28
+ ]
29
+ )
30
+
31
+
32
+ # Launch the interface
33
+ if __name__ == "__main__":
34
+ interface.launch()