|
import gradio as gr |
|
import openai |
|
import os |
|
|
|
openai.api_key = os.environ["OPENAI_KEY"] |
|
|
|
def answer_question(question): |
|
response = openai.Completion.create( |
|
engine="text-davinci-002", |
|
prompt="GIven this description of an officer and an incident help me write and incident report to report this officer: " + question, |
|
max_tokens=1024, |
|
n=1, |
|
stop=None, |
|
temperature=0.7, |
|
).get("choices")[0].text |
|
return response |
|
|
|
iface = gr.Interface(answer_question, |
|
inputs="text", outputs="text", |
|
title="Incident report generator ", |
|
description="Describe any police encounter and the officer and this will generate an incident report.") |
|
|
|
iface.launch() |