webscout 5.9__py3-none-any.whl → 6.1__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 (57) hide show
  1. webscout/Agents/Onlinesearcher.py +22 -10
  2. webscout/Agents/functioncall.py +2 -2
  3. webscout/Bard.py +21 -21
  4. webscout/Local/__init__.py +6 -7
  5. webscout/Local/formats.py +404 -194
  6. webscout/Local/model.py +1074 -477
  7. webscout/Local/samplers.py +108 -144
  8. webscout/Local/thread.py +251 -410
  9. webscout/Local/ui.py +401 -0
  10. webscout/Local/utils.py +308 -131
  11. webscout/Provider/Amigo.py +5 -3
  12. webscout/Provider/ChatHub.py +209 -0
  13. webscout/Provider/Chatify.py +3 -3
  14. webscout/Provider/Cloudflare.py +3 -3
  15. webscout/Provider/DARKAI.py +1 -1
  16. webscout/Provider/Deepinfra.py +95 -389
  17. webscout/Provider/Deepseek.py +4 -6
  18. webscout/Provider/DiscordRocks.py +3 -3
  19. webscout/Provider/Free2GPT.py +3 -3
  20. webscout/Provider/NinjaChat.py +200 -0
  21. webscout/Provider/OLLAMA.py +4 -4
  22. webscout/Provider/RUBIKSAI.py +3 -3
  23. webscout/Provider/TTI/Nexra.py +3 -3
  24. webscout/Provider/TTI/__init__.py +2 -1
  25. webscout/Provider/TTI/aiforce.py +2 -2
  26. webscout/Provider/TTI/imgninza.py +136 -0
  27. webscout/Provider/Youchat.py +4 -5
  28. webscout/Provider/__init__.py +13 -6
  29. webscout/Provider/ai4chat.py +3 -2
  30. webscout/Provider/aimathgpt.py +193 -0
  31. webscout/Provider/bagoodex.py +145 -0
  32. webscout/Provider/bixin.py +3 -3
  33. webscout/Provider/cleeai.py +3 -3
  34. webscout/Provider/elmo.py +2 -5
  35. webscout/Provider/felo_search.py +1 -1
  36. webscout/Provider/gaurish.py +168 -0
  37. webscout/Provider/geminiprorealtime.py +160 -0
  38. webscout/Provider/julius.py +10 -40
  39. webscout/Provider/llamatutor.py +2 -2
  40. webscout/Provider/prefind.py +3 -3
  41. webscout/Provider/promptrefine.py +3 -3
  42. webscout/Provider/turboseek.py +1 -1
  43. webscout/Provider/twitterclone.py +25 -41
  44. webscout/Provider/upstage.py +3 -3
  45. webscout/Provider/x0gpt.py +6 -6
  46. webscout/exceptions.py +5 -1
  47. webscout/utils.py +3 -0
  48. webscout/version.py +1 -1
  49. webscout/webscout_search.py +154 -123
  50. {webscout-5.9.dist-info → webscout-6.1.dist-info}/METADATA +132 -157
  51. {webscout-5.9.dist-info → webscout-6.1.dist-info}/RECORD +55 -49
  52. {webscout-5.9.dist-info → webscout-6.1.dist-info}/WHEEL +1 -1
  53. webscout/Local/rawdog.py +0 -946
  54. webscout/Provider/Poe.py +0 -208
  55. {webscout-5.9.dist-info → webscout-6.1.dist-info}/LICENSE.md +0 -0
  56. {webscout-5.9.dist-info → webscout-6.1.dist-info}/entry_points.txt +0 -0
  57. {webscout-5.9.dist-info → webscout-6.1.dist-info}/top_level.txt +0 -0
webscout/Provider/Poe.py DELETED
@@ -1,208 +0,0 @@
1
- from poe_api_wrapper import PoeApi
2
- from poe_api_wrapper.api import BOTS_LIST
3
- from ..AIbase import Provider
4
- from ..AIutel import Conversation
5
- from ..AIutel import Optimizers
6
- from ..AIutel import AwesomePrompts
7
- from pathlib import Path
8
- from json import loads
9
- from json import dumps
10
- from loguru import logger
11
- import logging
12
-
13
- logger.remove()
14
-
15
-
16
- class POE(Provider):
17
- def __init__(
18
- self,
19
- cookie: str,
20
- model: str = "Assistant",
21
- proxy: bool = False,
22
- timeout: int = 30,
23
- filepath: str = None,
24
- update_file: str = True,
25
- intro: str = None,
26
- act: str = None,
27
- init: bool = True,
28
- ):
29
- """Initializes POE
30
-
31
- Args:
32
- cookie (str): Path to `poe.com.cookies.json` file or 'p-b' cookie-value.
33
- model (str, optional): Model name. Default to Assistant.
34
- proxy (bool, optional): Flag for Httpx request proxy. Defaults to False.
35
- timeout (int, optional): Http request timeout. Defaults to 30.
36
- filepath (str, optional): Path to save the chat history. Defaults to None.
37
- update_file (str, optional): Flag for controlling chat history updates. Defaults to True.
38
- intro (str, optional): Conversation introductory prompt. Defaults to None.
39
- act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
40
- init (bool, optional): Resend the intro prompt. Defaults to True.
41
- """
42
- assert isinstance(
43
- cookie, str
44
- ), f"Cookie must be of {str} datatype only not {type(cookie)}"
45
- assert (
46
- model in BOTS_LIST.keys()
47
- ), f"model name '{model}' is not one of {', '.join(list(BOTS_LIST.keys()))}"
48
- cookie_path = Path(cookie)
49
-
50
- if cookie_path.exists() or any(["/" in cookie, ".json" in cookie]):
51
- cookie = None
52
- all_cookies = loads(cookie_path.read_text())
53
- for entry in all_cookies:
54
- if entry["name"] == "p-b":
55
- cookie = entry["value"]
56
- assert (
57
- cookie
58
- ), f'Required cookie value cannot be retrieved from the path "{cookie_path.as_posix()}"'
59
-
60
- if proxy:
61
- import poe_api_wrapper.proxies as proxies
62
-
63
- proxies.PROXY = True
64
-
65
- self.bot = BOTS_LIST[model]
66
- self.session = PoeApi(cookie)
67
- self.last_response = {}
68
- self.__available_optimizers = (
69
- method
70
- for method in dir(Optimizers)
71
- if callable(getattr(Optimizers, method)) and not method.startswith("__")
72
- )
73
- Conversation.intro = (
74
- AwesomePrompts().get_act(
75
- act, raise_not_found=True, default=None, case_insensitive=True
76
- )
77
- if act
78
- else intro or Conversation.intro
79
- )
80
- self.conversation = Conversation(
81
- status=False, filepath=filepath, update_file=update_file
82
- )
83
- if init:
84
- self.ask(self.conversation.intro) # Init
85
-
86
- def ask(
87
- self,
88
- prompt: str,
89
- stream: bool = False,
90
- raw: bool = False,
91
- optimizer: str = None,
92
- conversationally: bool = False,
93
- ) -> dict:
94
- """Chat with AI
95
-
96
- Args:
97
- prompt (str): Prompt to be send.
98
- stream (bool, optional): Flag for streaming response. Defaults to False.
99
- raw (bool, optional): Stream back raw response as received. Defaults to False.
100
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defeaults to None
101
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
102
- Returns:
103
- dict : {}
104
- ```json
105
- {
106
- "id": "TWVzc2FnZToxMTU0MzgyNDQ1ODU=",
107
- "messageId": 115438244585,
108
- "creationTime": 1707777376544407,
109
- "clientNonce": null,
110
- "state": "complete",
111
- "text": "Hello! How can I assist you today?",
112
- "author": "capybara",
113
- "contentType": "text_markdown",
114
- "sourceType": "chat_input",
115
- "attachmentTruncationState": "not_truncated",
116
- "attachments": [],
117
- "vote": null,
118
- "suggestedReplies": [],
119
- "hasCitations": false,
120
- "__isNode": "Message",
121
- "textLengthOnCancellation": null,
122
- "chatCode": "21a2jn0yrq9phxiy478",
123
- "chatId": 328236777,
124
- "title": null,
125
- "response": ""
126
- }
127
- ```
128
- """
129
- conversation_prompt = self.conversation.gen_complete_prompt(prompt)
130
- if optimizer:
131
- if optimizer in self.__available_optimizers:
132
- conversation_prompt = getattr(Optimizers, optimizer)(
133
- conversation_prompt if conversationally else prompt
134
- )
135
- else:
136
- raise Exception(
137
- f"Optimizer is not one of {self.__available_optimizers}"
138
- )
139
-
140
- def for_stream():
141
- for response in self.session.send_message(self.bot, conversation_prompt):
142
- if raw:
143
- yield dumps(response)
144
- else:
145
- yield response
146
-
147
- self.last_response.update(response)
148
-
149
- self.conversation.update_chat_history(
150
- prompt,
151
- self.get_message(self.last_response),
152
- force=True,
153
- )
154
-
155
- def for_non_stream():
156
- # let's make use of stream
157
- for _ in for_stream():
158
- pass
159
- return self.last_response
160
-
161
- return for_stream() if stream else for_non_stream()
162
-
163
- def chat(
164
- self,
165
- prompt: str,
166
- stream: bool = False,
167
- optimizer: str = None,
168
- conversationally: bool = False,
169
- ) -> str:
170
- """Generate response `str`
171
- Args:
172
- prompt (str): Prompt to be send.
173
- stream (bool, optional): Flag for streaming response. Defaults to False.
174
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
175
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
176
- Returns:
177
- str: Response generated
178
- """
179
-
180
- def for_stream():
181
- for response in self.ask(
182
- prompt, True, optimizer=optimizer, conversationally=conversationally
183
- ):
184
- yield self.get_message(response)
185
-
186
- def for_non_stream():
187
- return self.get_message(
188
- self.ask(
189
- prompt,
190
- False,
191
- optimizer=optimizer,
192
- conversationally=conversationally,
193
- )
194
- )
195
-
196
- return for_stream() if stream else for_non_stream()
197
-
198
- def get_message(self, response: dict) -> str:
199
- """Retrieves message only from response
200
-
201
- Args:
202
- response (dict): Response generated by `self.ask`
203
-
204
- Returns:
205
- str: Message extracted
206
- """
207
- assert isinstance(response, dict), "Response should be of dict data-type only"
208
- return response["text"]