webscout 8.3.2__py3-none-any.whl → 8.3.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of webscout might be problematic. Click here for more details.
- webscout/AIutel.py +146 -37
- webscout/Bing_search.py +1 -2
- webscout/Provider/AISEARCH/__init__.py +1 -0
- webscout/Provider/AISEARCH/stellar_search.py +132 -0
- webscout/Provider/ExaChat.py +84 -58
- webscout/Provider/HeckAI.py +85 -80
- webscout/Provider/Jadve.py +56 -50
- webscout/Provider/MiniMax.py +207 -0
- webscout/Provider/Nemotron.py +41 -13
- webscout/Provider/Netwrck.py +34 -51
- webscout/Provider/OPENAI/BLACKBOXAI.py +0 -1
- webscout/Provider/OPENAI/MiniMax.py +298 -0
- webscout/Provider/OPENAI/README.md +30 -29
- webscout/Provider/OPENAI/TogetherAI.py +4 -17
- webscout/Provider/OPENAI/__init__.py +3 -1
- webscout/Provider/OPENAI/autoproxy.py +752 -17
- webscout/Provider/OPENAI/base.py +7 -76
- webscout/Provider/OPENAI/deepinfra.py +42 -108
- webscout/Provider/OPENAI/flowith.py +179 -166
- webscout/Provider/OPENAI/friendli.py +233 -0
- webscout/Provider/OPENAI/monochat.py +329 -0
- webscout/Provider/OPENAI/pydantic_imports.py +1 -172
- webscout/Provider/OPENAI/toolbaz.py +1 -0
- webscout/Provider/OPENAI/typegpt.py +1 -1
- webscout/Provider/OPENAI/utils.py +19 -42
- webscout/Provider/OPENAI/x0gpt.py +14 -2
- webscout/Provider/OpenGPT.py +54 -32
- webscout/Provider/PI.py +58 -84
- webscout/Provider/StandardInput.py +32 -13
- webscout/Provider/TTI/README.md +9 -9
- webscout/Provider/TTI/__init__.py +2 -1
- webscout/Provider/TTI/aiarta.py +92 -78
- webscout/Provider/TTI/infip.py +212 -0
- webscout/Provider/TTI/monochat.py +220 -0
- webscout/Provider/TeachAnything.py +11 -3
- webscout/Provider/TextPollinationsAI.py +78 -70
- webscout/Provider/TogetherAI.py +32 -48
- webscout/Provider/Venice.py +37 -46
- webscout/Provider/VercelAI.py +27 -24
- webscout/Provider/WiseCat.py +35 -35
- webscout/Provider/WrDoChat.py +22 -26
- webscout/Provider/WritingMate.py +26 -22
- webscout/Provider/__init__.py +2 -2
- webscout/Provider/granite.py +48 -57
- webscout/Provider/koala.py +51 -39
- webscout/Provider/learnfastai.py +49 -64
- webscout/Provider/llmchat.py +79 -93
- webscout/Provider/llmchatco.py +63 -78
- webscout/Provider/multichat.py +51 -40
- webscout/Provider/oivscode.py +1 -1
- webscout/Provider/scira_chat.py +159 -96
- webscout/Provider/scnet.py +13 -13
- webscout/Provider/searchchat.py +13 -13
- webscout/Provider/sonus.py +12 -11
- webscout/Provider/toolbaz.py +25 -8
- webscout/Provider/turboseek.py +41 -42
- webscout/Provider/typefully.py +27 -12
- webscout/Provider/typegpt.py +41 -46
- webscout/Provider/uncovr.py +55 -90
- webscout/Provider/x0gpt.py +33 -17
- webscout/Provider/yep.py +79 -96
- webscout/auth/__init__.py +12 -1
- webscout/auth/providers.py +27 -5
- webscout/auth/routes.py +128 -104
- webscout/auth/server.py +367 -312
- webscout/client.py +121 -116
- webscout/litagent/Readme.md +68 -55
- webscout/litagent/agent.py +99 -9
- webscout/version.py +1 -1
- {webscout-8.3.2.dist-info → webscout-8.3.3.dist-info}/METADATA +102 -90
- {webscout-8.3.2.dist-info → webscout-8.3.3.dist-info}/RECORD +75 -87
- webscout/Provider/TTI/fastflux.py +0 -233
- webscout/Provider/Writecream.py +0 -246
- webscout/auth/static/favicon.svg +0 -11
- webscout/auth/swagger_ui.py +0 -203
- webscout/auth/templates/components/authentication.html +0 -237
- webscout/auth/templates/components/base.html +0 -103
- webscout/auth/templates/components/endpoints.html +0 -750
- webscout/auth/templates/components/examples.html +0 -491
- webscout/auth/templates/components/footer.html +0 -75
- webscout/auth/templates/components/header.html +0 -27
- webscout/auth/templates/components/models.html +0 -286
- webscout/auth/templates/components/navigation.html +0 -70
- webscout/auth/templates/static/api.js +0 -455
- webscout/auth/templates/static/icons.js +0 -168
- webscout/auth/templates/static/main.js +0 -784
- webscout/auth/templates/static/particles.js +0 -201
- webscout/auth/templates/static/styles.css +0 -3353
- webscout/auth/templates/static/ui.js +0 -374
- webscout/auth/templates/swagger_ui.html +0 -170
- {webscout-8.3.2.dist-info → webscout-8.3.3.dist-info}/WHEEL +0 -0
- {webscout-8.3.2.dist-info → webscout-8.3.3.dist-info}/entry_points.txt +0 -0
- {webscout-8.3.2.dist-info → webscout-8.3.3.dist-info}/licenses/LICENSE.md +0 -0
- {webscout-8.3.2.dist-info → webscout-8.3.3.dist-info}/top_level.txt +0 -0
webscout/auth/providers.py
CHANGED
|
@@ -87,13 +87,13 @@ def initialize_tti_provider_map() -> None:
|
|
|
87
87
|
logger.info("Initializing TTI provider map...")
|
|
88
88
|
|
|
89
89
|
try:
|
|
90
|
-
import webscout.Provider.TTI as tti_module
|
|
91
90
|
from webscout.Provider.TTI.base import TTICompatibleProvider
|
|
92
|
-
|
|
91
|
+
module = sys.modules["webscout.Provider.TTI"]
|
|
92
|
+
|
|
93
93
|
provider_count = 0
|
|
94
94
|
model_count = 0
|
|
95
95
|
|
|
96
|
-
for name, obj in inspect.getmembers(
|
|
96
|
+
for name, obj in inspect.getmembers(module):
|
|
97
97
|
if (
|
|
98
98
|
inspect.isclass(obj)
|
|
99
99
|
and issubclass(obj, TTICompatibleProvider)
|
|
@@ -242,7 +242,18 @@ def get_provider_instance(provider_class: Any):
|
|
|
242
242
|
key = provider_class.__name__
|
|
243
243
|
instance = provider_instances.get(key)
|
|
244
244
|
if instance is None:
|
|
245
|
-
|
|
245
|
+
try:
|
|
246
|
+
instance = provider_class()
|
|
247
|
+
except TypeError as e:
|
|
248
|
+
# Handle abstract class instantiation error
|
|
249
|
+
if "abstract class" in str(e):
|
|
250
|
+
from .exceptions import APIError
|
|
251
|
+
raise APIError(
|
|
252
|
+
f"Provider misconfiguration: Cannot instantiate abstract class '{provider_class.__name__}'. Please check the provider implementation.",
|
|
253
|
+
HTTP_500_INTERNAL_SERVER_ERROR,
|
|
254
|
+
"provider_error"
|
|
255
|
+
)
|
|
256
|
+
raise
|
|
246
257
|
provider_instances[key] = instance
|
|
247
258
|
return instance
|
|
248
259
|
|
|
@@ -252,6 +263,17 @@ def get_tti_provider_instance(provider_class: Any):
|
|
|
252
263
|
key = provider_class.__name__
|
|
253
264
|
instance = tti_provider_instances.get(key)
|
|
254
265
|
if instance is None:
|
|
255
|
-
|
|
266
|
+
try:
|
|
267
|
+
instance = provider_class()
|
|
268
|
+
except TypeError as e:
|
|
269
|
+
# Handle abstract class instantiation error
|
|
270
|
+
if "abstract class" in str(e):
|
|
271
|
+
from .exceptions import APIError
|
|
272
|
+
raise APIError(
|
|
273
|
+
f"Provider misconfiguration: Cannot instantiate abstract class '{provider_class.__name__}'. Please check the provider implementation.",
|
|
274
|
+
HTTP_500_INTERNAL_SERVER_ERROR,
|
|
275
|
+
"provider_error",
|
|
276
|
+
)
|
|
277
|
+
raise
|
|
256
278
|
tti_provider_instances[key] = instance
|
|
257
279
|
return instance
|
webscout/auth/routes.py
CHANGED
|
@@ -85,114 +85,78 @@ class Api:
|
|
|
85
85
|
|
|
86
86
|
def register_validation_exception_handler(self):
|
|
87
87
|
"""Register comprehensive exception handlers."""
|
|
88
|
+
from fastapi.exceptions import RequestValidationError
|
|
89
|
+
from starlette.exceptions import HTTPException as StarletteHTTPException
|
|
90
|
+
from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY, HTTP_500_INTERNAL_SERVER_ERROR
|
|
91
|
+
from .exceptions import APIError
|
|
92
|
+
|
|
93
|
+
github_footer = "If you believe this is a bug, please pull an issue at https://github.com/OEvortex/Webscout."
|
|
88
94
|
|
|
89
95
|
@self.app.exception_handler(APIError)
|
|
90
|
-
async def api_error_handler(request
|
|
91
|
-
"""Handle custom API errors."""
|
|
96
|
+
async def api_error_handler(request, exc: APIError):
|
|
92
97
|
logger.error(f"API Error: {exc.message} (Status: {exc.status_code})")
|
|
93
|
-
|
|
98
|
+
# Patch: add footer to error content before creating JSONResponse
|
|
99
|
+
error_response = exc.to_response()
|
|
100
|
+
# If the response is a JSONResponse, patch its content dict before returning
|
|
101
|
+
if hasattr(error_response, 'body') and hasattr(error_response, 'media_type'):
|
|
102
|
+
# Try to decode the body to dict and add footer if possible
|
|
103
|
+
try:
|
|
104
|
+
import json
|
|
105
|
+
content_dict = json.loads(error_response.body.decode())
|
|
106
|
+
if "error" in content_dict:
|
|
107
|
+
content_dict["error"]["footer"] = github_footer
|
|
108
|
+
return JSONResponse(status_code=error_response.status_code, content=content_dict)
|
|
109
|
+
except Exception:
|
|
110
|
+
pass
|
|
111
|
+
return error_response
|
|
94
112
|
|
|
95
113
|
@self.app.exception_handler(RequestValidationError)
|
|
96
|
-
async def validation_exception_handler(request
|
|
114
|
+
async def validation_exception_handler(request, exc: RequestValidationError):
|
|
97
115
|
errors = exc.errors()
|
|
98
116
|
error_messages = []
|
|
99
117
|
body = await request.body()
|
|
100
118
|
is_empty_body = not body or body.strip() in (b"", b"null", b"{}")
|
|
101
|
-
|
|
102
119
|
for error in errors:
|
|
103
120
|
loc = error.get("loc", [])
|
|
104
|
-
|
|
105
|
-
loc_str_parts = []
|
|
106
|
-
for item in loc:
|
|
107
|
-
if item == "body": # Skip "body" part if it's the first element of a longer path
|
|
108
|
-
if len(loc) > 1:
|
|
109
|
-
continue
|
|
110
|
-
loc_str_parts.append(str(item))
|
|
111
|
-
loc_str = " -> ".join(loc_str_parts)
|
|
112
|
-
|
|
121
|
+
loc_str = " -> ".join(str(item) for item in loc)
|
|
113
122
|
msg = error.get("msg", "Validation error")
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
"message": f"Invalid message content: {msg}. Ensure content matches the expected format (string or list of content parts). Path: {loc_str}",
|
|
129
|
-
"type": error.get("type", "validation_error")
|
|
130
|
-
})
|
|
131
|
-
continue
|
|
132
|
-
|
|
133
|
-
if "body" in loc:
|
|
134
|
-
if len(loc) > 1 and loc[1] == "messages":
|
|
135
|
-
error_messages.append({
|
|
136
|
-
"loc": loc,
|
|
137
|
-
"message": "The 'messages' field is required and must be a non-empty array of message objects. " + f"Error: {msg} at {loc_str}",
|
|
138
|
-
"type": error.get("type", "validation_error")
|
|
139
|
-
})
|
|
140
|
-
elif len(loc) > 1 and loc[1] == "model":
|
|
141
|
-
error_messages.append({
|
|
142
|
-
"loc": loc,
|
|
143
|
-
"message": "The 'model' field is required and must be a string. " + f"Error: {msg} at {loc_str}",
|
|
144
|
-
"type": error.get("type", "validation_error")
|
|
145
|
-
})
|
|
146
|
-
else:
|
|
147
|
-
error_messages.append({
|
|
148
|
-
"loc": loc,
|
|
149
|
-
"message": f"{msg} at {loc_str}",
|
|
150
|
-
"type": error.get("type", "validation_error")
|
|
151
|
-
})
|
|
152
|
-
else:
|
|
153
|
-
error_messages.append({
|
|
154
|
-
"loc": loc,
|
|
155
|
-
"message": f"{msg} at {loc_str}",
|
|
156
|
-
"type": error.get("type", "validation_error")
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
if request.url.path == "/v1/chat/completions":
|
|
160
|
-
example = ChatCompletionRequest.Config.schema_extra["example"]
|
|
161
|
-
if is_empty_body:
|
|
162
|
-
return JSONResponse(
|
|
163
|
-
status_code=HTTP_422_UNPROCESSABLE_ENTITY,
|
|
164
|
-
content={
|
|
165
|
-
"error": {
|
|
166
|
-
"message": "Request body is required and must include 'model' and 'messages'.",
|
|
167
|
-
"type": "invalid_request_error",
|
|
168
|
-
"param": None,
|
|
169
|
-
"code": "body_missing"
|
|
170
|
-
},
|
|
171
|
-
"example": example
|
|
172
|
-
}
|
|
173
|
-
)
|
|
174
|
-
return JSONResponse(
|
|
175
|
-
status_code=HTTP_422_UNPROCESSABLE_ENTITY,
|
|
176
|
-
content={"detail": error_messages, "example": example}
|
|
177
|
-
)
|
|
178
|
-
return JSONResponse(
|
|
179
|
-
status_code=HTTP_422_UNPROCESSABLE_ENTITY,
|
|
180
|
-
content={"detail": error_messages}
|
|
181
|
-
)
|
|
123
|
+
error_messages.append({
|
|
124
|
+
"loc": loc,
|
|
125
|
+
"message": f"{msg} at {loc_str}",
|
|
126
|
+
"type": error.get("type", "validation_error")
|
|
127
|
+
})
|
|
128
|
+
content = {
|
|
129
|
+
"error": {
|
|
130
|
+
"message": "Request validation error.",
|
|
131
|
+
"details": error_messages,
|
|
132
|
+
"type": "validation_error",
|
|
133
|
+
"footer": github_footer
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return JSONResponse(status_code=HTTP_422_UNPROCESSABLE_ENTITY, content=content)
|
|
182
137
|
|
|
183
138
|
@self.app.exception_handler(StarletteHTTPException)
|
|
184
|
-
async def http_exception_handler(request
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
139
|
+
async def http_exception_handler(request, exc: StarletteHTTPException):
|
|
140
|
+
content = {
|
|
141
|
+
"error": {
|
|
142
|
+
"message": exc.detail or "HTTP error occurred.",
|
|
143
|
+
"type": "http_error",
|
|
144
|
+
"footer": github_footer
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return JSONResponse(status_code=exc.status_code, content=content)
|
|
189
148
|
|
|
190
149
|
@self.app.exception_handler(Exception)
|
|
191
|
-
async def general_exception_handler(request
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
150
|
+
async def general_exception_handler(request, exc: Exception):
|
|
151
|
+
logger.error(f"Unhandled server error: {exc}")
|
|
152
|
+
content = {
|
|
153
|
+
"error": {
|
|
154
|
+
"message": f"Internal server error: {str(exc)}",
|
|
155
|
+
"type": "server_error",
|
|
156
|
+
"footer": github_footer
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return JSONResponse(status_code=HTTP_500_INTERNAL_SERVER_ERROR, content=content)
|
|
196
160
|
|
|
197
161
|
def register_routes(self):
|
|
198
162
|
"""Register all API routes."""
|
|
@@ -203,7 +167,12 @@ class Api:
|
|
|
203
167
|
|
|
204
168
|
def _register_model_routes(self):
|
|
205
169
|
"""Register model listing routes."""
|
|
206
|
-
@self.app.get(
|
|
170
|
+
@self.app.get(
|
|
171
|
+
"/v1/models",
|
|
172
|
+
response_model=ModelListResponse,
|
|
173
|
+
tags=["Chat Completions"],
|
|
174
|
+
description="List all available chat completion models."
|
|
175
|
+
)
|
|
207
176
|
async def list_models():
|
|
208
177
|
models = []
|
|
209
178
|
for model_name, provider_class in AppConfig.provider_map.items():
|
|
@@ -223,7 +192,12 @@ class Api:
|
|
|
223
192
|
"object": "list",
|
|
224
193
|
"data": models
|
|
225
194
|
}
|
|
226
|
-
@self.app.get(
|
|
195
|
+
@self.app.get(
|
|
196
|
+
"/v1/TTI/models",
|
|
197
|
+
response_model=ModelListResponse,
|
|
198
|
+
tags=["Image Generation"],
|
|
199
|
+
description="List all available text-to-image (TTI) models."
|
|
200
|
+
)
|
|
227
201
|
async def list_tti_models():
|
|
228
202
|
models = []
|
|
229
203
|
for model_name, provider_class in AppConfig.tti_provider_map.items():
|
|
@@ -250,6 +224,8 @@ class Api:
|
|
|
250
224
|
"/v1/chat/completions",
|
|
251
225
|
response_model_exclude_none=True,
|
|
252
226
|
response_model_exclude_unset=True,
|
|
227
|
+
tags=["Chat Completions"],
|
|
228
|
+
description="Generate chat completions using the specified model.",
|
|
253
229
|
openapi_extra={
|
|
254
230
|
"requestBody": {
|
|
255
231
|
"content": {
|
|
@@ -312,7 +288,11 @@ class Api:
|
|
|
312
288
|
)
|
|
313
289
|
|
|
314
290
|
|
|
315
|
-
@self.app.post(
|
|
291
|
+
@self.app.post(
|
|
292
|
+
"/v1/images/generations",
|
|
293
|
+
tags=["Image Generation"],
|
|
294
|
+
description="Generate images from text prompts using the specified TTI model."
|
|
295
|
+
)
|
|
316
296
|
async def image_generations(
|
|
317
297
|
image_request: ImageGenerationRequest = Body(...)
|
|
318
298
|
):
|
|
@@ -330,6 +310,18 @@ class Api:
|
|
|
330
310
|
try:
|
|
331
311
|
provider = get_tti_provider_instance(provider_class)
|
|
332
312
|
logger.debug(f"Using TTI provider instance: {provider_class.__name__}")
|
|
313
|
+
except APIError as e:
|
|
314
|
+
# Add helpful footer for provider errors
|
|
315
|
+
return JSONResponse(
|
|
316
|
+
status_code=e.status_code,
|
|
317
|
+
content={
|
|
318
|
+
"error": {
|
|
319
|
+
"message": e.message,
|
|
320
|
+
"type": e.error_type,
|
|
321
|
+
"footer": "If you believe this is a bug, please pull an issue at https://github.com/OEvortex/Webscout."
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
)
|
|
333
325
|
except Exception as e:
|
|
334
326
|
logger.error(f"Failed to initialize TTI provider {provider_class.__name__}: {e}")
|
|
335
327
|
raise APIError(
|
|
@@ -394,7 +386,12 @@ class Api:
|
|
|
394
386
|
auth_components = get_auth_components()
|
|
395
387
|
api_key_manager = auth_components.get("api_key_manager")
|
|
396
388
|
|
|
397
|
-
@self.app.post(
|
|
389
|
+
@self.app.post(
|
|
390
|
+
"/v1/auth/generate-key",
|
|
391
|
+
response_model=APIKeyCreateResponse,
|
|
392
|
+
tags=["Authentication"],
|
|
393
|
+
description="Generate a new API key for a user."
|
|
394
|
+
)
|
|
398
395
|
async def generate_api_key(request: APIKeyCreateRequest = Body(...)):
|
|
399
396
|
"""Generate a new API key."""
|
|
400
397
|
if not api_key_manager:
|
|
@@ -422,7 +419,12 @@ class Api:
|
|
|
422
419
|
logger.error(f"Error generating API key: {e}")
|
|
423
420
|
raise APIError(f"Failed to generate API key: {str(e)}", HTTP_500_INTERNAL_SERVER_ERROR)
|
|
424
421
|
|
|
425
|
-
@self.app.get(
|
|
422
|
+
@self.app.get(
|
|
423
|
+
"/v1/auth/validate",
|
|
424
|
+
response_model=APIKeyValidationResponse,
|
|
425
|
+
tags=["Authentication"],
|
|
426
|
+
description="Validate an API key and return its status."
|
|
427
|
+
)
|
|
426
428
|
async def validate_api_key(request: Request):
|
|
427
429
|
"""Validate an API key."""
|
|
428
430
|
if not api_key_manager:
|
|
@@ -455,7 +457,12 @@ class Api:
|
|
|
455
457
|
logger.error(f"Error validating API key: {e}")
|
|
456
458
|
return APIKeyValidationResponse(valid=False, error="Internal validation error")
|
|
457
459
|
|
|
458
|
-
@self.app.get(
|
|
460
|
+
@self.app.get(
|
|
461
|
+
"/health",
|
|
462
|
+
response_model=HealthCheckResponse,
|
|
463
|
+
tags=["Health"],
|
|
464
|
+
description="Health check endpoint for the API and database."
|
|
465
|
+
)
|
|
459
466
|
async def health_check():
|
|
460
467
|
"""Health check endpoint."""
|
|
461
468
|
db_status = "unknown"
|
|
@@ -473,7 +480,11 @@ class Api:
|
|
|
473
480
|
def _register_websearch_routes(self):
|
|
474
481
|
"""Register web search endpoint."""
|
|
475
482
|
|
|
476
|
-
@self.app.get(
|
|
483
|
+
@self.app.get(
|
|
484
|
+
"/search",
|
|
485
|
+
tags=["Web search"],
|
|
486
|
+
description="Unified web search endpoint supporting Google, Yep, and DuckDuckGo with text, news, images, and suggestions search types."
|
|
487
|
+
)
|
|
477
488
|
async def websearch(
|
|
478
489
|
q: str = Query(..., description="Search query"),
|
|
479
490
|
engine: str = Query("google", description="Search engine: google, yep, duckduckgo"),
|
|
@@ -483,6 +494,7 @@ class Api:
|
|
|
483
494
|
type: str = Query("text", description="Search type: text, news, images, suggestions"),
|
|
484
495
|
):
|
|
485
496
|
"""Unified web search endpoint."""
|
|
497
|
+
github_footer = "If you believe this is a bug, please pull an issue at https://github.com/OEvortex/Webscout."
|
|
486
498
|
try:
|
|
487
499
|
if engine == "google":
|
|
488
500
|
gs = GoogleSearch()
|
|
@@ -496,7 +508,7 @@ class Api:
|
|
|
496
508
|
results = gs.suggestions(q, region=region)
|
|
497
509
|
return {"engine": "google", "type": "suggestions", "results": results}
|
|
498
510
|
else:
|
|
499
|
-
return {"error": "Google only supports text, news, and suggestions in this API."}
|
|
511
|
+
return {"error": "Google only supports text, news, and suggestions in this API.", "footer": github_footer}
|
|
500
512
|
elif engine == "yep":
|
|
501
513
|
ys = YepSearch()
|
|
502
514
|
if type == "text":
|
|
@@ -509,7 +521,7 @@ class Api:
|
|
|
509
521
|
results = ys.suggestions(q, region=region)
|
|
510
522
|
return {"engine": "yep", "type": "suggestions", "results": results}
|
|
511
523
|
else:
|
|
512
|
-
return {"error": "Yep only supports text, images, and suggestions in this API."}
|
|
524
|
+
return {"error": "Yep only supports text, images, and suggestions in this API.", "footer": github_footer}
|
|
513
525
|
elif engine == "duckduckgo":
|
|
514
526
|
ws = WEBS()
|
|
515
527
|
if type == "text":
|
|
@@ -519,8 +531,20 @@ class Api:
|
|
|
519
531
|
results = ws.suggestions(keywords=q, region=region)
|
|
520
532
|
return {"engine": "duckduckgo", "type": "suggestions", "results": results}
|
|
521
533
|
else:
|
|
522
|
-
return {"error": "DuckDuckGo only supports text and suggestions in this API."}
|
|
534
|
+
return {"error": "DuckDuckGo only supports text and suggestions in this API.", "footer": github_footer}
|
|
523
535
|
else:
|
|
524
|
-
return {"error": "Unknown engine. Use one of: google, yep, duckduckgo."}
|
|
536
|
+
return {"error": "Unknown engine. Use one of: google, yep, duckduckgo.", "footer": github_footer}
|
|
525
537
|
except Exception as e:
|
|
526
|
-
|
|
538
|
+
# Special handling for rate limit errors
|
|
539
|
+
msg = str(e)
|
|
540
|
+
if "429" in msg or "rate limit" in msg.lower():
|
|
541
|
+
return {
|
|
542
|
+
"error": "You have hit the search rate limit. Please try again later.",
|
|
543
|
+
"details": msg,
|
|
544
|
+
"code": 429,
|
|
545
|
+
"footer": github_footer
|
|
546
|
+
}
|
|
547
|
+
return {
|
|
548
|
+
"error": f"Search request failed: {msg}",
|
|
549
|
+
"footer": github_footer
|
|
550
|
+
}
|