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.

Files changed (94) hide show
  1. webscout/AIutel.py +146 -37
  2. webscout/Bing_search.py +1 -2
  3. webscout/Provider/AISEARCH/__init__.py +1 -0
  4. webscout/Provider/AISEARCH/stellar_search.py +132 -0
  5. webscout/Provider/ExaChat.py +84 -58
  6. webscout/Provider/HeckAI.py +85 -80
  7. webscout/Provider/Jadve.py +56 -50
  8. webscout/Provider/MiniMax.py +207 -0
  9. webscout/Provider/Nemotron.py +41 -13
  10. webscout/Provider/Netwrck.py +34 -51
  11. webscout/Provider/OPENAI/BLACKBOXAI.py +0 -1
  12. webscout/Provider/OPENAI/MiniMax.py +298 -0
  13. webscout/Provider/OPENAI/README.md +30 -29
  14. webscout/Provider/OPENAI/TogetherAI.py +4 -17
  15. webscout/Provider/OPENAI/__init__.py +3 -1
  16. webscout/Provider/OPENAI/autoproxy.py +752 -17
  17. webscout/Provider/OPENAI/base.py +7 -76
  18. webscout/Provider/OPENAI/deepinfra.py +42 -108
  19. webscout/Provider/OPENAI/flowith.py +179 -166
  20. webscout/Provider/OPENAI/friendli.py +233 -0
  21. webscout/Provider/OPENAI/monochat.py +329 -0
  22. webscout/Provider/OPENAI/pydantic_imports.py +1 -172
  23. webscout/Provider/OPENAI/toolbaz.py +1 -0
  24. webscout/Provider/OPENAI/typegpt.py +1 -1
  25. webscout/Provider/OPENAI/utils.py +19 -42
  26. webscout/Provider/OPENAI/x0gpt.py +14 -2
  27. webscout/Provider/OpenGPT.py +54 -32
  28. webscout/Provider/PI.py +58 -84
  29. webscout/Provider/StandardInput.py +32 -13
  30. webscout/Provider/TTI/README.md +9 -9
  31. webscout/Provider/TTI/__init__.py +2 -1
  32. webscout/Provider/TTI/aiarta.py +92 -78
  33. webscout/Provider/TTI/infip.py +212 -0
  34. webscout/Provider/TTI/monochat.py +220 -0
  35. webscout/Provider/TeachAnything.py +11 -3
  36. webscout/Provider/TextPollinationsAI.py +78 -70
  37. webscout/Provider/TogetherAI.py +32 -48
  38. webscout/Provider/Venice.py +37 -46
  39. webscout/Provider/VercelAI.py +27 -24
  40. webscout/Provider/WiseCat.py +35 -35
  41. webscout/Provider/WrDoChat.py +22 -26
  42. webscout/Provider/WritingMate.py +26 -22
  43. webscout/Provider/__init__.py +2 -2
  44. webscout/Provider/granite.py +48 -57
  45. webscout/Provider/koala.py +51 -39
  46. webscout/Provider/learnfastai.py +49 -64
  47. webscout/Provider/llmchat.py +79 -93
  48. webscout/Provider/llmchatco.py +63 -78
  49. webscout/Provider/multichat.py +51 -40
  50. webscout/Provider/oivscode.py +1 -1
  51. webscout/Provider/scira_chat.py +159 -96
  52. webscout/Provider/scnet.py +13 -13
  53. webscout/Provider/searchchat.py +13 -13
  54. webscout/Provider/sonus.py +12 -11
  55. webscout/Provider/toolbaz.py +25 -8
  56. webscout/Provider/turboseek.py +41 -42
  57. webscout/Provider/typefully.py +27 -12
  58. webscout/Provider/typegpt.py +41 -46
  59. webscout/Provider/uncovr.py +55 -90
  60. webscout/Provider/x0gpt.py +33 -17
  61. webscout/Provider/yep.py +79 -96
  62. webscout/auth/__init__.py +12 -1
  63. webscout/auth/providers.py +27 -5
  64. webscout/auth/routes.py +128 -104
  65. webscout/auth/server.py +367 -312
  66. webscout/client.py +121 -116
  67. webscout/litagent/Readme.md +68 -55
  68. webscout/litagent/agent.py +99 -9
  69. webscout/version.py +1 -1
  70. {webscout-8.3.2.dist-info → webscout-8.3.3.dist-info}/METADATA +102 -90
  71. {webscout-8.3.2.dist-info → webscout-8.3.3.dist-info}/RECORD +75 -87
  72. webscout/Provider/TTI/fastflux.py +0 -233
  73. webscout/Provider/Writecream.py +0 -246
  74. webscout/auth/static/favicon.svg +0 -11
  75. webscout/auth/swagger_ui.py +0 -203
  76. webscout/auth/templates/components/authentication.html +0 -237
  77. webscout/auth/templates/components/base.html +0 -103
  78. webscout/auth/templates/components/endpoints.html +0 -750
  79. webscout/auth/templates/components/examples.html +0 -491
  80. webscout/auth/templates/components/footer.html +0 -75
  81. webscout/auth/templates/components/header.html +0 -27
  82. webscout/auth/templates/components/models.html +0 -286
  83. webscout/auth/templates/components/navigation.html +0 -70
  84. webscout/auth/templates/static/api.js +0 -455
  85. webscout/auth/templates/static/icons.js +0 -168
  86. webscout/auth/templates/static/main.js +0 -784
  87. webscout/auth/templates/static/particles.js +0 -201
  88. webscout/auth/templates/static/styles.css +0 -3353
  89. webscout/auth/templates/static/ui.js +0 -374
  90. webscout/auth/templates/swagger_ui.html +0 -170
  91. {webscout-8.3.2.dist-info → webscout-8.3.3.dist-info}/WHEEL +0 -0
  92. {webscout-8.3.2.dist-info → webscout-8.3.3.dist-info}/entry_points.txt +0 -0
  93. {webscout-8.3.2.dist-info → webscout-8.3.3.dist-info}/licenses/LICENSE.md +0 -0
  94. {webscout-8.3.2.dist-info → webscout-8.3.3.dist-info}/top_level.txt +0 -0
@@ -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(tti_module):
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
- instance = provider_class()
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
- instance = provider_class()
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: Request, exc: APIError):
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
- return exc.to_response()
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: Request, exc: RequestValidationError):
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
- # Ensure loc_str is user-friendly
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
- # Check if this error is for the 'content' field specifically due to multimodal input
116
- if len(loc) >= 3 and loc[0] == 'body' and loc[1] == 'messages' and loc[-1] == 'content':
117
- # Check if the error type suggests a string was expected but a list (or vice-versa) was given for content
118
- if "Input should be a valid string" in msg and error.get("input_type") == "list":
119
- error_messages.append({
120
- "loc": loc,
121
- "message": f"Invalid message content: {msg}. Ensure content matches the expected format (string or list of content parts). Path: {loc_str}",
122
- "type": error.get("type", "validation_error")
123
- })
124
- continue # Skip default message formatting for this specific case
125
- elif "Input should be a valid list" in msg and error.get("input_type") == "string":
126
- error_messages.append({
127
- "loc": loc,
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: Request, exc: StarletteHTTPException):
185
- return JSONResponse(
186
- status_code=exc.status_code,
187
- content={"detail": exc.detail}
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: Request, exc: Exception):
192
- return JSONResponse(
193
- status_code=HTTP_500_INTERNAL_SERVER_ERROR,
194
- content={"detail": f"Internal server error: {str(exc)}"}
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("/v1/models", response_model=ModelListResponse, tags=["Chat Completions"])
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("/v1/TTI/models", response_model=ModelListResponse, tags=["Image Generation"])
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("/v1/images/generations", tags=["Image Generation"])
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("/v1/auth/generate-key", response_model=APIKeyCreateResponse)
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("/v1/auth/validate", response_model=APIKeyValidationResponse)
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("/health", response_model=HealthCheckResponse)
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("/search")
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
- return {"error": str(e)}
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
+ }