Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,33 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import openai
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
def Question(OpenAI_Key, Ask_Question):
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
return response
|
| 22 |
-
|
| 23 |
-
|
| 24 |
demo = gr.Interface(
|
| 25 |
title='Elvire. AI Forest Oracle',
|
| 26 |
fn=Question,
|
| 27 |
inputs=["text", "text"],
|
| 28 |
-
outputs="text",
|
|
|
|
| 29 |
|
| 30 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import openai
|
| 3 |
|
| 4 |
+
css = """
|
| 5 |
+
body {
|
| 6 |
+
background-color: transparent;
|
| 7 |
+
}
|
| 8 |
+
"""
|
| 9 |
|
| 10 |
def Question(OpenAI_Key, Ask_Question):
|
| 11 |
+
# pass the generated text to audio
|
| 12 |
+
openai.api_key = OpenAI_Key
|
| 13 |
+
# Set up the model and prompt
|
| 14 |
+
model_engine = "text-davinci-003"
|
| 15 |
+
# Generate a response
|
| 16 |
+
completion = openai.Completion.create(
|
| 17 |
+
engine=model_engine,
|
| 18 |
+
prompt=(f"{Ask_Question}"),
|
| 19 |
+
max_tokens=1024,
|
| 20 |
+
n=1,
|
| 21 |
+
stop=None,
|
| 22 |
+
temperature=0.5,)
|
| 23 |
+
response = completion.choices[0].text
|
| 24 |
+
return response
|
| 25 |
+
|
|
|
|
|
|
|
|
|
|
| 26 |
demo = gr.Interface(
|
| 27 |
title='Elvire. AI Forest Oracle',
|
| 28 |
fn=Question,
|
| 29 |
inputs=["text", "text"],
|
| 30 |
+
outputs="text",
|
| 31 |
+
css=css)
|
| 32 |
|
| 33 |
+
demo.launch()
|