ncert-helper / app.py
ishaan-mital's picture
initial commit
4d82c20
raw
history blame
1.31 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://ishaan-mital-ncert-helper-vector-db.hf.space/--replicas/149bg26k5/")
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 NCERT-Helper. You are a helpful and truthful chatbot. You can help create questions(MCQs) for students in their 11th and 12th standard CBSE Board."
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()