Spaces:
Running
Running
fix
Browse files- anycoder_app/ui.py +18 -0
- requirements.txt +2 -0
anycoder_app/ui.py
CHANGED
|
@@ -6,6 +6,24 @@ import os
|
|
| 6 |
import gradio as gr
|
| 7 |
from typing import Dict, Optional
|
| 8 |
from huggingface_hub import HfApi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
from .config import (
|
| 11 |
AVAILABLE_MODELS, DEFAULT_MODEL, DEFAULT_MODEL_NAME,
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
from typing import Dict, Optional
|
| 8 |
from huggingface_hub import HfApi
|
| 9 |
+
import httpx
|
| 10 |
+
|
| 11 |
+
# Monkey-patch httpx to increase timeout for OAuth
|
| 12 |
+
# This prevents ReadTimeout errors during HuggingFace OAuth flow
|
| 13 |
+
_original_client_init = httpx.AsyncClient.__init__
|
| 14 |
+
|
| 15 |
+
def _patched_client_init(self, *args, **kwargs):
|
| 16 |
+
# If no timeout is specified, use longer timeouts
|
| 17 |
+
if 'timeout' not in kwargs:
|
| 18 |
+
kwargs['timeout'] = httpx.Timeout(
|
| 19 |
+
connect=30.0, # 30 seconds for connection
|
| 20 |
+
read=60.0, # 60 seconds for reading response (increased from default 5s)
|
| 21 |
+
write=30.0, # 30 seconds for writing
|
| 22 |
+
pool=30.0 # 30 seconds for pool operations
|
| 23 |
+
)
|
| 24 |
+
return _original_client_init(self, *args, **kwargs)
|
| 25 |
+
|
| 26 |
+
httpx.AsyncClient.__init__ = _patched_client_init
|
| 27 |
|
| 28 |
from .config import (
|
| 29 |
AVAILABLE_MODELS, DEFAULT_MODEL, DEFAULT_MODEL_NAME,
|
requirements.txt
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
git+https://github.com/huggingface/huggingface_hub.git
|
| 2 |
gradio[oauth]
|
|
|
|
|
|
|
| 3 |
PyPDF2
|
| 4 |
python-docx
|
| 5 |
pytesseract
|
|
|
|
| 1 |
git+https://github.com/huggingface/huggingface_hub.git
|
| 2 |
gradio[oauth]
|
| 3 |
+
fastapi==0.112.2
|
| 4 |
+
httpx>=0.27.0
|
| 5 |
PyPDF2
|
| 6 |
python-docx
|
| 7 |
pytesseract
|