webscout 8.3.2__py3-none-any.whl → 8.3.4__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 (117) hide show
  1. webscout/AIutel.py +367 -41
  2. webscout/Bard.py +2 -22
  3. webscout/Bing_search.py +1 -2
  4. webscout/Provider/AISEARCH/__init__.py +1 -0
  5. webscout/Provider/AISEARCH/scira_search.py +24 -11
  6. webscout/Provider/AISEARCH/stellar_search.py +132 -0
  7. webscout/Provider/Deepinfra.py +75 -57
  8. webscout/Provider/ExaChat.py +93 -63
  9. webscout/Provider/Flowith.py +1 -1
  10. webscout/Provider/FreeGemini.py +2 -2
  11. webscout/Provider/Gemini.py +3 -10
  12. webscout/Provider/GeminiProxy.py +31 -5
  13. webscout/Provider/HeckAI.py +85 -80
  14. webscout/Provider/Jadve.py +56 -50
  15. webscout/Provider/LambdaChat.py +39 -31
  16. webscout/Provider/MiniMax.py +207 -0
  17. webscout/Provider/Nemotron.py +41 -13
  18. webscout/Provider/Netwrck.py +39 -59
  19. webscout/Provider/OLLAMA.py +8 -9
  20. webscout/Provider/OPENAI/BLACKBOXAI.py +0 -1
  21. webscout/Provider/OPENAI/MiniMax.py +298 -0
  22. webscout/Provider/OPENAI/README.md +31 -30
  23. webscout/Provider/OPENAI/TogetherAI.py +4 -17
  24. webscout/Provider/OPENAI/__init__.py +4 -2
  25. webscout/Provider/OPENAI/autoproxy.py +753 -18
  26. webscout/Provider/OPENAI/base.py +7 -76
  27. webscout/Provider/OPENAI/copilot.py +73 -26
  28. webscout/Provider/OPENAI/deepinfra.py +96 -132
  29. webscout/Provider/OPENAI/exachat.py +9 -5
  30. webscout/Provider/OPENAI/flowith.py +179 -166
  31. webscout/Provider/OPENAI/friendli.py +233 -0
  32. webscout/Provider/OPENAI/monochat.py +329 -0
  33. webscout/Provider/OPENAI/netwrck.py +4 -7
  34. webscout/Provider/OPENAI/pydantic_imports.py +1 -172
  35. webscout/Provider/OPENAI/qodo.py +630 -0
  36. webscout/Provider/OPENAI/scirachat.py +82 -49
  37. webscout/Provider/OPENAI/textpollinations.py +13 -12
  38. webscout/Provider/OPENAI/toolbaz.py +1 -0
  39. webscout/Provider/OPENAI/typegpt.py +4 -4
  40. webscout/Provider/OPENAI/utils.py +19 -42
  41. webscout/Provider/OPENAI/x0gpt.py +14 -2
  42. webscout/Provider/OpenGPT.py +54 -32
  43. webscout/Provider/PI.py +58 -84
  44. webscout/Provider/Qodo.py +454 -0
  45. webscout/Provider/StandardInput.py +32 -13
  46. webscout/Provider/TTI/README.md +9 -9
  47. webscout/Provider/TTI/__init__.py +2 -1
  48. webscout/Provider/TTI/aiarta.py +92 -78
  49. webscout/Provider/TTI/infip.py +212 -0
  50. webscout/Provider/TTI/monochat.py +220 -0
  51. webscout/Provider/TeachAnything.py +11 -3
  52. webscout/Provider/TextPollinationsAI.py +91 -82
  53. webscout/Provider/TogetherAI.py +32 -48
  54. webscout/Provider/Venice.py +37 -46
  55. webscout/Provider/VercelAI.py +27 -24
  56. webscout/Provider/WiseCat.py +35 -35
  57. webscout/Provider/WrDoChat.py +22 -26
  58. webscout/Provider/WritingMate.py +26 -22
  59. webscout/Provider/__init__.py +6 -6
  60. webscout/Provider/copilot.py +58 -61
  61. webscout/Provider/freeaichat.py +64 -55
  62. webscout/Provider/granite.py +48 -57
  63. webscout/Provider/koala.py +51 -39
  64. webscout/Provider/learnfastai.py +49 -64
  65. webscout/Provider/llmchat.py +79 -93
  66. webscout/Provider/llmchatco.py +63 -78
  67. webscout/Provider/monochat.py +275 -0
  68. webscout/Provider/multichat.py +51 -40
  69. webscout/Provider/oivscode.py +1 -1
  70. webscout/Provider/scira_chat.py +257 -104
  71. webscout/Provider/scnet.py +13 -13
  72. webscout/Provider/searchchat.py +13 -13
  73. webscout/Provider/sonus.py +12 -11
  74. webscout/Provider/toolbaz.py +25 -8
  75. webscout/Provider/turboseek.py +41 -42
  76. webscout/Provider/typefully.py +27 -12
  77. webscout/Provider/typegpt.py +43 -48
  78. webscout/Provider/uncovr.py +55 -90
  79. webscout/Provider/x0gpt.py +325 -299
  80. webscout/Provider/yep.py +79 -96
  81. webscout/__init__.py +7 -2
  82. webscout/auth/__init__.py +12 -1
  83. webscout/auth/providers.py +27 -5
  84. webscout/auth/routes.py +146 -105
  85. webscout/auth/server.py +367 -312
  86. webscout/client.py +121 -116
  87. webscout/litagent/Readme.md +68 -55
  88. webscout/litagent/agent.py +99 -9
  89. webscout/version.py +1 -1
  90. {webscout-8.3.2.dist-info → webscout-8.3.4.dist-info}/METADATA +102 -91
  91. {webscout-8.3.2.dist-info → webscout-8.3.4.dist-info}/RECORD +95 -107
  92. webscout/Provider/AI21.py +0 -177
  93. webscout/Provider/HuggingFaceChat.py +0 -469
  94. webscout/Provider/OPENAI/freeaichat.py +0 -363
  95. webscout/Provider/TTI/fastflux.py +0 -233
  96. webscout/Provider/Writecream.py +0 -246
  97. webscout/auth/static/favicon.svg +0 -11
  98. webscout/auth/swagger_ui.py +0 -203
  99. webscout/auth/templates/components/authentication.html +0 -237
  100. webscout/auth/templates/components/base.html +0 -103
  101. webscout/auth/templates/components/endpoints.html +0 -750
  102. webscout/auth/templates/components/examples.html +0 -491
  103. webscout/auth/templates/components/footer.html +0 -75
  104. webscout/auth/templates/components/header.html +0 -27
  105. webscout/auth/templates/components/models.html +0 -286
  106. webscout/auth/templates/components/navigation.html +0 -70
  107. webscout/auth/templates/static/api.js +0 -455
  108. webscout/auth/templates/static/icons.js +0 -168
  109. webscout/auth/templates/static/main.js +0 -784
  110. webscout/auth/templates/static/particles.js +0 -201
  111. webscout/auth/templates/static/styles.css +0 -3353
  112. webscout/auth/templates/static/ui.js +0 -374
  113. webscout/auth/templates/swagger_ui.html +0 -170
  114. {webscout-8.3.2.dist-info → webscout-8.3.4.dist-info}/WHEEL +0 -0
  115. {webscout-8.3.2.dist-info → webscout-8.3.4.dist-info}/entry_points.txt +0 -0
  116. {webscout-8.3.2.dist-info → webscout-8.3.4.dist-info}/licenses/LICENSE.md +0 -0
  117. {webscout-8.3.2.dist-info → webscout-8.3.4.dist-info}/top_level.txt +0 -0
webscout/auth/routes.py CHANGED
@@ -44,6 +44,7 @@ from .auth_system import get_auth_components
44
44
  from webscout.DWEBS import GoogleSearch
45
45
  from webscout.yep_search import YepSearch
46
46
  from webscout.webscout_search import WEBS
47
+ from webscout.Bing_search import BingSearch
47
48
 
48
49
  # Setup logger
49
50
  logger = Logger(
@@ -85,114 +86,78 @@ class Api:
85
86
 
86
87
  def register_validation_exception_handler(self):
87
88
  """Register comprehensive exception handlers."""
89
+ from fastapi.exceptions import RequestValidationError
90
+ from starlette.exceptions import HTTPException as StarletteHTTPException
91
+ from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY, HTTP_500_INTERNAL_SERVER_ERROR
92
+ from .exceptions import APIError
93
+
94
+ github_footer = "If you believe this is a bug, please pull an issue at https://github.com/OEvortex/Webscout."
88
95
 
89
96
  @self.app.exception_handler(APIError)
90
- async def api_error_handler(request: Request, exc: APIError):
91
- """Handle custom API errors."""
97
+ async def api_error_handler(request, exc: APIError):
92
98
  logger.error(f"API Error: {exc.message} (Status: {exc.status_code})")
93
- return exc.to_response()
99
+ # Patch: add footer to error content before creating JSONResponse
100
+ error_response = exc.to_response()
101
+ # If the response is a JSONResponse, patch its content dict before returning
102
+ if hasattr(error_response, 'body') and hasattr(error_response, 'media_type'):
103
+ # Try to decode the body to dict and add footer if possible
104
+ try:
105
+ import json
106
+ content_dict = json.loads(error_response.body.decode())
107
+ if "error" in content_dict:
108
+ content_dict["error"]["footer"] = github_footer
109
+ return JSONResponse(status_code=error_response.status_code, content=content_dict)
110
+ except Exception:
111
+ pass
112
+ return error_response
94
113
 
95
114
  @self.app.exception_handler(RequestValidationError)
96
- async def validation_exception_handler(request: Request, exc: RequestValidationError):
115
+ async def validation_exception_handler(request, exc: RequestValidationError):
97
116
  errors = exc.errors()
98
117
  error_messages = []
99
118
  body = await request.body()
100
119
  is_empty_body = not body or body.strip() in (b"", b"null", b"{}")
101
-
102
120
  for error in errors:
103
121
  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
-
122
+ loc_str = " -> ".join(str(item) for item in loc)
113
123
  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
- )
124
+ error_messages.append({
125
+ "loc": loc,
126
+ "message": f"{msg} at {loc_str}",
127
+ "type": error.get("type", "validation_error")
128
+ })
129
+ content = {
130
+ "error": {
131
+ "message": "Request validation error.",
132
+ "details": error_messages,
133
+ "type": "validation_error",
134
+ "footer": github_footer
135
+ }
136
+ }
137
+ return JSONResponse(status_code=HTTP_422_UNPROCESSABLE_ENTITY, content=content)
182
138
 
183
139
  @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
- )
140
+ async def http_exception_handler(request, exc: StarletteHTTPException):
141
+ content = {
142
+ "error": {
143
+ "message": exc.detail or "HTTP error occurred.",
144
+ "type": "http_error",
145
+ "footer": github_footer
146
+ }
147
+ }
148
+ return JSONResponse(status_code=exc.status_code, content=content)
189
149
 
190
150
  @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
- )
151
+ async def general_exception_handler(request, exc: Exception):
152
+ logger.error(f"Unhandled server error: {exc}")
153
+ content = {
154
+ "error": {
155
+ "message": f"Internal server error: {str(exc)}",
156
+ "type": "server_error",
157
+ "footer": github_footer
158
+ }
159
+ }
160
+ return JSONResponse(status_code=HTTP_500_INTERNAL_SERVER_ERROR, content=content)
196
161
 
197
162
  def register_routes(self):
198
163
  """Register all API routes."""
@@ -203,7 +168,12 @@ class Api:
203
168
 
204
169
  def _register_model_routes(self):
205
170
  """Register model listing routes."""
206
- @self.app.get("/v1/models", response_model=ModelListResponse, tags=["Chat Completions"])
171
+ @self.app.get(
172
+ "/v1/models",
173
+ response_model=ModelListResponse,
174
+ tags=["Chat Completions"],
175
+ description="List all available chat completion models."
176
+ )
207
177
  async def list_models():
208
178
  models = []
209
179
  for model_name, provider_class in AppConfig.provider_map.items():
@@ -223,7 +193,12 @@ class Api:
223
193
  "object": "list",
224
194
  "data": models
225
195
  }
226
- @self.app.get("/v1/TTI/models", response_model=ModelListResponse, tags=["Image Generation"])
196
+ @self.app.get(
197
+ "/v1/TTI/models",
198
+ response_model=ModelListResponse,
199
+ tags=["Image Generation"],
200
+ description="List all available text-to-image (TTI) models."
201
+ )
227
202
  async def list_tti_models():
228
203
  models = []
229
204
  for model_name, provider_class in AppConfig.tti_provider_map.items():
@@ -250,6 +225,8 @@ class Api:
250
225
  "/v1/chat/completions",
251
226
  response_model_exclude_none=True,
252
227
  response_model_exclude_unset=True,
228
+ tags=["Chat Completions"],
229
+ description="Generate chat completions using the specified model.",
253
230
  openapi_extra={
254
231
  "requestBody": {
255
232
  "content": {
@@ -312,7 +289,11 @@ class Api:
312
289
  )
313
290
 
314
291
 
315
- @self.app.post("/v1/images/generations", tags=["Image Generation"])
292
+ @self.app.post(
293
+ "/v1/images/generations",
294
+ tags=["Image Generation"],
295
+ description="Generate images from text prompts using the specified TTI model."
296
+ )
316
297
  async def image_generations(
317
298
  image_request: ImageGenerationRequest = Body(...)
318
299
  ):
@@ -330,6 +311,18 @@ class Api:
330
311
  try:
331
312
  provider = get_tti_provider_instance(provider_class)
332
313
  logger.debug(f"Using TTI provider instance: {provider_class.__name__}")
314
+ except APIError as e:
315
+ # Add helpful footer for provider errors
316
+ return JSONResponse(
317
+ status_code=e.status_code,
318
+ content={
319
+ "error": {
320
+ "message": e.message,
321
+ "type": e.error_type,
322
+ "footer": "If you believe this is a bug, please pull an issue at https://github.com/OEvortex/Webscout."
323
+ }
324
+ }
325
+ )
333
326
  except Exception as e:
334
327
  logger.error(f"Failed to initialize TTI provider {provider_class.__name__}: {e}")
335
328
  raise APIError(
@@ -394,7 +387,12 @@ class Api:
394
387
  auth_components = get_auth_components()
395
388
  api_key_manager = auth_components.get("api_key_manager")
396
389
 
397
- @self.app.post("/v1/auth/generate-key", response_model=APIKeyCreateResponse)
390
+ @self.app.post(
391
+ "/v1/auth/generate-key",
392
+ response_model=APIKeyCreateResponse,
393
+ tags=["Authentication"],
394
+ description="Generate a new API key for a user."
395
+ )
398
396
  async def generate_api_key(request: APIKeyCreateRequest = Body(...)):
399
397
  """Generate a new API key."""
400
398
  if not api_key_manager:
@@ -422,7 +420,12 @@ class Api:
422
420
  logger.error(f"Error generating API key: {e}")
423
421
  raise APIError(f"Failed to generate API key: {str(e)}", HTTP_500_INTERNAL_SERVER_ERROR)
424
422
 
425
- @self.app.get("/v1/auth/validate", response_model=APIKeyValidationResponse)
423
+ @self.app.get(
424
+ "/v1/auth/validate",
425
+ response_model=APIKeyValidationResponse,
426
+ tags=["Authentication"],
427
+ description="Validate an API key and return its status."
428
+ )
426
429
  async def validate_api_key(request: Request):
427
430
  """Validate an API key."""
428
431
  if not api_key_manager:
@@ -455,7 +458,12 @@ class Api:
455
458
  logger.error(f"Error validating API key: {e}")
456
459
  return APIKeyValidationResponse(valid=False, error="Internal validation error")
457
460
 
458
- @self.app.get("/health", response_model=HealthCheckResponse)
461
+ @self.app.get(
462
+ "/health",
463
+ response_model=HealthCheckResponse,
464
+ tags=["Health"],
465
+ description="Health check endpoint for the API and database."
466
+ )
459
467
  async def health_check():
460
468
  """Health check endpoint."""
461
469
  db_status = "unknown"
@@ -473,16 +481,21 @@ class Api:
473
481
  def _register_websearch_routes(self):
474
482
  """Register web search endpoint."""
475
483
 
476
- @self.app.get("/search")
484
+ @self.app.get(
485
+ "/search",
486
+ tags=["Web search"],
487
+ description="Unified web search endpoint supporting Google, Yep, DuckDuckGo, and Bing with text, news, images, and suggestions search types."
488
+ )
477
489
  async def websearch(
478
490
  q: str = Query(..., description="Search query"),
479
- engine: str = Query("google", description="Search engine: google, yep, duckduckgo"),
491
+ engine: str = Query("google", description="Search engine: google, yep, duckduckgo, bing"),
480
492
  max_results: int = Query(10, description="Maximum number of results"),
481
493
  region: str = Query("all", description="Region code (optional)"),
482
494
  safesearch: str = Query("moderate", description="Safe search: on, moderate, off"),
483
495
  type: str = Query("text", description="Search type: text, news, images, suggestions"),
484
496
  ):
485
497
  """Unified web search endpoint."""
498
+ github_footer = "If you believe this is a bug, please pull an issue at https://github.com/OEvortex/Webscout."
486
499
  try:
487
500
  if engine == "google":
488
501
  gs = GoogleSearch()
@@ -496,7 +509,7 @@ class Api:
496
509
  results = gs.suggestions(q, region=region)
497
510
  return {"engine": "google", "type": "suggestions", "results": results}
498
511
  else:
499
- return {"error": "Google only supports text, news, and suggestions in this API."}
512
+ return {"error": "Google only supports text, news, and suggestions in this API.", "footer": github_footer}
500
513
  elif engine == "yep":
501
514
  ys = YepSearch()
502
515
  if type == "text":
@@ -509,7 +522,7 @@ class Api:
509
522
  results = ys.suggestions(q, region=region)
510
523
  return {"engine": "yep", "type": "suggestions", "results": results}
511
524
  else:
512
- return {"error": "Yep only supports text, images, and suggestions in this API."}
525
+ return {"error": "Yep only supports text, images, and suggestions in this API.", "footer": github_footer}
513
526
  elif engine == "duckduckgo":
514
527
  ws = WEBS()
515
528
  if type == "text":
@@ -519,8 +532,36 @@ class Api:
519
532
  results = ws.suggestions(keywords=q, region=region)
520
533
  return {"engine": "duckduckgo", "type": "suggestions", "results": results}
521
534
  else:
522
- return {"error": "DuckDuckGo only supports text and suggestions in this API."}
535
+ return {"error": "DuckDuckGo only supports text and suggestions in this API.", "footer": github_footer}
536
+ elif engine == "bing":
537
+ bs = BingSearch()
538
+ if type == "text":
539
+ results = bs.text(keywords=q, region=region, safesearch=safesearch, max_results=max_results)
540
+ return {"engine": "bing", "type": "text", "results": [r.__dict__ for r in results]}
541
+ elif type == "news":
542
+ results = bs.news(keywords=q, region=region, safesearch=safesearch, max_results=max_results)
543
+ return {"engine": "bing", "type": "news", "results": [r.__dict__ for r in results]}
544
+ elif type == "images":
545
+ results = bs.images(keywords=q, region=region, safesearch=safesearch, max_results=max_results)
546
+ return {"engine": "bing", "type": "images", "results": [r.__dict__ for r in results]}
547
+ elif type == "suggestions":
548
+ results = bs.suggestions(q, region=region)
549
+ return {"engine": "bing", "type": "suggestions", "results": results}
550
+ else:
551
+ return {"error": "Bing only supports text, news, images, and suggestions in this API.", "footer": github_footer}
523
552
  else:
524
- return {"error": "Unknown engine. Use one of: google, yep, duckduckgo."}
553
+ return {"error": "Unknown engine. Use one of: google, yep, duckduckgo, bing.", "footer": github_footer}
525
554
  except Exception as e:
526
- return {"error": str(e)}
555
+ # Special handling for rate limit errors
556
+ msg = str(e)
557
+ if "429" in msg or "rate limit" in msg.lower():
558
+ return {
559
+ "error": "You have hit the search rate limit. Please try again later.",
560
+ "details": msg,
561
+ "code": 429,
562
+ "footer": github_footer
563
+ }
564
+ return {
565
+ "error": f"Search request failed: {msg}",
566
+ "footer": github_footer
567
+ }