Spaces:
Runtime error
Runtime error
Change fn index
Browse files
app.py
CHANGED
@@ -1,49 +1,26 @@
|
|
1 |
from gradio_client import Client
|
2 |
-
from hugchat import hugchat
|
3 |
-
from hugchat.login import Login
|
4 |
-
import json
|
5 |
import gradio as gr
|
6 |
|
7 |
-
chat_client = Client("https://mosaicml-mpt-30b-chat.hf.space/")
|
8 |
|
9 |
|
10 |
retrieval = Client("https://slycat-southampton-similarity.hf.space/")
|
11 |
|
12 |
-
|
13 |
-
## Instruction: You are an AI language model and must return truthful responses as per the information below\n ##Input: Information: Your name is IITIGPT. You are a helpful and truthful chatbot. You can help answer any questions about the IIT Indore campus."
|
14 |
-
init_prompt =""
|
15 |
info="Information: \n"
|
16 |
-
q_prompt="\n ##Instruction: Please
|
17 |
|
18 |
-
|
19 |
-
def change_conv():
|
20 |
-
# Create a new conversation
|
21 |
-
id = chatbot.new_conversation()
|
22 |
-
chatbot.change_conversation(id)
|
23 |
-
chatbot.chat(init_prompt)
|
24 |
-
chatbot.cookies = {}
|
25 |
|
26 |
def main(question):
|
27 |
-
global
|
28 |
-
# if(n_conv > 3):
|
29 |
-
# n_conv = 0
|
30 |
-
# change_conv(chatbot)
|
31 |
information = retrieval.predict(question, api_name = "/predict")
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
fn_index=3
|
40 |
-
)
|
41 |
-
|
42 |
-
n_conv+=1
|
43 |
-
print(result)
|
44 |
-
|
45 |
-
|
46 |
-
return result
|
47 |
|
48 |
|
49 |
demo = gr.Interface(main,"text","text")
|
|
|
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 |
|
6 |
|
7 |
retrieval = Client("https://slycat-southampton-similarity.hf.space/")
|
8 |
|
9 |
+
chatbot = [["", None]]
|
|
|
|
|
10 |
info="Information: \n"
|
11 |
+
q_prompt="\n ##Instruction: Please provide an appropriate response to the following in less than 3 lines: \n"
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
def main(question):
|
15 |
+
global chatbot
|
|
|
|
|
|
|
16 |
information = retrieval.predict(question, api_name = "/predict")
|
17 |
+
answer=chat_client.predict(
|
18 |
+
info +information+question, # str in 'Type an input and press Enter' Textbox component
|
19 |
+
chatbot,
|
20 |
+
fn_index=1
|
21 |
+
)
|
22 |
+
chatbot = answer[1]
|
23 |
+
return answer[1][0][1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
|
26 |
demo = gr.Interface(main,"text","text")
|