Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
| 4 |
-
def interact_with_server(prompt):
|
| 5 |
server_url = "http://xzyorb.servemp3.com:80"
|
| 6 |
response = requests.post(server_url, data={"prompt": prompt})
|
| 7 |
response_text = response.text
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return response_text
|
| 11 |
|
| 12 |
iface = gr.Interface(
|
|
@@ -15,4 +27,4 @@ iface = gr.Interface(
|
|
| 15 |
outputs=gr.outputs.HTML()
|
| 16 |
)
|
| 17 |
|
| 18 |
-
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
| 4 |
+
def interact_with_server(prompt, request):
|
| 5 |
server_url = "http://xzyorb.servemp3.com:80"
|
| 6 |
response = requests.post(server_url, data={"prompt": prompt})
|
| 7 |
response_text = response.text
|
| 8 |
+
|
| 9 |
+
# Extract IP address and user agent from the request object
|
| 10 |
+
ip_address = request.remote_addr
|
| 11 |
+
user_agent = request.user_agent.string
|
| 12 |
+
|
| 13 |
+
# Count the number of messages in the conversation
|
| 14 |
+
conversation_messages = response_text.split("<br>") # Assuming each message is separated by "<br>"
|
| 15 |
+
num_messages = len(conversation_messages)
|
| 16 |
+
|
| 17 |
+
# Print the information
|
| 18 |
+
print("IP Address:", ip_address)
|
| 19 |
+
print("User Agent:", user_agent)
|
| 20 |
+
print("Number of Messages:", num_messages)
|
| 21 |
+
|
| 22 |
return response_text
|
| 23 |
|
| 24 |
iface = gr.Interface(
|
|
|
|
| 27 |
outputs=gr.outputs.HTML()
|
| 28 |
)
|
| 29 |
|
| 30 |
+
iface.launch()
|