DeMaking commited on
Commit
8282e1a
·
verified ·
1 Parent(s): d0e1395

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
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
- # Configure the HTTP backend to use "requests"
9
- configure_http_backend("requests") # Set the HTTP backend to "requests"
 
 
 
 
 
 
 
 
 
 
 
 
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)