Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import openai
|
3 |
+
|
4 |
+
openai.api_key = os.environ["AI_API_KEY"]
|
5 |
+
|
6 |
+
def answer_question(question):
|
7 |
+
response = openai.Completion.create(
|
8 |
+
engine="text-davinci-002",
|
9 |
+
prompt="Make a dua based on this prompt" " + question + "". and use this format: first praise allah using one of the appropriate 99 name then say peace be upon the prophet and then make the dua for what the user wants and then end it by giving thanks to allah",
|
10 |
+
max_tokens=1024,
|
11 |
+
n=1,
|
12 |
+
stop=None,
|
13 |
+
temperature=0.5,
|
14 |
+
).get("choices")[0].text
|
15 |
+
return response
|
16 |
+
|
17 |
+
iface = gr.Interface(answer_question,
|
18 |
+
gr.inputs.Textbox(lines=5, default="I am feeling overwhelmed?"),
|
19 |
+
gr.outputs.Textbox(),
|
20 |
+
title="Dua generator",
|
21 |
+
description="Get a dua based on how youre feeling.")
|
22 |
+
|
23 |
+
iface.launch()
|