| import gradio as gr | |
| import openai | |
| import os | |
| openai.api_key = os.environ["AI_API_KEY"] | |
| def make_dua(prompt): | |
| response = openai.Completion.create( | |
| engine="text-davinci-002", | |
| prompt=" Turn this prompt |: " + prompt + " | into a Splunk query ", | |
| max_tokens=1024, | |
| n=1, | |
| stop=None, | |
| temperature=0.5, | |
| ).get("choices")[0].text | |
| return response | |
| iface = gr.Interface(make_dua, | |
| gr.inputs.Textbox(lines=5, default="Find events with users who keep using the incorrect password?"), | |
| gr.outputs.Textbox(), | |
| title="Splunk Assistanr", | |
| description="Get a recomended splunk query for any of your problens.") | |
| iface.launch() |