webscout 5.5__py3-none-any.whl → 5.6__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.
Files changed (44) hide show
  1. webscout/Agents/Onlinesearcher.py +3 -3
  2. webscout/Agents/__init__.py +0 -1
  3. webscout/Agents/functioncall.py +3 -3
  4. webscout/Provider/Bing.py +243 -0
  5. webscout/Provider/Chatify.py +1 -1
  6. webscout/Provider/Cloudflare.py +1 -1
  7. webscout/Provider/DARKAI.py +1 -1
  8. webscout/Provider/DiscordRocks.py +109 -246
  9. webscout/Provider/Farfalle.py +1 -1
  10. webscout/Provider/Free2GPT.py +234 -0
  11. webscout/{Agents/ai.py → Provider/GPTWeb.py} +40 -33
  12. webscout/Provider/Llama3.py +65 -62
  13. webscout/Provider/OLLAMA.py +1 -1
  14. webscout/Provider/PizzaGPT.py +1 -1
  15. webscout/Provider/RUBIKSAI.py +13 -3
  16. webscout/Provider/TTI/Nexra.py +120 -0
  17. webscout/Provider/TTI/__init__.py +3 -1
  18. webscout/Provider/TTI/blackboximage.py +153 -0
  19. webscout/Provider/TTI/deepinfra.py +2 -2
  20. webscout/Provider/TeachAnything.py +1 -1
  21. webscout/Provider/Youchat.py +1 -1
  22. webscout/Provider/__init__.py +11 -6
  23. webscout/Provider/{NetFly.py → aigames.py} +76 -79
  24. webscout/Provider/cleeai.py +1 -1
  25. webscout/Provider/elmo.py +1 -1
  26. webscout/Provider/felo_search.py +1 -1
  27. webscout/Provider/genspark.py +1 -1
  28. webscout/Provider/julius.py +7 -1
  29. webscout/Provider/lepton.py +1 -1
  30. webscout/Provider/meta.py +1 -1
  31. webscout/Provider/turboseek.py +1 -1
  32. webscout/Provider/upstage.py +230 -0
  33. webscout/Provider/x0gpt.py +1 -1
  34. webscout/Provider/xdash.py +1 -1
  35. webscout/Provider/yep.py +2 -2
  36. webscout/version.py +1 -1
  37. webscout/webai.py +1 -1
  38. {webscout-5.5.dist-info → webscout-5.6.dist-info}/METADATA +5 -29
  39. {webscout-5.5.dist-info → webscout-5.6.dist-info}/RECORD +43 -39
  40. webscout/Provider/ThinkAnyAI.py +0 -219
  41. {webscout-5.5.dist-info → webscout-5.6.dist-info}/LICENSE.md +0 -0
  42. {webscout-5.5.dist-info → webscout-5.6.dist-info}/WHEEL +0 -0
  43. {webscout-5.5.dist-info → webscout-5.6.dist-info}/entry_points.txt +0 -0
  44. {webscout-5.5.dist-info → webscout-5.6.dist-info}/top_level.txt +0 -0
@@ -1,219 +0,0 @@
1
-
2
- import requests
3
-
4
- from webscout.AIutel import Optimizers
5
- from webscout.AIutel import Conversation
6
- from webscout.AIutel import AwesomePrompts, sanitize_stream
7
- from webscout.AIbase import Provider, AsyncProvider
8
- from webscout import exceptions
9
- from typing import Any, AsyncGenerator, Dict
10
-
11
- #------------------------------------ThinkAnyAI------------
12
- class ThinkAnyAI(Provider):
13
- def __init__(
14
- self,
15
- model: str = "claude-3-haiku",
16
- locale: str = "en",
17
- web_search: bool = True,
18
- chunk_size: int = 64,
19
- streaming: bool = True,
20
- is_conversation: bool = True,
21
- max_tokens: int = 600,
22
- timeout: int = 30,
23
- intro: str = None,
24
- filepath: str = None,
25
- update_file: bool = True,
26
- proxies: dict = {},
27
- history_offset: int = 10250,
28
- act: str = None,
29
- ):
30
- """Initializes ThinkAnyAI
31
-
32
- Args:
33
- model (str): The AI model to be used for generating responses. Defaults to "claude-3-haiku".
34
- locale (str): The language locale. Defaults to "en" (English).
35
- web_search (bool): Whether to include web search results in the response. Defaults to False.
36
- chunk_size (int): The size of data chunks when streaming responses. Defaults to 1.
37
- streaming (bool): Whether to stream response data. Defaults to True.
38
- is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
39
- max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
40
- timeout (int, optional): Http request timeout. Defaults to 30.
41
- intro (str, optional): Conversation introductory prompt. Defaults to None.
42
- filepath (str, optional): Path to file containing conversation history. Defaults to None.
43
- update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
44
- proxies (dict, optional): Http request proxies. Defaults to {}.
45
- history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
46
- act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
47
- """
48
- self.base_url = "https://thinkany.ai/api"
49
- self.model = model
50
- self.locale = locale
51
- self.web_search = web_search
52
- self.chunk_size = chunk_size
53
- self.streaming = streaming
54
- self.last_response = {}
55
- self.session = requests.Session()
56
- self.session.proxies = proxies
57
-
58
- self.__available_optimizers = (
59
- method
60
- for method in dir(Optimizers)
61
- if callable(getattr(Optimizers, method)) and not method.startswith("__")
62
- )
63
-
64
- Conversation.intro = (
65
- AwesomePrompts().get_act(
66
- act, raise_not_found=True, default=None, case_insensitive=True
67
- )
68
- if act
69
- else intro or Conversation.intro
70
- )
71
- self.conversation = Conversation(
72
- is_conversation, max_tokens, filepath, update_file
73
- )
74
- self.conversation.history_offset = history_offset
75
-
76
- def ask(
77
- self,
78
- prompt: str,
79
- stream: bool = False,
80
- raw: bool = False,
81
- optimizer: str = None,
82
- conversationally: bool = False,
83
- ) -> dict | AsyncGenerator:
84
-
85
- conversation_prompt = self.conversation.gen_complete_prompt(prompt)
86
- if optimizer:
87
- if optimizer in self.__available_optimizers:
88
- conversation_prompt = getattr(Optimizers, optimizer)(
89
- conversation_prompt if conversationally else prompt
90
- )
91
- else:
92
- raise Exception(
93
- f"Optimizer is not one of {self.__available_optimizers}"
94
- )
95
-
96
- def initiate_conversation(query: str) -> str:
97
- """
98
- Initiates a new conversation with the ThinkAny AI API.
99
-
100
- Args:
101
- query (str): The initial query to start the conversation.
102
-
103
- Returns:
104
- str: The UUID (Unique Identifier) of the conversation.
105
- """
106
- url = f"{self.base_url}/new-conversation"
107
- payload = {
108
- "content": query,
109
- "locale": self.locale,
110
- "mode": "search" if self.web_search else "chat",
111
- "model": self.model,
112
- "source": "all",
113
- }
114
- response = self.session.post(url, json=payload)
115
- return response.json().get("data", {}).get("uuid", "DevsDoCode")
116
-
117
- def RAG_search(uuid: str) -> tuple[bool, list]:
118
- """
119
- Performs a web search using the Retrieve And Generate (RAG) model.
120
-
121
- Args:
122
- uuid (str): The UUID of the conversation.
123
-
124
- Returns:
125
- tuple: A tuple containing a boolean indicating the success of the search
126
- and a list of search result links.
127
- """
128
- if not self.web_search:
129
- return True, []
130
- url = f"{self.base_url}/rag-search"
131
- payload = {"conv_uuid": uuid}
132
- response = self.session.post(url, json=payload)
133
- links = [source["link"] for source in response.json().get("data", [])]
134
- return response.json().get("message", "").strip(), links
135
-
136
- def for_stream():
137
- conversation_uuid = initiate_conversation(conversation_prompt)
138
- web_search_result, links = RAG_search(conversation_uuid)
139
- if not web_search_result:
140
- print("Failed to generate WEB response. Making normal Querywebscout..")
141
-
142
- url = f"{self.base_url}/chat"
143
- payload = {
144
- "role": "user",
145
- "content": prompt,
146
- "conv_uuid": conversation_uuid,
147
- "model": self.model,
148
- }
149
- response = self.session.post(url, json=payload, stream=True)
150
- complete_content = ""
151
- for content in response.iter_content(
152
- decode_unicode=True, chunk_size=self.chunk_size
153
- ):
154
- complete_content += content
155
- yield content if raw else dict(text=complete_content)
156
- self.last_response.update(dict(text=complete_content, links=links))
157
- self.conversation.update_chat_history(
158
- prompt, self.get_message(self.last_response)
159
- )
160
-
161
- def for_non_stream():
162
- for _ in for_stream():
163
- pass
164
- return self.last_response
165
-
166
- return for_stream() if stream else for_non_stream()
167
-
168
- def chat(
169
- self,
170
- prompt: str,
171
- stream: bool = False,
172
- optimizer: str = None,
173
- conversationally: bool = False,
174
- ) -> str:
175
- """Generate response `str`
176
- Args:
177
- prompt (str): Prompt to be send.
178
- stream (bool, optional): Flag for streaming response. Defaults to False.
179
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
180
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
181
- Returns:
182
- str: Response generated
183
- """
184
-
185
- def for_stream():
186
- for response in self.ask(
187
- prompt, True, optimizer=optimizer, conversationally=conversationally
188
- ):
189
- yield self.get_message(response)
190
-
191
- def for_non_stream():
192
- return self.get_message(
193
- self.ask(
194
- prompt,
195
- False,
196
- optimizer=optimizer,
197
- conversationally=conversationally,
198
- )
199
- )
200
-
201
- return for_stream() if stream else for_non_stream()
202
-
203
- def get_message(self, response: Dict[str, Any]) -> str:
204
- """Retrieves message only from response
205
-
206
- Args:
207
- response (dict): Response generated by `self.ask`
208
-
209
- Returns:
210
- str: Message extracted
211
- """
212
- assert isinstance(response, dict), "Response should be of dict data-type only"
213
- return response["text"]
214
- if __name__ == "__main__":
215
- from rich import print
216
- ai = ThinkAnyAI()
217
- response = ai.chat(input(">>> "))
218
- for chunk in response:
219
- print(chunk, end="", flush=True)
File without changes