Grey01 commited on
Commit
cbd0d8e
·
verified ·
1 Parent(s): 6c1e0f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -15
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
- ngrok_tunnel_url = "https://ngrok-python/1.4.0 ngrok-rust/0.14.0-pre.14L/predict"
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
- def get_response(prompt):
24
- response = requests.post(f"{ngrok_tunnel_url}/predict", json={"text": prompt})
25
- return response.json()["output"]
 
 
26
  return response
27
 
28
- # User input
29
- if prompt := st.chat_input("Ask Digital Ink..."):
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 = get_response(prompt)
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)