File size: 1,127 Bytes
12165fa
8d800b4
b19ea6f
cbd0d8e
d220f20
ce8de27
ada2a35
 
 
 
 
 
 
 
 
 
cbd0d8e
685e001
cbd0d8e
 
 
ada2a35
 
cbd0d8e
 
ada2a35
 
 
 
 
cbd0d8e
ada2a35
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
import streamlit as st
from gradio_client import Client

#connecting to the URL
client = Client("https://3c6d10d84bae52d4c7.gradio.live/")
st.title('Digital Ink')

# Initialize chat history
if "messages" not in st.session_state:
    st.session_state.messages = []

# Display chat messages from history
for message in st.session_state.messages:
    with st.chat_message(message["role"]):
        st.markdown(message["content"])

# Function for generating responses
def generate_response(message):
    st.session_state.messages.append({"role": "user", "content": message})
    response = client.predict(message=message,api_name="/predict")
    st.session_state.messages.append({"role": "assistant", "content": response})
    return response

# User input with placeholder
if prompt := st.chat_input("Create with Digital Ink.."):
    # Display user message in chat message container
    with st.chat_message("user"):
        st.markdown(prompt)
    # Generate and display assistant response in chat message container
    with st.chat_message("assistant"):
        response = generate_response(prompt)
        st.markdown(response)