webscout 5.3__py3-none-any.whl → 5.5__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 (52) hide show
  1. webscout/AIauto.py +8 -12
  2. webscout/Agents/Onlinesearcher.py +5 -5
  3. webscout/Agents/functioncall.py +123 -97
  4. webscout/Local/_version.py +2 -2
  5. webscout/Provider/Andi.py +1 -21
  6. webscout/Provider/BasedGPT.py +1 -21
  7. webscout/Provider/Blackboxai.py +1 -21
  8. webscout/Provider/Chatify.py +3 -2
  9. webscout/Provider/Cloudflare.py +1 -22
  10. webscout/Provider/Cohere.py +2 -23
  11. webscout/Provider/DARKAI.py +0 -1
  12. webscout/Provider/Deepinfra.py +2 -16
  13. webscout/Provider/EDITEE.py +3 -26
  14. webscout/Provider/Gemini.py +1 -24
  15. webscout/Provider/Groq.py +0 -2
  16. webscout/Provider/Koboldai.py +0 -21
  17. webscout/Provider/Llama.py +4 -21
  18. webscout/Provider/OLLAMA.py +0 -17
  19. webscout/Provider/Openai.py +2 -22
  20. webscout/Provider/Perplexity.py +1 -2
  21. webscout/Provider/Phind.py +3 -508
  22. webscout/Provider/Reka.py +4 -22
  23. webscout/Provider/TTI/__init__.py +2 -1
  24. webscout/Provider/TTI/aiforce.py +137 -0
  25. webscout/Provider/TTS/streamElements.py +0 -17
  26. webscout/Provider/TTS/voicepod.py +0 -1
  27. webscout/Provider/ThinkAnyAI.py +17 -78
  28. webscout/Provider/Youchat.py +3 -20
  29. webscout/Provider/__init__.py +12 -5
  30. webscout/Provider/cleeai.py +212 -0
  31. webscout/Provider/elmo.py +237 -0
  32. webscout/Provider/felo_search.py +4 -22
  33. webscout/Provider/geminiapi.py +198 -0
  34. webscout/Provider/genspark.py +222 -0
  35. webscout/Provider/julius.py +3 -20
  36. webscout/Provider/koala.py +1 -1
  37. webscout/Provider/lepton.py +194 -0
  38. webscout/Provider/turboseek.py +4 -21
  39. webscout/Provider/x0gpt.py +3 -2
  40. webscout/Provider/xdash.py +2 -22
  41. webscout/Provider/yep.py +391 -149
  42. webscout/YTdownloader.py +2 -3
  43. webscout/tempid.py +46 -2
  44. webscout/version.py +1 -1
  45. webscout/webscout_search_async.py +9 -9
  46. {webscout-5.3.dist-info → webscout-5.5.dist-info}/METADATA +39 -64
  47. webscout-5.5.dist-info/RECORD +99 -0
  48. webscout-5.3.dist-info/RECORD +0 -93
  49. {webscout-5.3.dist-info → webscout-5.5.dist-info}/LICENSE.md +0 -0
  50. {webscout-5.3.dist-info → webscout-5.5.dist-info}/WHEEL +0 -0
  51. {webscout-5.3.dist-info → webscout-5.5.dist-info}/entry_points.txt +0 -0
  52. {webscout-5.3.dist-info → webscout-5.5.dist-info}/top_level.txt +0 -0
@@ -1,33 +1,15 @@
1
- import time
2
- import uuid
3
- from selenium import webdriver
4
- from selenium.webdriver.chrome.options import Options
5
- from selenium.webdriver.common.by import By
6
- from selenium.webdriver.support import expected_conditions as EC
7
- from selenium.webdriver.support.ui import WebDriverWait
8
- import click
9
1
  import requests
10
- from requests import get
11
- from uuid import uuid4
12
- from re import findall
13
- from requests.exceptions import RequestException
14
- from curl_cffi.requests import get, RequestsError
15
- import g4f
16
- from random import randint
17
- from PIL import Image
18
- import io
19
2
  import re
20
3
  import json
21
4
  import yaml
22
5
  from webscout.AIutel import Optimizers
23
6
  from webscout.AIutel import Conversation
24
7
  from webscout.AIutel import AwesomePrompts, sanitize_stream
25
- from webscout.AIbase import Provider, AsyncProvider
26
- from Helpingai_T2 import Perplexity
8
+ from webscout.AIbase import Provider
9
+
27
10
  from webscout import exceptions
28
11
  from typing import Any, AsyncGenerator, Dict
29
- import logging
30
- import httpx
12
+
31
13
 
32
14
  #------------------------------------------------------phind-------------------------------------------------------------
33
15
  class PhindSearch:
@@ -272,250 +254,7 @@ class PhindSearch:
272
254
  if response["choices"][0].get("finish_reason") is None
273
255
  else ""
274
256
  )
275
- class AsyncPhindSearch(AsyncProvider):
276
- def __init__(
277
- self,
278
- is_conversation: bool = True,
279
- max_tokens: int = 600,
280
- timeout: int = 30,
281
- intro: str = None,
282
- filepath: str = None,
283
- update_file: bool = True,
284
- proxies: dict = {},
285
- history_offset: int = 10250,
286
- act: str = None,
287
- model: str = "Phind Model",
288
- quiet: bool = False,
289
- ):
290
- """Instantiates PHIND
291
-
292
- Args:
293
- is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True
294
- max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
295
- timeout (int, optional): Http request timeout. Defaults to 30.
296
- intro (str, optional): Conversation introductory prompt. Defaults to None.
297
- filepath (str, optional): Path to file containing conversation history. Defaults to None.
298
- update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
299
- proxies (dict, optional): Http request proxies. Defaults to {}.
300
- history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
301
- act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
302
- model (str, optional): Model name. Defaults to "Phind Model".
303
- quiet (bool, optional): Ignore web search-results and yield final response only. Defaults to False.
304
- """
305
- self.max_tokens_to_sample = max_tokens
306
- self.is_conversation = is_conversation
307
- self.chat_endpoint = "https://https.extension.phind.com/agent/"
308
- self.stream_chunk_size = 64
309
- self.timeout = timeout
310
- self.last_response = {}
311
- self.model = model
312
- self.quiet = quiet
313
-
314
- self.headers = {
315
- "Content-Type": "application/json",
316
- "User-Agent": "",
317
- "Accept": "*/*",
318
- "Accept-Encoding": "Identity",
319
- }
320
-
321
- self.__available_optimizers = (
322
- method
323
- for method in dir(Optimizers)
324
- if callable(getattr(Optimizers, method)) and not method.startswith("__")
325
- )
326
- Conversation.intro = (
327
- AwesomePrompts().get_act(
328
- act, raise_not_found=True, default=None, case_insensitive=True
329
- )
330
- if act
331
- else intro or Conversation.intro
332
- )
333
- self.conversation = Conversation(
334
- is_conversation, self.max_tokens_to_sample, filepath, update_file
335
- )
336
- self.conversation.history_offset = history_offset
337
- self.session = httpx.AsyncClient(headers=self.headers, proxies=proxies)
338
-
339
- async def ask(
340
- self,
341
- prompt: str,
342
- stream: bool = False,
343
- raw: bool = False,
344
- optimizer: str = None,
345
- conversationally: bool = False,
346
- synchronous_generator=False,
347
- ) -> dict | AsyncGenerator:
348
- """Asynchronously Chat with AI
349
257
 
350
- Args:
351
- prompt (str): Prompt to be send.
352
- stream (bool, optional): Flag for streaming response. Defaults to False.
353
- raw (bool, optional): Stream back raw response as received. Defaults to False.
354
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
355
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
356
- Returns:
357
- dict|AsyncGenerator : ai content.
358
- ```json
359
- {
360
- "id": "chatcmpl-r0wujizf2i2xb60mjiwt",
361
- "object": "chat.completion.chunk",
362
- "created": 1706775384,
363
- "model": "trt-llm-phind-model-serving",
364
- "choices": [
365
- {
366
- "index": 0,
367
- "delta": {
368
- "content": "Hello! How can I assist you with your programming today?"
369
- },
370
- "finish_reason": null
371
- }
372
- ]
373
- }
374
- ```
375
- """
376
- conversation_prompt = self.conversation.gen_complete_prompt(prompt)
377
- if optimizer:
378
- if optimizer in self.__available_optimizers:
379
- conversation_prompt = getattr(Optimizers, optimizer)(
380
- conversation_prompt if conversationally else prompt
381
- )
382
- else:
383
- raise Exception(
384
- f"Optimizer is not one of {self.__available_optimizers}"
385
- )
386
-
387
- payload = {
388
- "additional_extension_context": "",
389
- "allow_magic_buttons": True,
390
- "is_vscode_extension": True,
391
- "message_history": [
392
- {"content": conversation_prompt, "metadata": {}, "role": "user"}
393
- ],
394
- "requested_model": self.model,
395
- "user_input": prompt,
396
- }
397
-
398
- async def for_stream():
399
- async with self.session.stream(
400
- "POST",
401
- self.chat_endpoint,
402
- json=payload,
403
- timeout=self.timeout,
404
- ) as response:
405
- if (
406
- not response.is_success
407
- or not response.headers.get("Content-Type")
408
- == "text/event-stream; charset=utf-8"
409
- ):
410
- raise exceptions.FailedToGenerateResponseError(
411
- f"Failed to generate response - ({response.status_code}, {response.reason_phrase})"
412
- )
413
- streaming_text = ""
414
- async for value in response.aiter_lines():
415
- try:
416
- modified_value = re.sub("data:", "", value)
417
- json_modified_value = json.loads(modified_value)
418
- retrieved_text = await self.get_message(json_modified_value)
419
- if not retrieved_text:
420
- continue
421
- streaming_text += retrieved_text
422
- json_modified_value["choices"][0]["delta"][
423
- "content"
424
- ] = streaming_text
425
- self.last_response.update(json_modified_value)
426
- yield value if raw else json_modified_value
427
- except json.decoder.JSONDecodeError:
428
- pass
429
- self.conversation.update_chat_history(
430
- prompt, await self.get_message(self.last_response)
431
- )
432
-
433
- async def for_non_stream():
434
- async for _ in for_stream():
435
- pass
436
- return self.last_response
437
-
438
- return (
439
- for_stream()
440
- if stream and not synchronous_generator
441
- else await for_non_stream()
442
- )
443
-
444
- async def chat(
445
- self,
446
- prompt: str,
447
- stream: bool = False,
448
- optimizer: str = None,
449
- conversationally: bool = False,
450
- ) -> str | AsyncGenerator:
451
- """Generate response `str`
452
- Args:
453
- prompt (str): Prompt to be send.
454
- stream (bool, optional): Flag for streaming response. Defaults to False.
455
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
456
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
457
- Returns:
458
- str|AsyncGenerator: Response generated
459
- """
460
-
461
- async def for_stream():
462
- ask_resp = await self.ask(
463
- prompt, True, optimizer=optimizer, conversationally=conversationally
464
- )
465
- async for response in ask_resp:
466
- yield await self.get_message(response)
467
-
468
- async def for_non_stream():
469
- return await self.get_message(
470
- await self.ask(
471
- prompt,
472
- False,
473
- optimizer=optimizer,
474
- conversationally=conversationally,
475
- )
476
- )
477
-
478
- return for_stream() if stream else await for_non_stream()
479
-
480
- async def get_message(self, response: dict) -> str:
481
- """Retrieves message only from response
482
-
483
- Args:
484
- response (dict): Response generated by `self.ask`
485
-
486
- Returns:
487
- str: Message extracted
488
- """
489
- assert isinstance(response, dict), "Response should be of dict data-type only"
490
- if response.get("type", "") == "metadata":
491
- return
492
-
493
- delta: dict = response["choices"][0]["delta"]
494
-
495
- if not delta:
496
- return ""
497
-
498
- elif delta.get("function_call"):
499
- if self.quiet:
500
- return ""
501
-
502
- function_call: dict = delta["function_call"]
503
- if function_call.get("name"):
504
- return function_call["name"]
505
- elif function_call.get("arguments"):
506
- return function_call.get("arguments")
507
-
508
- elif delta.get("metadata"):
509
- if self.quiet:
510
- return ""
511
- return yaml.dump(delta["metadata"])
512
-
513
- else:
514
- return (
515
- response["choices"][0]["delta"].get("content")
516
- if response["choices"][0].get("finish_reason") is None
517
- else ""
518
- )
519
258
  class Phindv2(Provider):
520
259
  def __init__(
521
260
  self,
@@ -762,247 +501,3 @@ class Phindv2(Provider):
762
501
  else ""
763
502
  )
764
503
 
765
- class AsyncPhindv2(AsyncProvider):
766
- def __init__(
767
- self,
768
- is_conversation: bool = True,
769
- max_tokens: int = 600,
770
- timeout: int = 30,
771
- intro: str = None,
772
- filepath: str = None,
773
- update_file: bool = True,
774
- proxies: dict = {},
775
- history_offset: int = 10250,
776
- act: str = None,
777
- model: str = "Phind Instant",
778
- quiet: bool = False,
779
- system_prompt: str = "Be Helpful and Friendly",
780
- ):
781
- """Instantiates Phindv2
782
-
783
- Args:
784
- is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
785
- max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
786
- timeout (int, optional): Http request timeout. Defaults to 30.
787
- intro (str, optional): Conversation introductory prompt. Defaults to None.
788
- filepath (str, optional): Path to file containing conversation history. Defaults to None.
789
- update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
790
- proxies (dict, optional): Http request proxies. Defaults to {}.
791
- history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
792
- act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
793
- model (str, optional): Model name. Defaults to "Phind Model".
794
- quiet (bool, optional): Ignore web search-results and yield final response only. Defaults to False.
795
- system_prompt (str, optional): System prompt for Phindv2. Defaults to "Be Helpful and Friendly".
796
- """
797
- self.max_tokens_to_sample = max_tokens
798
- self.is_conversation = is_conversation
799
- self.chat_endpoint = "https://https.extension.phind.com/agent/"
800
- self.stream_chunk_size = 64
801
- self.timeout = timeout
802
- self.last_response = {}
803
- self.model = model
804
- self.quiet = quiet
805
- self.system_prompt = system_prompt
806
-
807
- self.headers = {
808
- "Content-Type": "application/json",
809
- "User-Agent": "",
810
- "Accept": "*/*",
811
- "Accept-Encoding": "Identity",
812
- }
813
-
814
- self.__available_optimizers = (
815
- method
816
- for method in dir(Optimizers)
817
- if callable(getattr(Optimizers, method)) and not method.startswith("__")
818
- )
819
- Conversation.intro = (
820
- AwesomePrompts().get_act(
821
- act, raise_not_found=True, default=None, case_insensitive=True
822
- )
823
- if act
824
- else intro or Conversation.intro
825
- )
826
- self.conversation = Conversation(
827
- is_conversation, self.max_tokens_to_sample, filepath, update_file
828
- )
829
- self.conversation.history_offset = history_offset
830
- self.session = httpx.AsyncClient(headers=self.headers, proxies=proxies)
831
-
832
- async def ask(
833
- self,
834
- prompt: str,
835
- stream: bool = False,
836
- raw: bool = False,
837
- optimizer: str = None,
838
- conversationally: bool = False,
839
- ) -> dict | AsyncGenerator:
840
- """Chat with AI asynchronously.
841
-
842
- Args:
843
- prompt (str): Prompt to be send.
844
- stream (bool, optional): Flag for streaming response. Defaults to False.
845
- raw (bool, optional): Stream back raw response as received. Defaults to False.
846
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
847
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
848
- Returns:
849
- dict|AsyncGenerator : ai content.
850
- ```json
851
- {
852
- "id": "chatcmpl-r0wujizf2i2xb60mjiwt",
853
- "object": "chat.completion.chunk",
854
- "created": 1706775384,
855
- "model": "trt-llm-phind-model-serving",
856
- "choices": [
857
- {
858
- "index": 0,
859
- "delta": {
860
- "content": "Hello! How can I assist you with your programming today?"
861
- },
862
- "finish_reason": null
863
- }
864
- ]
865
- }
866
- ```
867
- """
868
- conversation_prompt = self.conversation.gen_complete_prompt(prompt)
869
- if optimizer:
870
- if optimizer in self.__available_optimizers:
871
- conversation_prompt = getattr(Optimizers, optimizer)(
872
- conversation_prompt if conversationally else prompt
873
- )
874
- else:
875
- raise Exception(
876
- f"Optimizer is not one of {self.__available_optimizers}"
877
- )
878
-
879
- payload = {
880
- "additional_extension_context": "",
881
- "allow_magic_buttons": True,
882
- "is_vscode_extension": True,
883
- "message_history": [
884
- {"content": self.system_prompt, "metadata": {}, "role": "system"},
885
- {"content": conversation_prompt, "metadata": {}, "role": "user"}
886
- ],
887
- "requested_model": self.model,
888
- "user_input": prompt,
889
- }
890
-
891
- async def for_stream():
892
- async with self.session.stream(
893
- "POST",
894
- self.chat_endpoint,
895
- json=payload,
896
- timeout=self.timeout,
897
- ) as response:
898
- if (
899
- not response.is_success
900
- or not response.headers.get("Content-Type")
901
- == "text/event-stream; charset=utf-8"
902
- ):
903
- raise exceptions.FailedToGenerateResponseError(
904
- f"Failed to generate response - ({response.status_code}, {response.reason_phrase})"
905
- )
906
- streaming_text = ""
907
- async for value in response.aiter_lines():
908
- try:
909
- modified_value = re.sub("data:", "", value)
910
- json_modified_value = json.loads(modified_value)
911
- retrieved_text = await self.get_message(json_modified_value)
912
- if not retrieved_text:
913
- continue
914
- streaming_text += retrieved_text
915
- json_modified_value["choices"][0]["delta"][
916
- "content"
917
- ] = streaming_text
918
- self.last_response.update(json_modified_value)
919
- yield value if raw else json_modified_value
920
- except json.decoder.JSONDecodeError:
921
- pass
922
- self.conversation.update_chat_history(
923
- prompt, await self.get_message(self.last_response)
924
- )
925
-
926
- async def for_non_stream():
927
- async for _ in for_stream():
928
- pass
929
- return self.last_response
930
-
931
- return for_stream() if stream else await for_non_stream()
932
-
933
- async def chat(
934
- self,
935
- prompt: str,
936
- stream: bool = False,
937
- optimizer: str = None,
938
- conversationally: bool = False,
939
- ) -> str | AsyncGenerator:
940
- """Generate response `str`
941
- Args:
942
- prompt (str): Prompt to be send.
943
- stream (bool, optional): Flag for streaming response. Defaults to False.
944
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
945
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
946
- Returns:
947
- str|AsyncGenerator: Response generated
948
- """
949
-
950
- async def for_stream():
951
- ask_resp = await self.ask(
952
- prompt, True, optimizer=optimizer, conversationally=conversationally
953
- )
954
- async for response in ask_resp:
955
- yield await self.get_message(response)
956
-
957
- async def for_non_stream():
958
- return await self.get_message(
959
- await self.ask(
960
- prompt,
961
- False,
962
- optimizer=optimizer,
963
- conversationally=conversationally,
964
- )
965
- )
966
-
967
- return for_stream() if stream else await for_non_stream()
968
-
969
- async def get_message(self, response: dict) -> str:
970
- """Retrieves message only from response
971
-
972
- Args:
973
- response (dict): Response generated by `self.ask`
974
-
975
- Returns:
976
- str: Message extracted
977
- """
978
- assert isinstance(response, dict), "Response should be of dict data-type only"
979
- if response.get("type", "") == "metadata":
980
- return
981
-
982
- delta: dict = response["choices"][0]["delta"]
983
-
984
- if not delta:
985
- return ""
986
-
987
- elif delta.get("function_call"):
988
- if self.quiet:
989
- return ""
990
-
991
- function_call: dict = delta["function_call"]
992
- if function_call.get("name"):
993
- return function_call["name"]
994
- elif function_call.get("arguments"):
995
- return function_call.get("arguments")
996
-
997
- elif delta.get("metadata"):
998
- if self.quiet:
999
- return ""
1000
- return yaml.dump(delta["metadata"])
1001
-
1002
- else:
1003
- return (
1004
- response["choices"][0]["delta"].get("content")
1005
- if response["choices"][0].get("finish_reason") is None
1006
- else ""
1007
- )
1008
-
webscout/Provider/Reka.py CHANGED
@@ -1,33 +1,15 @@
1
- import time
2
- import uuid
3
- from selenium import webdriver
4
- from selenium.webdriver.chrome.options import Options
5
- from selenium.webdriver.common.by import By
6
- from selenium.webdriver.support import expected_conditions as EC
7
- from selenium.webdriver.support.ui import WebDriverWait
8
1
  import click
9
2
  import requests
10
- from requests import get
11
- from uuid import uuid4
12
- from re import findall
13
- from requests.exceptions import RequestException
14
- from curl_cffi.requests import get, RequestsError
15
- import g4f
16
- from random import randint
17
- from PIL import Image
18
- import io
19
- import re
3
+
4
+
20
5
  import json
21
- import yaml
6
+
22
7
  from ..AIutel import Optimizers
23
8
  from ..AIutel import Conversation
24
9
  from ..AIutel import AwesomePrompts, sanitize_stream
25
10
  from ..AIbase import Provider, AsyncProvider
26
- from Helpingai_T2 import Perplexity
27
11
  from webscout import exceptions
28
- from typing import Any, AsyncGenerator, Dict
29
- import logging
30
- import httpx
12
+
31
13
  #-----------------------------------------------REKA-----------------------------------------------
32
14
  class REKA(Provider):
33
15
  def __init__(
@@ -1,2 +1,3 @@
1
1
  from .deepinfra import *
2
- from .PollinationsAI import *
2
+ from .PollinationsAI import *
3
+ from .aiforce import *