Pooja P commited on
Commit
70b1905
·
1 Parent(s): 631ceba

Add application file

Browse files
Files changed (2) hide show
  1. app.py +18 -0
  2. requirments.txt +2 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import openai
3
+ import os
4
+
5
+ openai.api_key = os.environ["OPENAI_API_KEY"]
6
+
7
+ def generate_blog(topic):
8
+ response = openai.ChatCompletion.create(
9
+ model="gpt-3.5-turbo",
10
+ messages=[
11
+ { "role": "system", "content": "You are a blog writer AI." },
12
+ { "role": "user", "content": f"Write a blog on: {topic}" }
13
+ ]
14
+ )
15
+ return response.choices[0].message.content
16
+
17
+ iface = gr.Interface(fn=generate_blog, inputs="text", outputs="text", title="Blog Generator AI")
18
+ iface.launch()
requirments.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ openai
2
+ gradio