New file
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import openai
|
3 |
+
import os
|
4 |
+
|
5 |
+
openai.api_key = os.environ["AI_API_KEY"]
|
6 |
+
|
7 |
+
def make_dua(prompt):
|
8 |
+
response = openai.Completion.create(
|
9 |
+
engine="text-davinci-002",
|
10 |
+
prompt=" Turn this prompt |: " + prompt + " | into a Splunk query ",
|
11 |
+
max_tokens=1024,
|
12 |
+
n=1,
|
13 |
+
stop=None,
|
14 |
+
temperature=0.5,
|
15 |
+
).get("choices")[0].text
|
16 |
+
return response
|
17 |
+
|
18 |
+
iface = gr.Interface(make_dua,
|
19 |
+
gr.inputs.Textbox(lines=5, default="I am feeling overwhelmed?"),
|
20 |
+
gr.outputs.Textbox(),
|
21 |
+
title="Dua generator",
|
22 |
+
description="Get a dua based on how youre feeling.")
|
23 |
+
|
24 |
+
iface.launch()
|