Merge pull request #11 from ZyphrZero/pre
Browse files- .gitignore +1 -0
- app/core/zai_transformer.py +8 -8
- app/utils/token_pool.py +0 -1
- pyproject.toml +2 -3
- requirements.txt +1 -2
.gitignore
CHANGED
|
@@ -5,6 +5,7 @@
|
|
| 5 |
.conda/
|
| 6 |
*.zip
|
| 7 |
*.txt
|
|
|
|
| 8 |
docs/
|
| 9 |
output/
|
| 10 |
main.build/
|
|
|
|
| 5 |
.conda/
|
| 6 |
*.zip
|
| 7 |
*.txt
|
| 8 |
+
*.pid
|
| 9 |
docs/
|
| 10 |
output/
|
| 11 |
main.build/
|
app/core/zai_transformer.py
CHANGED
|
@@ -5,7 +5,6 @@ import json
|
|
| 5 |
import time
|
| 6 |
import uuid
|
| 7 |
import random
|
| 8 |
-
import requests
|
| 9 |
from datetime import datetime
|
| 10 |
from typing import Dict, List, Any, Optional, Generator, AsyncGenerator
|
| 11 |
import httpx
|
|
@@ -105,13 +104,14 @@ def get_auth_token_sync() -> str:
|
|
| 105 |
if settings.ANONYMOUS_MODE:
|
| 106 |
try:
|
| 107 |
headers = get_dynamic_headers()
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
| 115 |
except Exception as e:
|
| 116 |
logger.warning(f"获取访客令牌失败: {e}")
|
| 117 |
|
|
|
|
| 5 |
import time
|
| 6 |
import uuid
|
| 7 |
import random
|
|
|
|
| 8 |
from datetime import datetime
|
| 9 |
from typing import Dict, List, Any, Optional, Generator, AsyncGenerator
|
| 10 |
import httpx
|
|
|
|
| 104 |
if settings.ANONYMOUS_MODE:
|
| 105 |
try:
|
| 106 |
headers = get_dynamic_headers()
|
| 107 |
+
with httpx.Client() as client:
|
| 108 |
+
response = client.get("https://chat.z.ai/api/v1/auths/", headers=headers, timeout=10.0)
|
| 109 |
+
if response.status_code == 200:
|
| 110 |
+
data = response.json()
|
| 111 |
+
token = data.get("token", "")
|
| 112 |
+
if token:
|
| 113 |
+
logger.debug(f"获取访客令牌成功: {token[:20]}...")
|
| 114 |
+
return token
|
| 115 |
except Exception as e:
|
| 116 |
logger.warning(f"获取访客令牌失败: {e}")
|
| 117 |
|
app/utils/token_pool.py
CHANGED
|
@@ -12,7 +12,6 @@ from typing import Dict, List, Optional, Tuple
|
|
| 12 |
from dataclasses import dataclass, field
|
| 13 |
from threading import Lock
|
| 14 |
import httpx
|
| 15 |
-
import requests
|
| 16 |
|
| 17 |
from app.utils.logger import logger
|
| 18 |
|
|
|
|
| 12 |
from dataclasses import dataclass, field
|
| 13 |
from threading import Lock
|
| 14 |
import httpx
|
|
|
|
| 15 |
|
| 16 |
from app.utils.logger import logger
|
| 17 |
|
pyproject.toml
CHANGED
|
@@ -24,10 +24,9 @@ classifiers = [
|
|
| 24 |
"Topic :: Software Development :: Libraries :: Python Modules",
|
| 25 |
]
|
| 26 |
dependencies = [
|
| 27 |
-
"fastapi==0.
|
| 28 |
"granian[reload,pname]==2.5.2",
|
| 29 |
-
"
|
| 30 |
-
"httpx==0.27.0",
|
| 31 |
"pydantic==2.11.7",
|
| 32 |
"pydantic-settings==2.10.1",
|
| 33 |
"pydantic-core==2.33.2",
|
|
|
|
| 24 |
"Topic :: Software Development :: Libraries :: Python Modules",
|
| 25 |
]
|
| 26 |
dependencies = [
|
| 27 |
+
"fastapi==0.116.1",
|
| 28 |
"granian[reload,pname]==2.5.2",
|
| 29 |
+
"httpx==0.28.1",
|
|
|
|
| 30 |
"pydantic==2.11.7",
|
| 31 |
"pydantic-settings==2.10.1",
|
| 32 |
"pydantic-core==2.33.2",
|
requirements.txt
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
fastapi==0.116.1
|
| 2 |
granian[reload,pname]==2.5.2
|
| 3 |
-
|
| 4 |
-
httpx==0.27.0
|
| 5 |
pydantic==2.11.7
|
| 6 |
pydantic-settings==2.10.1
|
| 7 |
pydantic-core==2.33.2
|
|
|
|
| 1 |
fastapi==0.116.1
|
| 2 |
granian[reload,pname]==2.5.2
|
| 3 |
+
httpx==0.28.1
|
|
|
|
| 4 |
pydantic==2.11.7
|
| 5 |
pydantic-settings==2.10.1
|
| 6 |
pydantic-core==2.33.2
|