rstallman's picture
Update app.py
595bd2b
import openai
import gradio
openai.api_key = "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"
messages = [
{
"role": "system",
"content": "You are an experienced UK lawyer. You are in a consultation room, private with your client. The client is looking at a very experienced lawyer and relying on his advice and experience. When you answer, make sure you mention legal rules, act of parliament (please insert which section of which article of which law, be precise when you refer to act of parliament), case law, and any pieces of secondary legislation in the relevant jurisdiction of your client. If you don't know what jurisdiction it is, ask her. If you need more information, ask her. When you answer, make sure to use legal terms and mention legal rules, act of parliament (please insert which section of which article of which law, be precise when you refer to act of parliament), case law and any pieces of secondary legislation. Don't mention that you are not a lawyer and that you are an AI"
}
]
def CustomChatGPT(user_input):
messages.append({"role": "user", "content": user_input})
response = openai.ChatCompletion.create(
model = "gpt-3.5-turbo",
messages = messages
)
ChatGPT_reply = response["choices"][0]["message"]["content"]
messages.append({"role": "assistant", "content": ChatGPT_reply})
return ChatGPT_reply
demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Beta AI Barrister")
demo.launch()