webscout 1.4.3__tar.gz → 1.4.5__tar.gz

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 (44) hide show
  1. {webscout-1.4.3 → webscout-1.4.5}/PKG-INFO +70 -5
  2. {webscout-1.4.3 → webscout-1.4.5}/README.md +69 -4
  3. {webscout-1.4.3 → webscout-1.4.5}/setup.py +1 -1
  4. {webscout-1.4.3 → webscout-1.4.5}/webscout/AI.py +253 -3
  5. {webscout-1.4.3 → webscout-1.4.5}/webscout/AIutel.py +4 -2
  6. {webscout-1.4.3 → webscout-1.4.5}/webscout/__init__.py +2 -1
  7. {webscout-1.4.3 → webscout-1.4.5}/webscout/utils.py +0 -1
  8. webscout-1.4.5/webscout/version.py +2 -0
  9. {webscout-1.4.3 → webscout-1.4.5}/webscout/webai.py +15 -1
  10. {webscout-1.4.3 → webscout-1.4.5}/webscout/webscout_search.py +13 -10
  11. {webscout-1.4.3 → webscout-1.4.5}/webscout/webscout_search_async.py +132 -76
  12. {webscout-1.4.3 → webscout-1.4.5}/webscout.egg-info/PKG-INFO +70 -5
  13. webscout-1.4.3/webscout/version.py +0 -2
  14. {webscout-1.4.3 → webscout-1.4.5}/DeepWEBS/__init__.py +0 -0
  15. {webscout-1.4.3 → webscout-1.4.5}/DeepWEBS/documents/__init__.py +0 -0
  16. {webscout-1.4.3 → webscout-1.4.5}/DeepWEBS/documents/query_results_extractor.py +0 -0
  17. {webscout-1.4.3 → webscout-1.4.5}/DeepWEBS/documents/webpage_content_extractor.py +0 -0
  18. {webscout-1.4.3 → webscout-1.4.5}/DeepWEBS/networks/__init__.py +0 -0
  19. {webscout-1.4.3 → webscout-1.4.5}/DeepWEBS/networks/filepath_converter.py +0 -0
  20. {webscout-1.4.3 → webscout-1.4.5}/DeepWEBS/networks/google_searcher.py +0 -0
  21. {webscout-1.4.3 → webscout-1.4.5}/DeepWEBS/networks/network_configs.py +0 -0
  22. {webscout-1.4.3 → webscout-1.4.5}/DeepWEBS/networks/webpage_fetcher.py +0 -0
  23. {webscout-1.4.3 → webscout-1.4.5}/DeepWEBS/utilsdw/__init__.py +0 -0
  24. {webscout-1.4.3 → webscout-1.4.5}/DeepWEBS/utilsdw/enver.py +0 -0
  25. {webscout-1.4.3 → webscout-1.4.5}/DeepWEBS/utilsdw/logger.py +0 -0
  26. {webscout-1.4.3 → webscout-1.4.5}/LICENSE.md +0 -0
  27. {webscout-1.4.3 → webscout-1.4.5}/setup.cfg +0 -0
  28. {webscout-1.4.3 → webscout-1.4.5}/webscout/AIbase.py +0 -0
  29. {webscout-1.4.3 → webscout-1.4.5}/webscout/DWEBS.py +0 -0
  30. {webscout-1.4.3 → webscout-1.4.5}/webscout/LLM.py +0 -0
  31. {webscout-1.4.3 → webscout-1.4.5}/webscout/__main__.py +0 -0
  32. {webscout-1.4.3 → webscout-1.4.5}/webscout/async_providers.py +0 -0
  33. {webscout-1.4.3 → webscout-1.4.5}/webscout/cli.py +0 -0
  34. {webscout-1.4.3 → webscout-1.4.5}/webscout/exceptions.py +0 -0
  35. {webscout-1.4.3 → webscout-1.4.5}/webscout/g4f.py +0 -0
  36. {webscout-1.4.3 → webscout-1.4.5}/webscout/models.py +0 -0
  37. {webscout-1.4.3 → webscout-1.4.5}/webscout/tempid.py +0 -0
  38. {webscout-1.4.3 → webscout-1.4.5}/webscout/transcriber.py +0 -0
  39. {webscout-1.4.3 → webscout-1.4.5}/webscout/voice.py +0 -0
  40. {webscout-1.4.3 → webscout-1.4.5}/webscout.egg-info/SOURCES.txt +0 -0
  41. {webscout-1.4.3 → webscout-1.4.5}/webscout.egg-info/dependency_links.txt +0 -0
  42. {webscout-1.4.3 → webscout-1.4.5}/webscout.egg-info/entry_points.txt +0 -0
  43. {webscout-1.4.3 → webscout-1.4.5}/webscout.egg-info/requires.txt +0 -0
  44. {webscout-1.4.3 → webscout-1.4.5}/webscout.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webscout
3
- Version: 1.4.3
3
+ Version: 1.4.5
4
4
  Summary: Search for anything using the Google, DuckDuckGo, phind.com. Also containes AI models, can transcribe yt videos, temporary email and phone number generation, have TTS support and webai(terminal gpt and open interpeter)
5
5
  Author: OEvortex
6
6
  Author-email: helpingai5@gmail.com
@@ -54,9 +54,31 @@ Provides-Extra: dev
54
54
  Requires-Dist: ruff>=0.1.6; extra == "dev"
55
55
  Requires-Dist: pytest>=7.4.2; extra == "dev"
56
56
 
57
- # webscout
58
- <p align="center">
57
+ <div align="center">
58
+ <!-- Replace `#` with your actual links -->
59
+ <a href="https://t.me/devsdocode"><img alt="Telegram" src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white"></a>
60
+ <a href="https://www.instagram.com/sree.shades_/"><img alt="Instagram" src="https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white"></a>
61
+ <a href="https://www.linkedin.com/in/developer-sreejan/"><img alt="LinkedIn" src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white"></a>
62
+ <a href="https://buymeacoffee.com/devsdocode"><img alt="Buy Me A Coffee" src="https://img.shields.io/badge/Buy%20Me%20A%20Coffee-FFDD00?style=for-the-badge&logo=buymeacoffee&logoColor=black"></a>
63
+ </div>
64
+
65
+ <div align="center">
66
+ <!-- Replace `#` with your actual links -->
67
+ <a href="https://youtube.com/@@OEvortex">&#10148; Vortex's YouTube Channel</a>
68
+ </div>
69
+ <div align="center">
70
+ <a href="https://youtube.com/@devsdocode">&#10148; Devs Do Code's YouTube Channel</a>
71
+ </div>
72
+
73
+
59
74
 
75
+
76
+ # WEBSCOUT
77
+ </div>
78
+ <p align="center">
79
+ <div align="center">
80
+ <img src="https://img.shields.io/badge/WebScout-API-blue?style=for-the-badge&logo=WebScout" alt="WebScout API Badge">
81
+ </div>
60
82
  <a href="#"><img alt="Python version" src="https://img.shields.io/pypi/pyversions/webscout"/></a>
61
83
  <a href="https://pepy.tech/project/webscout"><img alt="Downloads" src="https://static.pepy.tech/badge/webscout"></a>
62
84
 
@@ -64,7 +86,7 @@ Search for anything using the Google, DuckDuckGo, phind.com. Also containes AI m
64
86
 
65
87
 
66
88
  ## Table of Contents
67
- - [webscout](#webscout)
89
+ - [WEBSCOUT](#webscout)
68
90
  - [Table of Contents](#table-of-contents)
69
91
  - [Install](#install)
70
92
  - [CLI version](#cli-version)
@@ -105,6 +127,7 @@ Search for anything using the Google, DuckDuckGo, phind.com. Also containes AI m
105
127
  - [10. `Reka` - chat with reka](#10-reka---chat-with-reka)
106
128
  - [11. `Cohere` - chat with cohere](#11-cohere---chat-with-cohere)
107
129
  - [12. `Xjai` - chat with free gpt 3.5](#12-xjai---chat-with-free-gpt-35)
130
+ - [`ThinkAny` - AI search engine](#thinkany---ai-search-engine)
108
131
  - [`LLM`](#llm)
109
132
  - [`LLM` with internet](#llm-with-internet)
110
133
  - [LLM with deepwebs](#llm-with-deepwebs)
@@ -790,7 +813,7 @@ print(response)
790
813
  ```python
791
814
  from webscout.AI import OPENGPT
792
815
 
793
- opengpt = OPENGPT(is_conversation=True, max_tokens=8000, timeout=30)
816
+ opengpt = OPENGPT(is_conversation=True, max_tokens=8000, timeout=30, assistant_id="bca37014-6f97-4f2b-8928-81ea8d478d88")
794
817
  while True:
795
818
  # Prompt the user for input
796
819
  prompt = input("Enter your prompt: ")
@@ -862,7 +885,31 @@ prompt = "Tell me about india"
862
885
  response = ai.chat(prompt)
863
886
  print(response)
864
887
  ```
888
+ ### `ThinkAny` - AI search engine
889
+ ```python
890
+ from webscout.AI import ThinkAnyAI
865
891
 
892
+ ai = ThinkAnyAI(
893
+ is_conversation=True,
894
+ max_tokens=800,
895
+ timeout=30,
896
+ intro=None,
897
+ filepath=None,
898
+ update_file=True,
899
+ proxies={},
900
+ history_offset=10250,
901
+ act=None,
902
+ web_search=False,
903
+ )
904
+
905
+ prompt = "what is meaning of life"
906
+
907
+ response = ai.ask(prompt)
908
+
909
+ # Extract and print the message from the response
910
+ message = ai.get_message(response)
911
+ print(message)
912
+ ```
866
913
  ### `LLM`
867
914
  ```python
868
915
  from webscout.LLM import LLM
@@ -1093,3 +1140,21 @@ if __name__ == "__main__":
1093
1140
  ```shell
1094
1141
  python -m webscout.webai webai --provider "phind" --rawdog
1095
1142
  ```
1143
+
1144
+ <div align="center">
1145
+ <!-- Replace `#` with your actual links -->
1146
+ <a href="https://t.me/devsdocode"><img alt="Telegram" src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white"></a>
1147
+ <a href="https://www.instagram.com/sree.shades_/"><img alt="Instagram" src="https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white"></a>
1148
+ <a href="https://www.linkedin.com/in/developer-sreejan/"><img alt="LinkedIn" src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white"></a>
1149
+ <a href="https://buymeacoffee.com/devsdocode"><img alt="Buy Me A Coffee" src="https://img.shields.io/badge/Buy%20Me%20A%20Coffee-FFDD00?style=for-the-badge&logo=buymeacoffee&logoColor=black"></a>
1150
+ </div>
1151
+
1152
+ <div align="center">
1153
+ <!-- Replace `#` with your actual links -->
1154
+ <a href="https://youtube.com/@@OEvortex">&#10148; Vortex's YouTube Channel</a>
1155
+ </div>
1156
+ <div align="center">
1157
+ <a href="https://youtube.com/@devsdocode">&#10148; Devs Do Code's YouTube Channel</a>
1158
+ </div>
1159
+
1160
+
@@ -1,6 +1,28 @@
1
- # webscout
1
+ <div align="center">
2
+ <!-- Replace `#` with your actual links -->
3
+ <a href="https://t.me/devsdocode"><img alt="Telegram" src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white"></a>
4
+ <a href="https://www.instagram.com/sree.shades_/"><img alt="Instagram" src="https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white"></a>
5
+ <a href="https://www.linkedin.com/in/developer-sreejan/"><img alt="LinkedIn" src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white"></a>
6
+ <a href="https://buymeacoffee.com/devsdocode"><img alt="Buy Me A Coffee" src="https://img.shields.io/badge/Buy%20Me%20A%20Coffee-FFDD00?style=for-the-badge&logo=buymeacoffee&logoColor=black"></a>
7
+ </div>
8
+
9
+ <div align="center">
10
+ <!-- Replace `#` with your actual links -->
11
+ <a href="https://youtube.com/@@OEvortex">&#10148; Vortex's YouTube Channel</a>
12
+ </div>
13
+ <div align="center">
14
+ <a href="https://youtube.com/@devsdocode">&#10148; Devs Do Code's YouTube Channel</a>
15
+ </div>
16
+
17
+
18
+
19
+
20
+ # WEBSCOUT
21
+ </div>
2
22
  <p align="center">
3
-
23
+ <div align="center">
24
+ <img src="https://img.shields.io/badge/WebScout-API-blue?style=for-the-badge&logo=WebScout" alt="WebScout API Badge">
25
+ </div>
4
26
  <a href="#"><img alt="Python version" src="https://img.shields.io/pypi/pyversions/webscout"/></a>
5
27
  <a href="https://pepy.tech/project/webscout"><img alt="Downloads" src="https://static.pepy.tech/badge/webscout"></a>
6
28
 
@@ -8,7 +30,7 @@ Search for anything using the Google, DuckDuckGo, phind.com. Also containes AI m
8
30
 
9
31
 
10
32
  ## Table of Contents
11
- - [webscout](#webscout)
33
+ - [WEBSCOUT](#webscout)
12
34
  - [Table of Contents](#table-of-contents)
13
35
  - [Install](#install)
14
36
  - [CLI version](#cli-version)
@@ -49,6 +71,7 @@ Search for anything using the Google, DuckDuckGo, phind.com. Also containes AI m
49
71
  - [10. `Reka` - chat with reka](#10-reka---chat-with-reka)
50
72
  - [11. `Cohere` - chat with cohere](#11-cohere---chat-with-cohere)
51
73
  - [12. `Xjai` - chat with free gpt 3.5](#12-xjai---chat-with-free-gpt-35)
74
+ - [`ThinkAny` - AI search engine](#thinkany---ai-search-engine)
52
75
  - [`LLM`](#llm)
53
76
  - [`LLM` with internet](#llm-with-internet)
54
77
  - [LLM with deepwebs](#llm-with-deepwebs)
@@ -734,7 +757,7 @@ print(response)
734
757
  ```python
735
758
  from webscout.AI import OPENGPT
736
759
 
737
- opengpt = OPENGPT(is_conversation=True, max_tokens=8000, timeout=30)
760
+ opengpt = OPENGPT(is_conversation=True, max_tokens=8000, timeout=30, assistant_id="bca37014-6f97-4f2b-8928-81ea8d478d88")
738
761
  while True:
739
762
  # Prompt the user for input
740
763
  prompt = input("Enter your prompt: ")
@@ -806,7 +829,31 @@ prompt = "Tell me about india"
806
829
  response = ai.chat(prompt)
807
830
  print(response)
808
831
  ```
832
+ ### `ThinkAny` - AI search engine
833
+ ```python
834
+ from webscout.AI import ThinkAnyAI
835
+
836
+ ai = ThinkAnyAI(
837
+ is_conversation=True,
838
+ max_tokens=800,
839
+ timeout=30,
840
+ intro=None,
841
+ filepath=None,
842
+ update_file=True,
843
+ proxies={},
844
+ history_offset=10250,
845
+ act=None,
846
+ web_search=False,
847
+ )
809
848
 
849
+ prompt = "what is meaning of life"
850
+
851
+ response = ai.ask(prompt)
852
+
853
+ # Extract and print the message from the response
854
+ message = ai.get_message(response)
855
+ print(message)
856
+ ```
810
857
  ### `LLM`
811
858
  ```python
812
859
  from webscout.LLM import LLM
@@ -1037,3 +1084,21 @@ if __name__ == "__main__":
1037
1084
  ```shell
1038
1085
  python -m webscout.webai webai --provider "phind" --rawdog
1039
1086
  ```
1087
+
1088
+ <div align="center">
1089
+ <!-- Replace `#` with your actual links -->
1090
+ <a href="https://t.me/devsdocode"><img alt="Telegram" src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white"></a>
1091
+ <a href="https://www.instagram.com/sree.shades_/"><img alt="Instagram" src="https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white"></a>
1092
+ <a href="https://www.linkedin.com/in/developer-sreejan/"><img alt="LinkedIn" src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white"></a>
1093
+ <a href="https://buymeacoffee.com/devsdocode"><img alt="Buy Me A Coffee" src="https://img.shields.io/badge/Buy%20Me%20A%20Coffee-FFDD00?style=for-the-badge&logo=buymeacoffee&logoColor=black"></a>
1094
+ </div>
1095
+
1096
+ <div align="center">
1097
+ <!-- Replace `#` with your actual links -->
1098
+ <a href="https://youtube.com/@@OEvortex">&#10148; Vortex's YouTube Channel</a>
1099
+ </div>
1100
+ <div align="center">
1101
+ <a href="https://youtube.com/@devsdocode">&#10148; Devs Do Code's YouTube Channel</a>
1102
+ </div>
1103
+
1104
+
@@ -5,7 +5,7 @@ with open("README.md", encoding="utf-8") as f:
5
5
 
6
6
  setup(
7
7
  name="webscout",
8
- version="1.4.3",
8
+ version="1.4.5",
9
9
  description="Search for anything using the Google, DuckDuckGo, phind.com. Also containes AI models, can transcribe yt videos, temporary email and phone number generation, have TTS support and webai(terminal gpt and open interpeter)",
10
10
  long_description=README,
11
11
  long_description_content_type="text/markdown",
@@ -25,9 +25,259 @@ from webscout.AIutel import AwesomePrompts, sanitize_stream
25
25
  from webscout.AIbase import Provider, AsyncProvider
26
26
  from Helpingai_T2 import Perplexity
27
27
  from webscout import exceptions
28
- from typing import Any, AsyncGenerator
28
+ from typing import Any, AsyncGenerator, Dict
29
29
  import logging
30
30
  import httpx
31
+ #------------------------------------ThinkAnyAI------------
32
+ class ThinkAnyAI(Provider):
33
+ def __init__(
34
+ self,
35
+ model: str = "claude-3-haiku",
36
+ locale: str = "en",
37
+ web_search: bool = False,
38
+ chunk_size: int = 1,
39
+ streaming: bool = True,
40
+ is_conversation: bool = True,
41
+ max_tokens: int = 600,
42
+ timeout: int = 30,
43
+ intro: str = None,
44
+ filepath: str = None,
45
+ update_file: bool = True,
46
+ proxies: dict = {},
47
+ history_offset: int = 10250,
48
+ act: str = None,
49
+ ):
50
+ """Initializes ThinkAnyAI
51
+
52
+ Args:
53
+ model (str): The AI model to be used for generating responses. Defaults to "claude-3-haiku".
54
+ locale (str): The language locale. Defaults to "en" (English).
55
+ web_search (bool): Whether to include web search results in the response. Defaults to False.
56
+ chunk_size (int): The size of data chunks when streaming responses. Defaults to 1.
57
+ streaming (bool): Whether to stream response data. Defaults to True.
58
+ is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
59
+ max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
60
+ timeout (int, optional): Http request timeout. Defaults to 30.
61
+ intro (str, optional): Conversation introductory prompt. Defaults to None.
62
+ filepath (str, optional): Path to file containing conversation history. Defaults to None.
63
+ update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
64
+ proxies (dict, optional): Http request proxies. Defaults to {}.
65
+ history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
66
+ act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
67
+ """
68
+ self.base_url = "https://thinkany.ai/api"
69
+ self.model = model
70
+ self.locale = locale
71
+ self.web_search = web_search
72
+ self.chunk_size = chunk_size
73
+ self.streaming = streaming
74
+ self.last_response = {}
75
+ self.session = requests.Session()
76
+ self.session.proxies = proxies
77
+
78
+ self.__available_optimizers = (
79
+ method
80
+ for method in dir(Optimizers)
81
+ if callable(getattr(Optimizers, method)) and not method.startswith("__")
82
+ )
83
+
84
+ Conversation.intro = (
85
+ AwesomePrompts().get_act(
86
+ act, raise_not_found=True, default=None, case_insensitive=True
87
+ )
88
+ if act
89
+ else intro or Conversation.intro
90
+ )
91
+ self.conversation = Conversation(
92
+ is_conversation, max_tokens, filepath, update_file
93
+ )
94
+ self.conversation.history_offset = history_offset
95
+
96
+ def ask(
97
+ self,
98
+ prompt: str,
99
+ stream: bool = False,
100
+ raw: bool = False,
101
+ optimizer: str = None,
102
+ conversationally: bool = False,
103
+ ) -> dict | AsyncGenerator:
104
+ """Chat with AI asynchronously.
105
+
106
+ Args:
107
+ prompt (str): Prompt to be send.
108
+ stream (bool, optional): Flag for streaming response. Defaults to False.
109
+ raw (bool, optional): Stream back raw response as received. Defaults to False.
110
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defeaults to None
111
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
112
+ Returns:
113
+ dict : {}
114
+ ```json
115
+ {
116
+ "content": "General Kenobi! \n\n(I couldn't help but respond with the iconic Star Wars greeting since you used it first. )\n\nIs there anything I can help you with today?\n[Image of Hello there General Kenobi]",
117
+ "conversation_id": "c_f13f6217f9a997aa",
118
+ "response_id": "r_d3665f95975c368f",
119
+ "factualityQueries": null,
120
+ "textQuery": [
121
+ "hello there",
122
+ 1
123
+ ],
124
+ "choices": [
125
+ {
126
+ "id": "rc_ea075c9671bfd8cb",
127
+ "content": [
128
+ "General Kenobi! \n\n(I couldn't help but respond with the iconic Star Wars greeting since you used it first. )\n\nIs there anything I can help you with today?\n[Image of Hello there General Kenobi]"
129
+ ]
130
+ },
131
+ {
132
+ "id": "rc_de6dd3fb793a5402",
133
+ "content": [
134
+ "General Kenobi! (or just a friendly hello, whichever you prefer!). \n\nI see you're a person of culture as well. *Star Wars* references are always appreciated. \n\nHow can I help you today?\n"
135
+ ]
136
+ },
137
+ {
138
+ "id": "rc_a672ac089caf32db",
139
+ "content": [
140
+ "General Kenobi! (or just a friendly hello if you're not a Star Wars fan!). \n\nHow can I help you today? Feel free to ask me anything, or tell me what you'd like to chat about. I'm here to assist in any way I can.\n[Image of Obi-Wan Kenobi saying hello there]"
141
+ ]
142
+ }
143
+ ],
144
+
145
+ "images": [
146
+ "https://i.pinimg.com/originals/40/74/60/407460925c9e419d82b93313f0b42f71.jpg"
147
+ ]
148
+ }
149
+
150
+ ```
151
+ """
152
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
153
+ if optimizer:
154
+ if optimizer in self.__available_optimizers:
155
+ conversation_prompt = getattr(Optimizers, optimizer)(
156
+ conversation_prompt if conversationally else prompt
157
+ )
158
+ else:
159
+ raise Exception(
160
+ f"Optimizer is not one of {self.__available_optimizers}"
161
+ )
162
+
163
+ def initiate_conversation(query: str) -> str:
164
+ """
165
+ Initiates a new conversation with the ThinkAny AI API.
166
+
167
+ Args:
168
+ query (str): The initial query to start the conversation.
169
+
170
+ Returns:
171
+ str: The UUID (Unique Identifier) of the conversation.
172
+ """
173
+ url = f"{self.base_url}/new-conversation"
174
+ payload = {
175
+ "content": query,
176
+ "locale": self.locale,
177
+ "mode": "search" if self.web_search else "chat",
178
+ "model": self.model,
179
+ "source": "all",
180
+ }
181
+ response = self.session.post(url, json=payload)
182
+ return response.json().get("data", {}).get("uuid", "DevsDoCode")
183
+
184
+ def RAG_search(uuid: str) -> tuple[bool, list]:
185
+ """
186
+ Performs a web search using the Retrieve And Generate (RAG) model.
187
+
188
+ Args:
189
+ uuid (str): The UUID of the conversation.
190
+
191
+ Returns:
192
+ tuple: A tuple containing a boolean indicating the success of the search
193
+ and a list of search result links.
194
+ """
195
+ if not self.web_search:
196
+ return True, []
197
+ url = f"{self.base_url}/rag-search"
198
+ payload = {"conv_uuid": uuid}
199
+ response = self.session.post(url, json=payload)
200
+ links = [source["link"] for source in response.json().get("data", [])]
201
+ return response.json().get("message", "").strip(), links
202
+
203
+ def for_stream():
204
+ conversation_uuid = initiate_conversation(conversation_prompt)
205
+ web_search_result, links = RAG_search(conversation_uuid)
206
+ if not web_search_result:
207
+ print("Failed to generate WEB response. Making normal Query...")
208
+
209
+ url = f"{self.base_url}/chat"
210
+ payload = {
211
+ "role": "user",
212
+ "content": prompt,
213
+ "conv_uuid": conversation_uuid,
214
+ "model": self.model,
215
+ }
216
+ response = self.session.post(url, json=payload, stream=True)
217
+ complete_content = ""
218
+ for content in response.iter_content(
219
+ decode_unicode=True, chunk_size=self.chunk_size
220
+ ):
221
+ complete_content += content
222
+ yield content if raw else dict(text=complete_content)
223
+ self.last_response.update(dict(text=complete_content, links=links))
224
+ self.conversation.update_chat_history(
225
+ prompt, self.get_message(self.last_response)
226
+ )
227
+
228
+ def for_non_stream():
229
+ for _ in for_stream():
230
+ pass
231
+ return self.last_response
232
+
233
+ return for_stream() if stream else for_non_stream()
234
+
235
+ def chat(
236
+ self,
237
+ prompt: str,
238
+ stream: bool = False,
239
+ optimizer: str = None,
240
+ conversationally: bool = False,
241
+ ) -> str:
242
+ """Generate response `str`
243
+ Args:
244
+ prompt (str): Prompt to be send.
245
+ stream (bool, optional): Flag for streaming response. Defaults to False.
246
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
247
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
248
+ Returns:
249
+ str: Response generated
250
+ """
251
+
252
+ def for_stream():
253
+ for response in self.ask(
254
+ prompt, True, optimizer=optimizer, conversationally=conversationally
255
+ ):
256
+ yield self.get_message(response)
257
+
258
+ def for_non_stream():
259
+ return self.get_message(
260
+ self.ask(
261
+ prompt,
262
+ False,
263
+ optimizer=optimizer,
264
+ conversationally=conversationally,
265
+ )
266
+ )
267
+
268
+ return for_stream() if stream else for_non_stream()
269
+
270
+ def get_message(self, response: Dict[str, Any]) -> str:
271
+ """Retrieves message only from response
272
+
273
+ Args:
274
+ response (dict): Response generated by `self.ask`
275
+
276
+ Returns:
277
+ str: Message extracted
278
+ """
279
+ assert isinstance(response, dict), "Response should be of dict data-type only"
280
+ return response["text"]
31
281
  #-----------------------------------------------xjai-------------------------------------------
32
282
  class Xjai(Provider):
33
283
  def __init__(
@@ -2802,6 +3052,7 @@ class AsyncKOBOLDAI(AsyncProvider):
2802
3052
  class OPENGPT:
2803
3053
  def __init__(
2804
3054
  self,
3055
+ assistant_id,
2805
3056
  is_conversation: bool = True,
2806
3057
  max_tokens: int = 600,
2807
3058
  timeout: int = 30,
@@ -2834,7 +3085,7 @@ class OPENGPT:
2834
3085
  self.stream_chunk_size = 64
2835
3086
  self.timeout = timeout
2836
3087
  self.last_response = {}
2837
- self.assistant_id = "bca37014-6f97-4f2b-8928-81ea8d478d88"
3088
+ self.assistant_id = assistant_id
2838
3089
  self.authority = "opengpts-example-vz4y4ooboq-uc.a.run.app"
2839
3090
 
2840
3091
  self.headers = {
@@ -3026,7 +3277,6 @@ class OPENGPT:
3026
3277
  str: Message extracted
3027
3278
  """
3028
3279
  assert isinstance(response, dict), "Response should be of dict data-type only"
3029
- return response["content"]
3030
3280
  class AsyncOPENGPT(AsyncProvider):
3031
3281
  def __init__(
3032
3282
  self,
@@ -18,6 +18,7 @@ from pathlib import Path
18
18
  from playsound import playsound
19
19
  from time import sleep as wait
20
20
  import pathlib
21
+ import urllib.parse
21
22
  appdir = appdirs.AppDirs("AIWEBS", "vortex")
22
23
 
23
24
  default_path = appdir.user_cache_dir
@@ -39,7 +40,8 @@ webai = [
39
40
  "cohere",
40
41
  "yepchat",
41
42
  "you",
42
- "xjai"
43
+ "xjai",
44
+ "thinkany"
43
45
  ]
44
46
 
45
47
  gpt4free_providers = [
@@ -938,7 +940,7 @@ class Audio:
938
940
  ), f"Voice '{voice}' not one of [{', '.join(cls.all_voices)}]"
939
941
  # Base URL for provider API
940
942
  url: str = (
941
- f"https://api.streamelements.com/kappa/v2/speech?voice={voice}&text={{{message}}}"
943
+ f"https://api.streamelements.com/kappa/v2/speech?voice={voice}&text={{{urllib.parse.quote(message)}}}"
942
944
  )
943
945
  resp = requests.get(url=url, headers=cls.headers, stream=True)
944
946
  if not resp.ok:
@@ -29,7 +29,8 @@ webai = [
29
29
  "cohere",
30
30
  "yepchat",
31
31
  "you",
32
- "xjai"
32
+ "xjai",
33
+ "thinkany"
33
34
  ]
34
35
 
35
36
  gpt4free_providers = [
@@ -4,7 +4,6 @@ from html import unescape
4
4
  from math import atan2, cos, radians, sin, sqrt
5
5
  from typing import Any, Dict, List, Union
6
6
  from urllib.parse import unquote
7
-
8
7
  import orjson
9
8
 
10
9
  from .exceptions import WebscoutE
@@ -0,0 +1,2 @@
1
+ __version__ = "1.4.5"
2
+
@@ -471,6 +471,20 @@ class Main(cmd.Cmd):
471
471
  history_offset=history_offset,
472
472
  act=awesome_prompt,
473
473
  )
474
+ elif provider == "thinkany":
475
+ from webscout.AI import ThinkAnyAI
476
+
477
+ self.bot = ThinkAnyAI(
478
+ is_conversation=disable_conversation,
479
+ max_tokens=max_tokens,
480
+ timeout=timeout,
481
+ intro=intro,
482
+ filepath=filepath,
483
+ update_file=update_file,
484
+ proxies=proxies,
485
+ history_offset=history_offset,
486
+ act=awesome_prompt,
487
+ )
474
488
  elif provider == "yepchat":
475
489
  from webscout.AI import YEPCHAT
476
490
 
@@ -981,7 +995,7 @@ class Main(cmd.Cmd):
981
995
  self.output_bond("Chat History", formatted_history, self.color)
982
996
  if click.confirm("Do you wish to save this chat"):
983
997
  save_to = click.prompt(
984
- "Enter path/file-name", default="llama-conversation.txt"
998
+ "Enter path/file-name", default=f"{self.provider}-chat.txt"
985
999
  )
986
1000
  with open(save_to, "a") as fh:
987
1001
  fh.write(history)
@@ -20,11 +20,19 @@ class WEBS(AsyncWEBS):
20
20
  def __init__(
21
21
  self,
22
22
  headers: Optional[Dict[str, str]] = None,
23
- proxies: Union[Dict[str, str], str, None] = None,
23
+ proxy: Optional[str] = None,
24
+ proxies: Union[Dict[str, str], str, None] = None, # deprecated
24
25
  timeout: Optional[int] = 10,
25
26
  ) -> None:
26
- super().__init__(headers=headers, proxies=proxies, timeout=timeout)
27
- self._exit_done = False
27
+ """Initialize the DDGS object.
28
+
29
+ Args:
30
+ headers (dict, optional): Dictionary of headers for the HTTP client. Defaults to None.
31
+ proxy (str, optional): proxy for the HTTP client, supports http/https/socks5 protocols.
32
+ example: "http://user:pass@example.com:3128". Defaults to None.
33
+ timeout (int, optional): Timeout value for the HTTP client. Defaults to 10.
34
+ """
35
+ super().__init__(headers=headers, proxy=proxy, proxies=proxies, timeout=timeout)
28
36
 
29
37
  def __enter__(self) -> "WEBS":
30
38
  return self
@@ -42,13 +50,8 @@ class WEBS(AsyncWEBS):
42
50
 
43
51
  def _close_session(self) -> None:
44
52
  """Close the curl-cffi async session."""
45
- if self._exit_done is False:
46
- # Ensure self._asession.close() is a coroutine
47
- coro = self._asession.close()
48
- # Check if coro is a coroutine object
49
- if asyncio.iscoroutine(coro):
50
- self._run_async_in_thread(coro)
51
- self._exit_done = True
53
+ if hasattr(self, "_asession") and self._asession._closed is False:
54
+ self._run_async_in_thread(self._asession.close()) # type: ignore
52
55
 
53
56
  def _run_async_in_thread(self, coro: Awaitable[Any]) -> Any:
54
57
  """Runs an async coroutine in a separate thread."""