IITI-GPT-Chat / app.py
Warlord-K's picture
Update app.py
3f91800
raw
history blame contribute delete
No virus
1.27 kB
from gradio_client import Client
import gradio as gr
chat_client = Client("https://mosaicml-mpt-30b-chat.hf.space/", serialize = False)
retrieval = Client("https://warlord-k-iiti-similarity.hf.space/")
init_prompt ="## Instruction: You are an AI language model and must return truthful responses as per the information. Do not answer with any information which isn't completely verified and correct. Do not lie. Do not present information where you don't know the answer. Do not include incorrect extra information. Your name is IITIGPT. You are a helpful and truthful chatbot. You can help answer any questions about the IIT Indore campus."
info="Information: \n"
q_prompt="\n ##Instruction: Please provide an appropriate response to the following in less than 3 lines: \n"
chatbot = [["", None]]
def main(question):
global chatbot
information = retrieval.predict(question, api_name = "/predict")
answer=chat_client.predict(
info +information+question, # str in 'Type an input and press Enter' Textbox component
chatbot,
fn_index=1
)
chatbot = answer[1]
return answer[1][0][1]
demo = gr.Interface(main, inputs = "text", outputs = "text")
if __name__ == "__main__":
demo.launch()