Update app.py
Browse files
app.py
CHANGED
@@ -2,11 +2,23 @@ import os
|
|
2 |
import logging
|
3 |
from fastapi import FastAPI, Request
|
4 |
import subprocess
|
5 |
-
from huggingface_hub import InferenceClient, login, configure_http_backend
|
6 |
import langid
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Configure logging
|
12 |
logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s", level=logging.INFO)
|
|
|
2 |
import logging
|
3 |
from fastapi import FastAPI, Request
|
4 |
import subprocess
|
5 |
+
from huggingface_hub import InferenceClient, login, configure_http_backend, get_session
|
6 |
import langid
|
7 |
|
8 |
+
|
9 |
+
# Create a factory function that returns a requests.Session object
|
10 |
+
def backend_factory() -> requests.Session:
|
11 |
+
session = requests.Session()
|
12 |
+
# session.proxies = {"http": "http://your-proxy-host:your-proxy-port",
|
13 |
+
# "https": "http://your-proxy-host:your-proxy-port"}
|
14 |
+
return session
|
15 |
+
|
16 |
+
# Set our custom backend factory as the default HTTP backend
|
17 |
+
configure_http_backend(backend_factory=backend_factory)
|
18 |
+
|
19 |
+
# For debugging
|
20 |
+
session = get_session()
|
21 |
+
print("Configured session:", session)
|
22 |
|
23 |
# Configure logging
|
24 |
logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s", level=logging.INFO)
|