File size: 1,658 Bytes
efff7f3
 
 
 
 
 
45fc740
efff7f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e7fdac2
efff7f3
 
 
 
e9b2ef0
a326a39
 
 
 
6480db9
a326a39
 
 
efff7f3
a326a39
35b0bf4
a326a39
 
0b3eb46
a326a39
efff7f3
 
0222cad
efff7f3
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from gradio_client import Client
from hugchat import hugchat
from hugchat.login import Login
import json
import gradio as gr

chat_client = Client("https://mosaicml-mpt-30b-chat.hf.space/")


retrieval = Client("https://slycat-southampton-similarity.hf.space/")

n_conv = 0
## 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."
init_prompt =""
info="Information: \n"
q_prompt="\n ##Instruction: Please  provide an appropriate response to the following: \n"


def change_conv():
    # Create a new conversation
    id = chatbot.new_conversation()
    chatbot.change_conversation(id)
    chatbot.chat(init_prompt)
    chatbot.cookies = {}
    
def main(question):
    global n_conv
    # if(n_conv > 3):
    #     n_conv = 0
    #     change_conv(chatbot)
    information = retrieval.predict(question, api_name = "/predict")
    client = Client("https://mosaicml-mpt-30b-chat.hf.space/")
    result = chat_client.predict(
        
		"Howdy!",	# str  in 'System Prompt' Textbox component
        "new.json",
		"You are an AI language model and must return truthful responses as per the information below\n ##Input: Information: Your name is Southampton GPT. You are a helpful and truthful chatbot. You can help answer any questions about Southampton University."
        + information + question,
		fn_index=3
)

    n_conv+=1
    print(result)

    
    return result


demo = gr.Interface(main,"text","text")

if __name__ == "__main__":
    demo.launch()