Mbonea commited on
Commit
f82fb89
·
1 Parent(s): 432b599
Files changed (1) hide show
  1. App/Chat/PoeChatrouter.py +16 -23
App/Chat/PoeChatrouter.py CHANGED
@@ -12,38 +12,28 @@ from ballyregan import ProxyFetcher
12
 
13
  chat_router = APIRouter(tags=["Chat"])
14
  proxy = ""
 
 
 
 
 
 
 
 
 
 
 
15
 
16
 
17
  class InputData(BaseModel):
18
  input: dict
19
  version: str = "727e49a643e999d602a896c774a0658ffefea21465756a6ce24b7ea4165eba6a"
 
20
 
21
 
22
  async def fetch_predictions(data):
23
- global proxy
24
- proxies = []
25
  proxy_set = proxy != ""
26
- loop = None
27
- if not asyncio.get_event_loop().is_running():
28
- # If not, create a new event loop
29
- loop = asyncio.new_event_loop()
30
- asyncio.set_event_loop(loop)
31
- else:
32
- # If an event loop is already running, use the current one
33
- loop = asyncio.get_event_loop()
34
-
35
- if not proxy_set:
36
- try:
37
- fetcher = ProxyFetcher()
38
- fetcher.loop = loop
39
- proxies = fetcher.get(
40
- limit=10,
41
- protocols=[Protocols.HTTP],
42
- anonymities=[Anonymities.ELITE],
43
- )
44
- except Exception as e:
45
- print("Error getting proxies", e)
46
-
47
  async with ClientSession() as session:
48
  for p in proxies:
49
  if proxy_set:
@@ -68,6 +58,9 @@ async def fetch_predictions(data):
68
 
69
  @chat_router.post("/predictions")
70
  async def get_predictions(input_data: InputData):
 
 
 
71
  data = {
72
  "input": input_data.input,
73
  "is_training": False,
 
12
 
13
  chat_router = APIRouter(tags=["Chat"])
14
  proxy = ""
15
+ proxies = [
16
+ "http://51.89.14.70:80",
17
+ "http://52.151.210.204:9002",
18
+ "http://38.180.36.19:80",
19
+ "http://38.54.79.150:80",
20
+ "https://80.91.26.137:3128",
21
+ "http://82.223.102.92:9443",
22
+ "http://189.240.60.166:9090",
23
+ "https://189.240.60.168:9090",
24
+ "http://189.240.60.171:9090",
25
+ ]
26
 
27
 
28
  class InputData(BaseModel):
29
  input: dict
30
  version: str = "727e49a643e999d602a896c774a0658ffefea21465756a6ce24b7ea4165eba6a"
31
+ proxies: list[str] = []
32
 
33
 
34
  async def fetch_predictions(data):
35
+ global proxy, proxies
 
36
  proxy_set = proxy != ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  async with ClientSession() as session:
38
  for p in proxies:
39
  if proxy_set:
 
58
 
59
  @chat_router.post("/predictions")
60
  async def get_predictions(input_data: InputData):
61
+ global proxies
62
+ if input_data.proxies != []:
63
+ proxies = input_data.proxies
64
  data = {
65
  "input": input_data.input,
66
  "is_training": False,