Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,3 @@
|
|
1 |
-
import os
|
2 |
-
import subprocess
|
3 |
-
import httpx
|
4 |
-
import importlib
|
5 |
-
|
6 |
-
# Get the path to the _config.py file
|
7 |
-
config_path = os.path.join(os.path.dirname(httpx.__file__), "_config.py")
|
8 |
-
|
9 |
-
# Check if the file exists
|
10 |
-
if not os.path.isfile(config_path):
|
11 |
-
raise FileNotFoundError(f"Error: {config_path} does not exist.")
|
12 |
-
|
13 |
-
# Create a backup of the original file
|
14 |
-
backup_path = f"{config_path}.bak"
|
15 |
-
subprocess.run(['cp', config_path, backup_path], check=True)
|
16 |
-
|
17 |
-
# Modify the _config.py file to update the default timeout
|
18 |
-
sed_command = f"sed -i 's/DEFAULT_TIMEOUT_CONFIG = Timeout(timeout=5.0)/DEFAULT_TIMEOUT_CONFIG = Timeout(timeout=60)/' {config_path}"
|
19 |
-
subprocess.run(sed_command, shell=True, check=True)
|
20 |
-
|
21 |
-
# Force reload of the httpx module to apply changes
|
22 |
-
importlib.reload(httpx)
|
23 |
-
|
24 |
-
print(f"Successfully modified {config_path} and backed up the original at {backup_path}.")
|
25 |
-
print("httpx module reloaded to apply changes.")
|
26 |
-
|
27 |
-
|
28 |
import gradio as gr
|
29 |
import os
|
30 |
import sys
|
@@ -119,13 +92,8 @@ def predict(inputs, top_p, temperature, chat_counter, chatbot, history, request:
|
|
119 |
counter = 0
|
120 |
|
121 |
try:
|
122 |
-
import time
|
123 |
-
time.sleep(10)
|
124 |
# make a POST request to the API endpoint using the requests.post method, passing in stream=True
|
125 |
response = requests.post(API_URL, headers=headers, json=payload, stream=True)
|
126 |
-
print ('r', response)
|
127 |
-
import sys
|
128 |
-
sys.stdout.flush()
|
129 |
response_code = f"{response}"
|
130 |
#if response_code.strip() != "<Response [200]>":
|
131 |
# #print(f"response code - {response}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import sys
|
|
|
92 |
counter = 0
|
93 |
|
94 |
try:
|
|
|
|
|
95 |
# make a POST request to the API endpoint using the requests.post method, passing in stream=True
|
96 |
response = requests.post(API_URL, headers=headers, json=payload, stream=True)
|
|
|
|
|
|
|
97 |
response_code = f"{response}"
|
98 |
#if response_code.strip() != "<Response [200]>":
|
99 |
# #print(f"response code - {response}")
|