Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import sys
|
|
@@ -5,6 +32,8 @@ import json
|
|
| 5 |
import requests
|
| 6 |
import random
|
| 7 |
|
|
|
|
|
|
|
| 8 |
MODEL = "o1-preview"
|
| 9 |
API_URL = os.getenv("API_URL")
|
| 10 |
DISABLED = os.getenv("DISABLED") == 'True'
|
|
|
|
| 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
|
|
|
|
| 32 |
import requests
|
| 33 |
import random
|
| 34 |
|
| 35 |
+
|
| 36 |
+
|
| 37 |
MODEL = "o1-preview"
|
| 38 |
API_URL = os.getenv("API_URL")
|
| 39 |
DISABLED = os.getenv("DISABLED") == 'True'
|