webscout 2.8__py3-none-any.whl → 3.0b0__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/AIutel.py +1 -0
- webscout/Local/_version.py +1 -1
- webscout/Local/model.py +75 -4
- webscout/Local/thread.py +13 -2
- webscout/Local/utils.py +3 -2
- webscout/Provider/__init__.py +3 -2
- webscout/__init__.py +1 -0
- webscout/version.py +1 -1
- {webscout-2.8.dist-info → webscout-3.0b0.dist-info}/METADATA +2 -1
- {webscout-2.8.dist-info → webscout-3.0b0.dist-info}/RECORD +14 -14
- {webscout-2.8.dist-info → webscout-3.0b0.dist-info}/LICENSE.md +0 -0
- {webscout-2.8.dist-info → webscout-3.0b0.dist-info}/WHEEL +0 -0
- {webscout-2.8.dist-info → webscout-3.0b0.dist-info}/entry_points.txt +0 -0
- {webscout-2.8.dist-info → webscout-3.0b0.dist-info}/top_level.txt +0 -0
webscout/AIutel.py
CHANGED
webscout/Local/_version.py
CHANGED
webscout/Local/model.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import json
|
|
1
2
|
from ._version import __version__, __llama_cpp_version__
|
|
2
3
|
|
|
3
4
|
"""Submodule containing the Model class to work with language models"""
|
|
@@ -15,7 +16,7 @@ from .utils import (
|
|
|
15
16
|
|
|
16
17
|
from .samplers import SamplerSettings, DefaultSampling
|
|
17
18
|
from llama_cpp import Llama, StoppingCriteriaList
|
|
18
|
-
from typing import Generator, Optional, Union
|
|
19
|
+
from typing import Callable, Generator, Optional, Union
|
|
19
20
|
from os.path import isdir, exists
|
|
20
21
|
from heapq import nlargest
|
|
21
22
|
|
|
@@ -68,7 +69,7 @@ class Model:
|
|
|
68
69
|
n_gpu_layers: int = 0,
|
|
69
70
|
offload_kqv: bool = True,
|
|
70
71
|
flash_attn: bool = False,
|
|
71
|
-
verbose: bool = False
|
|
72
|
+
verbose: bool = False,
|
|
72
73
|
):
|
|
73
74
|
"""
|
|
74
75
|
Given the path to a GGUF file, construct a Model instance.
|
|
@@ -105,7 +106,7 @@ class Model:
|
|
|
105
106
|
self._offload_kqv = offload_kqv
|
|
106
107
|
self._flash_attn = flash_attn
|
|
107
108
|
self._verbose = self.verbose = verbose
|
|
108
|
-
|
|
109
|
+
self.tools = {}
|
|
109
110
|
# if context_length <= 0, use n_ctx_train
|
|
110
111
|
if isinstance(context_length, int) and context_length <= 0:
|
|
111
112
|
context_length = None
|
|
@@ -269,7 +270,77 @@ class Model:
|
|
|
269
270
|
print_verbose(f"param: self.context_length == {self.context_length}")
|
|
270
271
|
print_verbose(f" gguf: rope_freq_base_train == {rope_freq_base_train}")
|
|
271
272
|
print_verbose(f"param: rope_freq_base == {rope_freq_base}")
|
|
272
|
-
|
|
273
|
+
def register_tool(self, name: str, function: Callable):
|
|
274
|
+
"""
|
|
275
|
+
Registers a tool for function calling.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
name: The name of the tool.
|
|
279
|
+
function: The Python function to execute when the tool is called.
|
|
280
|
+
"""
|
|
281
|
+
self.tools[name] = function
|
|
282
|
+
|
|
283
|
+
def _extract_tool_code(self, text: str) -> dict:
|
|
284
|
+
"""
|
|
285
|
+
Extracts tool code from the model's output using the chatml-function-calling format.
|
|
286
|
+
|
|
287
|
+
Args:
|
|
288
|
+
text: The model's generated text.
|
|
289
|
+
|
|
290
|
+
Returns:
|
|
291
|
+
A dictionary containing the tool name and arguments, or None if no tool call is found.
|
|
292
|
+
"""
|
|
293
|
+
try:
|
|
294
|
+
# Assuming tool code is enclosed in ```tool_code\n...\n```tool_code```
|
|
295
|
+
start = text.find("```tool_code\n") + len("```tool_code\n")
|
|
296
|
+
end = text.find("\n```tool_code```")
|
|
297
|
+
tool_code_json = text[start:end]
|
|
298
|
+
tool_code = json.loads(tool_code_json)
|
|
299
|
+
return tool_code
|
|
300
|
+
except (ValueError, json.JSONDecodeError):
|
|
301
|
+
return None
|
|
302
|
+
|
|
303
|
+
def generate(
|
|
304
|
+
self,
|
|
305
|
+
prompt: Union[str, list[int]],
|
|
306
|
+
stops: list[Union[str, int]] = [],
|
|
307
|
+
sampler: SamplerSettings = DefaultSampling
|
|
308
|
+
) -> str:
|
|
309
|
+
"""
|
|
310
|
+
Given a prompt, return a generated string, potentially calling and executing tools.
|
|
311
|
+
|
|
312
|
+
Args:
|
|
313
|
+
prompt: The text from which to generate.
|
|
314
|
+
stops: A list of strings and/or token IDs at which to end the generation early.
|
|
315
|
+
sampler: The SamplerSettings object used to control text generation.
|
|
316
|
+
|
|
317
|
+
Returns:
|
|
318
|
+
The generated string.
|
|
319
|
+
"""
|
|
320
|
+
assert_model_is_loaded(self)
|
|
321
|
+
response_text = self.llama.create_completion(
|
|
322
|
+
prompt,
|
|
323
|
+
max_tokens=sampler.max_len_tokens,
|
|
324
|
+
temperature=sampler.temp,
|
|
325
|
+
top_p=sampler.top_p,
|
|
326
|
+
min_p=sampler.min_p,
|
|
327
|
+
frequency_penalty=sampler.frequency_penalty,
|
|
328
|
+
presence_penalty=sampler.presence_penalty,
|
|
329
|
+
repeat_penalty=sampler.repeat_penalty,
|
|
330
|
+
top_k=sampler.top_k,
|
|
331
|
+
stop=stops
|
|
332
|
+
)['choices'][0]['text']
|
|
333
|
+
|
|
334
|
+
tool_code = self._extract_tool_code(response_text)
|
|
335
|
+
if tool_code:
|
|
336
|
+
# Execute the tool and get its output
|
|
337
|
+
tool_name = tool_code.get("function", {}).get("name")
|
|
338
|
+
arguments = tool_code.get("function", {}).get("arguments", "")
|
|
339
|
+
if tool_name and arguments and tool_name in self.tools:
|
|
340
|
+
tool_output = self.tools[tool_name](**json.loads(arguments))
|
|
341
|
+
# Append the tool output to the response
|
|
342
|
+
response_text += f"\n{tool_output}"
|
|
343
|
+
return response_text
|
|
273
344
|
def __repr__(self) -> str:
|
|
274
345
|
return \
|
|
275
346
|
f"Model({repr(self._model_path)}, " + \
|
webscout/Local/thread.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import json
|
|
1
2
|
from ._version import __version__, __llama_cpp_version__
|
|
2
3
|
|
|
3
4
|
"""Submodule containing the Thread class, used for interaction with a Model"""
|
|
@@ -80,7 +81,9 @@ class Thread:
|
|
|
80
81
|
format: Union[dict, AdvancedFormat],
|
|
81
82
|
sampler: SamplerSettings = DefaultSampling,
|
|
82
83
|
messages: Optional[list[Message]] = None,
|
|
84
|
+
|
|
83
85
|
):
|
|
86
|
+
|
|
84
87
|
"""
|
|
85
88
|
Given a Model and a format, construct a Thread instance.
|
|
86
89
|
|
|
@@ -141,7 +144,7 @@ class Thread:
|
|
|
141
144
|
self.create_message("system", self.format['system_content'])
|
|
142
145
|
] if self._messages is None else self._messages
|
|
143
146
|
self.sampler: SamplerSettings = sampler
|
|
144
|
-
|
|
147
|
+
self.tools = []
|
|
145
148
|
if self.model.verbose:
|
|
146
149
|
print_verbose("new Thread instance with the following attributes:")
|
|
147
150
|
print_verbose(f"model == {self.model}")
|
|
@@ -162,8 +165,16 @@ class Thread:
|
|
|
162
165
|
print_verbose(f"sampler.presence_penalty == {self.sampler.presence_penalty}")
|
|
163
166
|
print_verbose(f"sampler.repeat_penalty == {self.sampler.repeat_penalty}")
|
|
164
167
|
print_verbose(f"sampler.top_k == {self.sampler.top_k}")
|
|
165
|
-
|
|
168
|
+
def add_tool(self, tool: dict):
|
|
169
|
+
"""
|
|
170
|
+
Adds a tool to the Thread for function calling.
|
|
171
|
+
... (Rest of your add_tool docstring)
|
|
172
|
+
"""
|
|
173
|
+
self.tools.append(tool)
|
|
174
|
+
self.model.register_tool(tool['function']['name'], tool['function'].get('execute', None))
|
|
166
175
|
|
|
176
|
+
# Include tool information in the system message
|
|
177
|
+
self.messages[0]['content'] += f"\nYou have access to the following tool:\n```tool_code\n{json.dumps(tool)}\n```tool_code"
|
|
167
178
|
def __repr__(self) -> str:
|
|
168
179
|
return \
|
|
169
180
|
f"Thread({repr(self.model)}, {repr(self.format)}, " + \
|
webscout/Local/utils.py
CHANGED
|
@@ -25,18 +25,19 @@ class _ArrayLike(Iterable):
|
|
|
25
25
|
class _SupportsWriteAndFlush(TextIO):
|
|
26
26
|
pass
|
|
27
27
|
|
|
28
|
-
def download_model(repo_id: str, filename: str, cache_dir: str = ".cache") -> str:
|
|
28
|
+
def download_model(repo_id: str, filename: str, token: str, cache_dir: str = ".cache") -> str:
|
|
29
29
|
"""
|
|
30
30
|
Downloads a GGUF model file from Hugging Face Hub.
|
|
31
31
|
|
|
32
32
|
repo_id: The Hugging Face repository ID (e.g., 'facebook/bart-large-cnn').
|
|
33
33
|
filename: The name of the GGUF file within the repository (e.g., 'model.gguf').
|
|
34
|
+
token: The Hugging Face token for authentication.
|
|
34
35
|
cache_dir: The directory where the downloaded file should be stored.
|
|
35
36
|
|
|
36
37
|
Returns: The path to the downloaded file.
|
|
37
38
|
"""
|
|
38
39
|
url = hf_hub_url(repo_id, filename)
|
|
39
|
-
filepath = cached_download(url, cache_dir=cache_dir, force_filename=filename)
|
|
40
|
+
filepath = cached_download(url, cache_dir=cache_dir, force_filename=filename, use_auth_token=token)
|
|
40
41
|
return filepath
|
|
41
42
|
|
|
42
43
|
class GGUFReader:
|
webscout/Provider/__init__.py
CHANGED
|
@@ -28,7 +28,7 @@ from .Gemini import GEMINI
|
|
|
28
28
|
from .Berlin4h import Berlin4h
|
|
29
29
|
from .ChatGPTUK import ChatGPTUK
|
|
30
30
|
from .Poe import POE
|
|
31
|
-
from .BasedGPT import
|
|
31
|
+
from .BasedGPT import BasedGPT
|
|
32
32
|
__all__ = [
|
|
33
33
|
'ThinkAnyAI',
|
|
34
34
|
'Xjai',
|
|
@@ -57,5 +57,6 @@ __all__ = [
|
|
|
57
57
|
'GEMINI',
|
|
58
58
|
'Berlin4h',
|
|
59
59
|
'ChatGPTUK',
|
|
60
|
-
'POE'
|
|
60
|
+
'POE',
|
|
61
|
+
'BasedGPT',
|
|
61
62
|
]
|
webscout/__init__.py
CHANGED
webscout/version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "2.
|
|
1
|
+
__version__ = "2.9"
|
|
2
2
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: webscout
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0b0
|
|
4
4
|
Summary: Search for anything using Google, DuckDuckGo, phind.com, Contains AI models, can transcribe yt videos, temporary email and phone number generation, has TTS support, webai (terminal gpt and open interpreter) and offline LLMs
|
|
5
5
|
Author: OEvortex
|
|
6
6
|
Author-email: helpingai5@gmail.com
|
|
@@ -61,6 +61,7 @@ Provides-Extra: local
|
|
|
61
61
|
Requires-Dist: llama-cpp-python ; extra == 'local'
|
|
62
62
|
Requires-Dist: colorama ; extra == 'local'
|
|
63
63
|
Requires-Dist: numpy ; extra == 'local'
|
|
64
|
+
Requires-Dist: huggingface-hub ; extra == 'local'
|
|
64
65
|
|
|
65
66
|
<div align="center">
|
|
66
67
|
<!-- Replace `#` with your actual links -->
|
|
@@ -12,10 +12,10 @@ DeepWEBS/utilsdw/enver.py,sha256=vpI7s4_o_VL9govSryOv-z1zYK3pTEW3-H9QNN8JYtc,247
|
|
|
12
12
|
DeepWEBS/utilsdw/logger.py,sha256=Z0nFUcEGyU8r28yKiIyvEtO26xxpmJgbvNToTfwZecc,8174
|
|
13
13
|
webscout/AIauto.py,sha256=xPGr_Z0h27XXNh4Wiufjn9TksDOqxqlaGcLUYKNP55w,18246
|
|
14
14
|
webscout/AIbase.py,sha256=GoHbN8r0gq2saYRZv6LA-Fr9Jlcjv80STKFXUq2ZeGU,4710
|
|
15
|
-
webscout/AIutel.py,sha256=
|
|
15
|
+
webscout/AIutel.py,sha256=5-Is9e-COeh0NX9wkugdctHdzrsjBVZ7lfl2aunt1YI,33272
|
|
16
16
|
webscout/DWEBS.py,sha256=QT-7-dUgWhQ_H7EVZD53AVyXxyskoPMKCkFIpzkN56Q,7332
|
|
17
17
|
webscout/LLM.py,sha256=LbGCZdJf8A5dwfoGS4tyy39tAh5BDdhMZP0ScKaaQfU,4184
|
|
18
|
-
webscout/__init__.py,sha256=
|
|
18
|
+
webscout/__init__.py,sha256=eqHBfAE3psYEi42ZXnbwZG2y3J23F9XZjhoAI0nOKlQ,1856
|
|
19
19
|
webscout/__main__.py,sha256=ZtTRgsRjUi2JOvYFLF1ZCh55Sdoz94I-BS-TlJC7WDU,126
|
|
20
20
|
webscout/async_providers.py,sha256=holBv5SxanxVXc_92CBBaXHlB2IakB_fHnhyZaFjYF8,684
|
|
21
21
|
webscout/cli.py,sha256=174iWc0NxwfYMq9vyIk_NNnd3Q8bkzEiCa_BE6a0WZY,18743
|
|
@@ -25,18 +25,18 @@ webscout/models.py,sha256=5iQIdtedT18YuTZ3npoG7kLMwcrKwhQ7928dl_7qZW0,692
|
|
|
25
25
|
webscout/tempid.py,sha256=5oc3UbXhPGKxrMRTfRABT-V-dNzH_hOKWtLYM6iCWd4,5896
|
|
26
26
|
webscout/transcriber.py,sha256=EddvTSq7dPJ42V3pQVnGuEiYQ7WjJ9uyeR9kMSxN7uY,20622
|
|
27
27
|
webscout/utils.py,sha256=CxeXvp0rWIulUrEaPZMaNfg_tSuQLRSV8uuHA2chyKE,2603
|
|
28
|
-
webscout/version.py,sha256=
|
|
28
|
+
webscout/version.py,sha256=oUZS6cJqcn6yjv-XNLbwyvxLWIalOba-cFuLM6eoaWU,23
|
|
29
29
|
webscout/voice.py,sha256=0QjXTHAQmCK07IDZXRc7JXem47cnPJH7u3X0sVP1-UQ,967
|
|
30
30
|
webscout/webai.py,sha256=GqJs_4KSas9xOvEZ7cDAwo88OVsPoJnJWmnZ68qRQ0g,85324
|
|
31
31
|
webscout/webscout_search.py,sha256=8tDmlskNtIUAM41dqIc387ufC1YunovTm6w5NqeM_yQ,42650
|
|
32
32
|
webscout/webscout_search_async.py,sha256=ecn9b0J6YtAxMER80iUF1cgn_eh3Ysj7jFpievJzDbE,14471
|
|
33
33
|
webscout/Local/__init__.py,sha256=0yXXihFek7VCugUjjCI67i3yZ_PQ8mw3MMVlWGpMmLM,217
|
|
34
|
-
webscout/Local/_version.py,sha256=
|
|
34
|
+
webscout/Local/_version.py,sha256=_4faCzosNaazujtNZJP12bI38sKMaj4KxGdcGvcGPdY,83
|
|
35
35
|
webscout/Local/formats.py,sha256=BiZZSoN3e8S6-S-ykBL9ogSUs0vK11GaZ3ghc9U8GRk,18994
|
|
36
|
-
webscout/Local/model.py,sha256=
|
|
36
|
+
webscout/Local/model.py,sha256=SErw1uH416y62T2nD4w6LII7xA956DBnXSJXV-LOVfs,30463
|
|
37
37
|
webscout/Local/samplers.py,sha256=qXwU4eLXER-2aCYzcJcTgA6BeFmi5GMpTDUX1C9pTN4,4372
|
|
38
|
-
webscout/Local/thread.py,sha256=
|
|
39
|
-
webscout/Local/utils.py,sha256=
|
|
38
|
+
webscout/Local/thread.py,sha256=5jaOrMANwiIQpGx8_G29-ZxREhDTm_bt3ubGmNYg8K4,27453
|
|
39
|
+
webscout/Local/utils.py,sha256=CSt9IqHhVGk_nJEnKvSFbLhC5nNf01e0MtwpgMmF9pA,6197
|
|
40
40
|
webscout/Provider/BasedGPT.py,sha256=eijTnqsecFQuHtspXDHryvh42caE_yANJI7gw9wiG7Y,8191
|
|
41
41
|
webscout/Provider/Berlin4h.py,sha256=-O6BRkLusUEdYXcyQ09iY86dFl9WoiA4mlmZ_DLZbos,8342
|
|
42
42
|
webscout/Provider/Blackboxai.py,sha256=8B5wT_eb86RVZ5uOqwvgVC5QATl0uEMCli0n4SDwt1M,16743
|
|
@@ -57,10 +57,10 @@ webscout/Provider/ThinkAnyAI.py,sha256=_qFjj0djxxrranyEY33w14oizyRjzlVwMv_hzvVtw
|
|
|
57
57
|
webscout/Provider/Xjai.py,sha256=gI9FqEodS-jHfFM_CsDPmTb_wL5NU2q__2fg9hqVoEc,8809
|
|
58
58
|
webscout/Provider/Yepchat.py,sha256=E0tv3Zfoqs1Sw8Pe-6_5d--_1LESm8mjw536DWclJk8,19398
|
|
59
59
|
webscout/Provider/Youchat.py,sha256=JAZYwcj0Kl1UUgqN0rD3TKaReA1G-cmIlW_4mog1j_c,7756
|
|
60
|
-
webscout/Provider/__init__.py,sha256=
|
|
61
|
-
webscout-
|
|
62
|
-
webscout-
|
|
63
|
-
webscout-
|
|
64
|
-
webscout-
|
|
65
|
-
webscout-
|
|
66
|
-
webscout-
|
|
60
|
+
webscout/Provider/__init__.py,sha256=LBqUHmcwkpvBOpJ3eigXc4yUL6mWKc-v_9i5fCw7TtQ,1396
|
|
61
|
+
webscout-3.0b0.dist-info/LICENSE.md,sha256=mRVwJuT4SXC5O93BFdsfWBjlXjGn2Np90Zm5SocUzM0,3150
|
|
62
|
+
webscout-3.0b0.dist-info/METADATA,sha256=nQLpMueY8rfYsKBeB0uhbWGNVi5XIcD6hKj-1Aau4Io,47788
|
|
63
|
+
webscout-3.0b0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
64
|
+
webscout-3.0b0.dist-info/entry_points.txt,sha256=Hh4YIIjvkqB9SVxZ2ri4DZUkgEu_WF_5_r_nZDIvfG8,73
|
|
65
|
+
webscout-3.0b0.dist-info/top_level.txt,sha256=OD5YKy6Y3hldL7SmuxsiEDxAG4LgdSSWwzYk22MF9fk,18
|
|
66
|
+
webscout-3.0b0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|