File size: 788 Bytes
c652bdc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import random
import gradio as gr
import bardapi

# Set your Secure-1PSID value to token
token = 'cQjDrFOQjkhOHHHCW54Tc7IKyphnqos-A-IpmgjVa9p3_ZFFa5Ilet-heMO8Xm3TM1Y5vw.'

def get_spaces_response(message, history):
    # Send an API request and get a response
    response = bardapi.core.Bard(token).get_answer(message)
    return response["answers"][0]["answer"]

chatbot = gr.ChatInterface(fn=get_spaces_response, 
                           inputs="text", 
                           outputs="text", 
                           title="Hugging Face Spaces Chat",
                           description="Chat with a Hugging Face Spaces model",
                           placeholder="Type your message here..."
                          )

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