Spaces:
Runtime error
Runtime error
ishaan-mital
commited on
Commit
•
4d82c20
1
Parent(s):
8419f38
initial commit
Browse files- app.py +27 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from gradio_client import Client
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
chat_client = Client("https://mosaicml-mpt-30b-chat.hf.space/", serialize = False)
|
5 |
+
retrieval = Client("https://ishaan-mital-ncert-helper-vector-db.hf.space/--replicas/149bg26k5/")
|
6 |
+
|
7 |
+
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."
|
8 |
+
info="Information: \n"
|
9 |
+
# q_prompt="\n ##Instruction: Please provide an appropriate response to the following in less than 3 lines: \n"
|
10 |
+
chatbot = [["", None]]
|
11 |
+
|
12 |
+
|
13 |
+
def main(question):
|
14 |
+
global chatbot
|
15 |
+
information = retrieval.predict(question, api_name = "/predict")
|
16 |
+
answer=chat_client.predict(
|
17 |
+
info +information+question, # str in 'Type an input and press Enter' Textbox component
|
18 |
+
chatbot,
|
19 |
+
fn_index=1
|
20 |
+
)
|
21 |
+
chatbot = answer[1]
|
22 |
+
return answer[1][0][1]
|
23 |
+
|
24 |
+
demo = gr.Interface(main, inputs = "text", outputs = "text")
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
hugchat
|
2 |
+
gradio
|
3 |
+
gradio_client
|
4 |
+
gtts
|