|
|
import gradio as gr |
|
|
import openai |
|
|
|
|
|
css = """ |
|
|
body { |
|
|
background-color: transparent; |
|
|
} |
|
|
""" |
|
|
|
|
|
def Question(OpenAI_Key, Ask_Question): |
|
|
|
|
|
openai.api_key = OpenAI_Key |
|
|
|
|
|
model_engine = "text-davinci-003" |
|
|
|
|
|
completion = openai.Completion.create( |
|
|
engine=model_engine, |
|
|
prompt=(f"{Ask_Question}"), |
|
|
max_tokens=1024, |
|
|
n=1, |
|
|
stop=None, |
|
|
temperature=0.5,) |
|
|
response = completion.choices[0].text |
|
|
return response |
|
|
|
|
|
demo = gr.Interface( |
|
|
title='Elvire. AI Forest Oracle', |
|
|
fn=Question, |
|
|
inputs=["text", "text"], |
|
|
outputs="text", |
|
|
css=css) |
|
|
|
|
|
demo.launch() |