File size: 1,004 Bytes
5349b4b
 
 
 
 
 
912877f
e165190
58793fb
912877f
6620de1
 
2a93774
a6d35dd
912877f
 
58793fb
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#Working!!!
#url = 'https://binqiangliu-fastapi-in-docker.hf.space/api/chat'
#data = {'user_question': "Tell me a joke"}
#response = requests.post(url, json=data)
#result = response.json()

import requests
import streamlit as st

def call_chatbot_api(query):
    #url = 'https://binqiangliu-fastapi-in-docker.hf.space/api/chat'
    url = 'https://binqiangliu-officialusinositechatv1api.hf.space/api/chat'
    json_data_for_api = {'user_question': query}
    response = requests.post(url, json=json_data_for_api) 
    result = response.json()
    return result['response']
    
user_query = st.text_input("Enter your query here:")
with st.spinner("AI Thinking...Please wait a while to Cheers!"):    
    if user_query !="" and not user_query.strip().isspace() and not user_query == "" and not user_query.strip() == "" and not user_query.isspace():
        response = call_chatbot_api(user_query)
        st.write("AI Response:")
        st.write(response)
        print(response)  # 打印Chatbot的响应