constructionGPT / app.py
cc38300's picture
Update app.py
797a7d6
raw
history blame
1.17 kB
import openai
import gradio as gr
import os
openai.api_key = os.environ.get('API_KEY')
# messages = [
# {"role": "system", "content": "You are an AI specialized in Canadian Construction laws and codes. Do not answer anything other than Canadian Construction related queries. You will provide references to all datapoints used."},
# ]
messages = [
{"role": "system", "content": "I want you to act as a construction safety auditor for Ontario. My first request is: I need help confirming if my work adheres to the Ontario Building Code"},
]
def chatbot(input):
if input:
messages.append({"role": "user", "content": input})
chat = openai.ChatCompletion.create(
model="gpt-3.5-turbo", messages=messages
)
reply = chat.choices[0].message.content
messages.append({"role": "assistant", "content": reply})
return reply
inputs = gr.inputs.Textbox(lines=7, label="Chat with AI")
outputs = gr.outputs.Textbox(label="Reply")
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="ConstructionGPT",
description="Ask anything you want",
theme="compact").launch(share=False)