webscout 6.2b0__py3-none-any.whl → 6.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.
- webscout/AIauto.py +191 -176
- webscout/AIbase.py +112 -239
- webscout/AIutel.py +488 -1130
- webscout/Agents/functioncall.py +248 -198
- webscout/Bing_search.py +250 -153
- webscout/DWEBS.py +454 -178
- webscout/Extra/__init__.py +2 -1
- webscout/Extra/autocoder/__init__.py +9 -0
- webscout/Extra/autocoder/autocoder_utiles.py +121 -0
- webscout/Extra/autocoder/rawdog.py +681 -0
- webscout/Extra/autollama.py +246 -195
- webscout/Extra/gguf.py +441 -226
- webscout/Extra/weather.py +172 -67
- webscout/LLM.py +442 -100
- webscout/Litlogger/__init__.py +681 -0
- webscout/Local/formats.py +4 -2
- webscout/Provider/Amigo.py +19 -10
- webscout/Provider/Andi.py +0 -33
- webscout/Provider/Blackboxai.py +4 -204
- webscout/Provider/DARKAI.py +1 -1
- webscout/Provider/EDITEE.py +1 -1
- webscout/Provider/Llama3.py +1 -1
- webscout/Provider/Marcus.py +137 -0
- webscout/Provider/NinjaChat.py +1 -1
- webscout/Provider/PI.py +221 -207
- webscout/Provider/Perplexity.py +598 -598
- webscout/Provider/RoboCoders.py +206 -0
- webscout/Provider/TTI/AiForce/__init__.py +22 -0
- webscout/Provider/TTI/AiForce/async_aiforce.py +257 -0
- webscout/Provider/TTI/AiForce/sync_aiforce.py +242 -0
- webscout/Provider/TTI/Nexra/__init__.py +22 -0
- webscout/Provider/TTI/Nexra/async_nexra.py +286 -0
- webscout/Provider/TTI/Nexra/sync_nexra.py +258 -0
- webscout/Provider/TTI/PollinationsAI/__init__.py +23 -0
- webscout/Provider/TTI/PollinationsAI/async_pollinations.py +330 -0
- webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +285 -0
- webscout/Provider/TTI/__init__.py +3 -4
- webscout/Provider/TTI/artbit/__init__.py +22 -0
- webscout/Provider/TTI/artbit/async_artbit.py +184 -0
- webscout/Provider/TTI/artbit/sync_artbit.py +176 -0
- webscout/Provider/TTI/blackbox/__init__.py +4 -0
- webscout/Provider/TTI/blackbox/async_blackbox.py +212 -0
- webscout/Provider/TTI/{blackboximage.py → blackbox/sync_blackbox.py} +199 -153
- webscout/Provider/TTI/deepinfra/__init__.py +4 -0
- webscout/Provider/TTI/deepinfra/async_deepinfra.py +227 -0
- webscout/Provider/TTI/deepinfra/sync_deepinfra.py +199 -0
- webscout/Provider/TTI/huggingface/__init__.py +22 -0
- webscout/Provider/TTI/huggingface/async_huggingface.py +199 -0
- webscout/Provider/TTI/huggingface/sync_huggingface.py +195 -0
- webscout/Provider/TTI/imgninza/__init__.py +4 -0
- webscout/Provider/TTI/imgninza/async_ninza.py +214 -0
- webscout/Provider/TTI/{imgninza.py → imgninza/sync_ninza.py} +209 -136
- webscout/Provider/TTI/talkai/__init__.py +4 -0
- webscout/Provider/TTI/talkai/async_talkai.py +229 -0
- webscout/Provider/TTI/talkai/sync_talkai.py +207 -0
- webscout/Provider/__init__.py +146 -132
- webscout/Provider/askmyai.py +158 -0
- webscout/Provider/cerebras.py +227 -206
- webscout/Provider/geminiapi.py +208 -198
- webscout/Provider/llama3mitril.py +180 -0
- webscout/Provider/llmchat.py +203 -0
- webscout/Provider/mhystical.py +176 -0
- webscout/Provider/perplexitylabs.py +265 -0
- webscout/Provider/talkai.py +196 -0
- webscout/Provider/twitterclone.py +251 -244
- webscout/Provider/typegpt.py +359 -0
- webscout/__init__.py +28 -23
- webscout/__main__.py +5 -5
- webscout/cli.py +327 -347
- webscout/conversation.py +227 -0
- webscout/exceptions.py +161 -29
- webscout/litagent/__init__.py +172 -0
- webscout/litprinter/__init__.py +831 -0
- webscout/optimizers.py +270 -0
- webscout/prompt_manager.py +279 -0
- webscout/swiftcli/__init__.py +810 -0
- webscout/transcriber.py +479 -551
- webscout/update_checker.py +125 -0
- webscout/version.py +1 -1
- webscout-6.4.dist-info/LICENSE.md +211 -0
- {webscout-6.2b0.dist-info → webscout-6.4.dist-info}/METADATA +34 -55
- webscout-6.4.dist-info/RECORD +154 -0
- webscout/Provider/TTI/AIuncensored.py +0 -103
- webscout/Provider/TTI/Nexra.py +0 -120
- webscout/Provider/TTI/PollinationsAI.py +0 -138
- webscout/Provider/TTI/WebSimAI.py +0 -142
- webscout/Provider/TTI/aiforce.py +0 -160
- webscout/Provider/TTI/artbit.py +0 -141
- webscout/Provider/TTI/deepinfra.py +0 -148
- webscout/Provider/TTI/huggingface.py +0 -155
- webscout/models.py +0 -23
- webscout-6.2b0.dist-info/LICENSE.md +0 -50
- webscout-6.2b0.dist-info/RECORD +0 -118
- /webscout/{g4f.py → gpt4free.py} +0 -0
- {webscout-6.2b0.dist-info → webscout-6.4.dist-info}/WHEEL +0 -0
- {webscout-6.2b0.dist-info → webscout-6.4.dist-info}/entry_points.txt +0 -0
- {webscout-6.2b0.dist-info → webscout-6.4.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import uuid
|
|
2
|
+
import requests
|
|
3
|
+
import json
|
|
4
|
+
from typing import Any, Dict, Optional, Generator
|
|
5
|
+
|
|
6
|
+
from webscout.AIutel import Optimizers
|
|
7
|
+
from webscout.AIutel import Conversation
|
|
8
|
+
from webscout.AIutel import AwesomePrompts
|
|
9
|
+
from webscout.AIbase import Provider
|
|
10
|
+
from webscout import exceptions
|
|
11
|
+
|
|
12
|
+
class Talkai(Provider):
|
|
13
|
+
"""
|
|
14
|
+
A class to interact with the Talkai.info API.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
is_conversation: bool = True,
|
|
20
|
+
max_tokens: int = 2048,
|
|
21
|
+
timeout: int = 30,
|
|
22
|
+
intro: str = None,
|
|
23
|
+
filepath: str = None,
|
|
24
|
+
update_file: bool = True,
|
|
25
|
+
proxies: dict = {},
|
|
26
|
+
history_offset: int = 10250,
|
|
27
|
+
act: str = None,
|
|
28
|
+
model: str = "gpt-4o-mini", # Default model
|
|
29
|
+
):
|
|
30
|
+
"""
|
|
31
|
+
Initializes the Talkai.info API with given parameters.
|
|
32
|
+
"""
|
|
33
|
+
self.session = requests.Session()
|
|
34
|
+
self.is_conversation = is_conversation
|
|
35
|
+
self.max_tokens_to_sample = max_tokens
|
|
36
|
+
self.api_endpoint = "https://talkai.info/chat/send/"
|
|
37
|
+
self.timeout = timeout
|
|
38
|
+
self.last_response = {}
|
|
39
|
+
self.model = model
|
|
40
|
+
self.headers = {
|
|
41
|
+
'Accept': 'application/json, text/event-stream',
|
|
42
|
+
'Accept-Language': 'en-US,en;q=0.9,en-IN;q=0.8',
|
|
43
|
+
'Content-Type': 'application/json',
|
|
44
|
+
'Origin': 'https://talkai.info',
|
|
45
|
+
'Referer': 'https://talkai.info/chat/',
|
|
46
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0',
|
|
47
|
+
'sec-ch-ua': '"Chromium";v="130", "Microsoft Edge";v="130", "Not?A_Brand";v="99"',
|
|
48
|
+
'sec-ch-ua-platform': '"Windows"'
|
|
49
|
+
}
|
|
50
|
+
self.__available_optimizers = (
|
|
51
|
+
method
|
|
52
|
+
for method in dir(Optimizers)
|
|
53
|
+
if callable(getattr(Optimizers, method)) and not method.startswith("__")
|
|
54
|
+
)
|
|
55
|
+
Conversation.intro = (
|
|
56
|
+
AwesomePrompts().get_act(
|
|
57
|
+
act, raise_not_found=True, default=None, case_insensitive=True
|
|
58
|
+
)
|
|
59
|
+
if act
|
|
60
|
+
else intro or Conversation.intro
|
|
61
|
+
)
|
|
62
|
+
self.conversation = Conversation(
|
|
63
|
+
is_conversation, self.max_tokens_to_sample, filepath, update_file
|
|
64
|
+
)
|
|
65
|
+
self.conversation.history_offset = history_offset
|
|
66
|
+
self.session.proxies = proxies
|
|
67
|
+
|
|
68
|
+
def ask(
|
|
69
|
+
self,
|
|
70
|
+
prompt: str,
|
|
71
|
+
stream: bool = False,
|
|
72
|
+
raw: bool = False,
|
|
73
|
+
optimizer: str = None,
|
|
74
|
+
conversationally: bool = False,
|
|
75
|
+
) -> Dict[str, Any]:
|
|
76
|
+
"""Chat with Talkai
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
prompt (str): Prompt to be sent.
|
|
80
|
+
stream (bool, optional): Flag for streaming response. Defaults to False.
|
|
81
|
+
raw (bool, optional): Stream back raw response as received. Defaults to False.
|
|
82
|
+
optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
|
|
83
|
+
conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
|
|
84
|
+
Returns:
|
|
85
|
+
dict: Response dictionary.
|
|
86
|
+
"""
|
|
87
|
+
conversation_prompt = self.conversation.gen_complete_prompt(prompt)
|
|
88
|
+
if optimizer:
|
|
89
|
+
if optimizer in self.__available_optimizers:
|
|
90
|
+
conversation_prompt = getattr(Optimizers, optimizer)(
|
|
91
|
+
conversation_prompt if conversationally else prompt
|
|
92
|
+
)
|
|
93
|
+
else:
|
|
94
|
+
raise exceptions.FailedToGenerateResponseError(
|
|
95
|
+
f"Optimizer is not one of {self.__available_optimizers}"
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
payload = {
|
|
99
|
+
"type": "chat",
|
|
100
|
+
"messagesHistory": [
|
|
101
|
+
{
|
|
102
|
+
"id": str(uuid.uuid4()),
|
|
103
|
+
"from": "you",
|
|
104
|
+
"content": conversation_prompt
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"settings": {
|
|
108
|
+
"model": self.model
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
def for_stream():
|
|
113
|
+
try:
|
|
114
|
+
with requests.post(self.api_endpoint, headers=self.headers, json=payload, stream=True, timeout=self.timeout) as response:
|
|
115
|
+
response.raise_for_status()
|
|
116
|
+
|
|
117
|
+
full_response = ""
|
|
118
|
+
for line in response.iter_lines():
|
|
119
|
+
if line:
|
|
120
|
+
decoded_line = line.decode('utf-8')
|
|
121
|
+
if 'event: trylimit' in decoded_line:
|
|
122
|
+
break # Stop if trylimit event is encountered
|
|
123
|
+
if decoded_line.startswith('data: '):
|
|
124
|
+
data = decoded_line[6:] # Remove 'data: ' prefix
|
|
125
|
+
full_response += data
|
|
126
|
+
yield data if raw else dict(text=data)
|
|
127
|
+
|
|
128
|
+
self.last_response.update(dict(text=full_response))
|
|
129
|
+
self.conversation.update_chat_history(
|
|
130
|
+
prompt, self.get_message(self.last_response)
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
except requests.exceptions.RequestException as e:
|
|
134
|
+
raise exceptions.FailedToGenerateResponseError(f"Request failed: {e}")
|
|
135
|
+
|
|
136
|
+
def for_non_stream():
|
|
137
|
+
full_response = ""
|
|
138
|
+
for line in for_stream():
|
|
139
|
+
full_response += line['text'] if not raw else line
|
|
140
|
+
return dict(text=full_response)
|
|
141
|
+
|
|
142
|
+
return for_stream() if stream else for_non_stream()
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def chat(
|
|
146
|
+
self,
|
|
147
|
+
prompt: str,
|
|
148
|
+
stream: bool = False,
|
|
149
|
+
optimizer: str = None,
|
|
150
|
+
conversationally: bool = False,
|
|
151
|
+
) -> str | Generator[str, None, None]:
|
|
152
|
+
"""Generate response `str`
|
|
153
|
+
Args:
|
|
154
|
+
prompt (str): Prompt to be send.
|
|
155
|
+
stream (bool, optional): Flag for streaming response. Defaults to False.
|
|
156
|
+
optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
|
|
157
|
+
conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
|
|
158
|
+
Returns:
|
|
159
|
+
str: Response generated
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
def for_stream():
|
|
163
|
+
for response in self.ask(
|
|
164
|
+
prompt, True, optimizer=optimizer, conversationally=conversationally
|
|
165
|
+
):
|
|
166
|
+
yield self.get_message(response)
|
|
167
|
+
|
|
168
|
+
def for_non_stream():
|
|
169
|
+
return self.get_message(
|
|
170
|
+
self.ask(
|
|
171
|
+
prompt,
|
|
172
|
+
False,
|
|
173
|
+
optimizer=optimizer,
|
|
174
|
+
conversationally=conversationally,
|
|
175
|
+
)
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
return for_stream() if stream else for_non_stream()
|
|
179
|
+
|
|
180
|
+
def get_message(self, response: Dict[str, Any]) -> str:
|
|
181
|
+
"""Retrieves message only from response.
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
response (dict): Response generated by `self.ask`
|
|
185
|
+
|
|
186
|
+
Returns:
|
|
187
|
+
str: Message extracted.
|
|
188
|
+
"""
|
|
189
|
+
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
190
|
+
return response["text"].replace('\\n', '\n').replace('\\n\\n', '\n\n')
|
|
191
|
+
|
|
192
|
+
if __name__ == "__main__":
|
|
193
|
+
t = Talkai()
|
|
194
|
+
resp = t.chat("write me about AI", stream=True)
|
|
195
|
+
for chunk in resp:
|
|
196
|
+
print(chunk, end="", flush=True)
|