mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-18 18:12:15 +00:00
Update notification service
This commit is contained in:
@@ -152,6 +152,10 @@ class AIProvider(ABC):
|
|||||||
import urllib.request
|
import urllib.request
|
||||||
import urllib.error
|
import urllib.error
|
||||||
|
|
||||||
|
# Ensure User-Agent is set (Cloudflare blocks requests without it - error 1010)
|
||||||
|
if 'User-Agent' not in headers:
|
||||||
|
headers['User-Agent'] = 'ProxMenux/1.0'
|
||||||
|
|
||||||
data = json.dumps(payload).encode('utf-8')
|
data = json.dumps(payload).encode('utf-8')
|
||||||
req = urllib.request.Request(url, data=data, headers=headers, method='POST')
|
req = urllib.request.Request(url, data=data, headers=headers, method='POST')
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class GeminiProvider(AIProvider):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
url = f"{self.API_BASE}?key={self.api_key}"
|
url = f"{self.API_BASE}?key={self.api_key}"
|
||||||
req = urllib.request.Request(url, method='GET')
|
req = urllib.request.Request(url, method='GET', headers={'User-Agent': 'ProxMenux/1.0'})
|
||||||
|
|
||||||
with urllib.request.urlopen(req, timeout=10) as resp:
|
with urllib.request.urlopen(req, timeout=10) as resp:
|
||||||
data = json.loads(resp.read().decode('utf-8'))
|
data = json.loads(resp.read().decode('utf-8'))
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ class GroqProvider(AIProvider):
|
|||||||
try:
|
try:
|
||||||
req = urllib.request.Request(
|
req = urllib.request.Request(
|
||||||
self.MODELS_URL,
|
self.MODELS_URL,
|
||||||
headers={'Authorization': f'Bearer {self.api_key}'},
|
headers={
|
||||||
|
'Authorization': f'Bearer {self.api_key}',
|
||||||
|
'User-Agent': 'ProxMenux/1.0' # Cloudflare blocks requests without User-Agent
|
||||||
|
},
|
||||||
method='GET'
|
method='GET'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class OllamaProvider(AIProvider):
|
|||||||
# First check if server is running
|
# First check if server is running
|
||||||
try:
|
try:
|
||||||
url = f"{self.base_url.rstrip('/')}/api/tags"
|
url = f"{self.base_url.rstrip('/')}/api/tags"
|
||||||
req = urllib.request.Request(url, method='GET')
|
req = urllib.request.Request(url, method='GET', headers={'User-Agent': 'ProxMenux/1.0'})
|
||||||
with urllib.request.urlopen(req, timeout=5) as resp:
|
with urllib.request.urlopen(req, timeout=5) as resp:
|
||||||
data = json.loads(resp.read().decode('utf-8'))
|
data = json.loads(resp.read().decode('utf-8'))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user