File size: 835 Bytes
3170b9a
 
 
 
 
 
 
 
e30d93c
3170b9a
 
 
 
 
 
 
 
 
 
e30d93c
 
 
 
3170b9a
 
 
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
import streamlit as st
from huggingface_hub import InferenceClient

# Initialize the Hugging Face Inference API client
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta", token="hf_gzFQTPmbxocKx"+"wyjRVSzJMWLdHCsZyQIjz")

def send_message(message):
    messages = [{"role": "user", "content": message}]
    response = client.chat_completion(messages, max_tokens=150)
    return response

def main():
    st.title("Chat with AI")
    
    # Text area for user input
    user_input = st.text_input("Type your message:", key="user_input")
    
    if st.button("Send"):
        with st.spinner('AI is typing...'):
            response = send_message(user_input)
            # Display complete response
            for choice in response.choices:
                st.write(choice.message.content)

if __name__ == "__main__":
    main()