Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,8 @@
|
|
1 |
-
import gradio as gr
|
2 |
import streamlit as st
|
3 |
-
import requests
|
4 |
from gradio_client import Client
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
st.title('Digital Ink')
|
11 |
-
|
12 |
-
|
13 |
|
14 |
# Initialize chat history
|
15 |
if "messages" not in st.session_state:
|
@@ -20,17 +13,19 @@ for message in st.session_state.messages:
|
|
20 |
with st.chat_message(message["role"]):
|
21 |
st.markdown(message["content"])
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
26 |
return response
|
27 |
|
28 |
-
# User input
|
29 |
-
if prompt := st.chat_input("
|
30 |
# Display user message in chat message container
|
31 |
with st.chat_message("user"):
|
32 |
st.markdown(prompt)
|
33 |
# Generate and display assistant response in chat message container
|
34 |
with st.chat_message("assistant"):
|
35 |
-
response =
|
36 |
st.markdown(response)
|
|
|
|
|
1 |
import streamlit as st
|
|
|
2 |
from gradio_client import Client
|
3 |
|
4 |
+
#connecting to the URL
|
5 |
+
client = Client("https://f77c234af73e4f6a6f.gradio.live/")
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Initialize chat history
|
8 |
if "messages" not in st.session_state:
|
|
|
13 |
with st.chat_message(message["role"]):
|
14 |
st.markdown(message["content"])
|
15 |
|
16 |
+
# Function for generating responses
|
17 |
+
def generate_response(message, model, tokenizer):
|
18 |
+
st.session_state.messages.append({"role": "user", "content": message})
|
19 |
+
response = client.predict(message=message,api_name="/predict")
|
20 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|
21 |
return response
|
22 |
|
23 |
+
# User input with placeholder
|
24 |
+
if prompt := st.chat_input("Create with Digital Ink.."):
|
25 |
# Display user message in chat message container
|
26 |
with st.chat_message("user"):
|
27 |
st.markdown(prompt)
|
28 |
# Generate and display assistant response in chat message container
|
29 |
with st.chat_message("assistant"):
|
30 |
+
response = generate_response(prompt)
|
31 |
st.markdown(response)
|