webscout 6.0__py3-none-any.whl → 6.2b0__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 (60) hide show
  1. webscout/AIauto.py +77 -259
  2. webscout/Agents/Onlinesearcher.py +22 -10
  3. webscout/Agents/functioncall.py +2 -2
  4. webscout/Bard.py +21 -21
  5. webscout/Extra/autollama.py +37 -20
  6. webscout/Local/__init__.py +6 -7
  7. webscout/Local/formats.py +404 -194
  8. webscout/Local/model.py +1074 -477
  9. webscout/Local/samplers.py +108 -144
  10. webscout/Local/thread.py +251 -410
  11. webscout/Local/ui.py +401 -0
  12. webscout/Local/utils.py +338 -136
  13. webscout/Provider/Amigo.py +51 -38
  14. webscout/Provider/Deepseek.py +7 -6
  15. webscout/Provider/EDITEE.py +2 -2
  16. webscout/Provider/GPTWeb.py +1 -1
  17. webscout/Provider/NinjaChat.py +200 -0
  18. webscout/Provider/OLLAMA.py +1 -1
  19. webscout/Provider/Perplexity.py +1 -1
  20. webscout/Provider/Reka.py +12 -5
  21. webscout/Provider/TTI/AIuncensored.py +103 -0
  22. webscout/Provider/TTI/Nexra.py +3 -3
  23. webscout/Provider/TTI/__init__.py +3 -2
  24. webscout/Provider/TTI/aiforce.py +2 -2
  25. webscout/Provider/TTI/imgninza.py +136 -0
  26. webscout/Provider/TeachAnything.py +0 -3
  27. webscout/Provider/Youchat.py +1 -1
  28. webscout/Provider/__init__.py +12 -11
  29. webscout/Provider/{ChatHub.py → aimathgpt.py} +72 -88
  30. webscout/Provider/cerebras.py +125 -118
  31. webscout/Provider/cleeai.py +1 -1
  32. webscout/Provider/felo_search.py +1 -1
  33. webscout/Provider/gaurish.py +207 -0
  34. webscout/Provider/geminiprorealtime.py +160 -0
  35. webscout/Provider/genspark.py +1 -1
  36. webscout/Provider/julius.py +8 -3
  37. webscout/Provider/learnfastai.py +1 -1
  38. webscout/Provider/promptrefine.py +3 -1
  39. webscout/Provider/turboseek.py +3 -8
  40. webscout/Provider/tutorai.py +1 -1
  41. webscout/__init__.py +2 -43
  42. webscout/exceptions.py +5 -1
  43. webscout/tempid.py +4 -73
  44. webscout/utils.py +3 -0
  45. webscout/version.py +1 -1
  46. webscout/webai.py +1 -1
  47. webscout/webscout_search.py +154 -123
  48. {webscout-6.0.dist-info → webscout-6.2b0.dist-info}/METADATA +156 -236
  49. {webscout-6.0.dist-info → webscout-6.2b0.dist-info}/RECORD +53 -54
  50. webscout/Local/rawdog.py +0 -946
  51. webscout/Provider/BasedGPT.py +0 -214
  52. webscout/Provider/TTI/amigo.py +0 -148
  53. webscout/Provider/aigames.py +0 -213
  54. webscout/Provider/bixin.py +0 -264
  55. webscout/Provider/xdash.py +0 -182
  56. webscout/websx_search.py +0 -19
  57. {webscout-6.0.dist-info → webscout-6.2b0.dist-info}/LICENSE.md +0 -0
  58. {webscout-6.0.dist-info → webscout-6.2b0.dist-info}/WHEEL +0 -0
  59. {webscout-6.0.dist-info → webscout-6.2b0.dist-info}/entry_points.txt +0 -0
  60. {webscout-6.0.dist-info → webscout-6.2b0.dist-info}/top_level.txt +0 -0
@@ -1,161 +1,125 @@
1
-
2
- from ._version import __version__, __llama_cpp_version__
3
-
4
- """Submodule containing SamplerSettings class and some preset samplers"""
5
-
1
+ from typing import Optional
6
2
  from sys import maxsize
7
3
 
4
+ from .utils import assert_type, NoneType
8
5
 
9
6
  MAX_TEMP = float(maxsize)
10
7
 
11
8
  class SamplerSettings:
12
9
  """
13
- A SamplerSettings object specifies the sampling parameters that will be
14
- used to control text generation
10
+ Specifies sampling parameters for controlling text generation.
11
+
12
+ This class allows you to fine-tune the behavior of text generation
13
+ models by adjusting various sampling parameters. These settings are
14
+ passed as an optional parameter to functions like `Thread.__init__()`,
15
+ `Model.generate()`, `Model.stream()`, and `Model.stream_print()`.
16
+
17
+ If a parameter is unspecified, the default value from llama.cpp is used.
18
+ If all parameters are unspecified, the behavior is equivalent to
19
+ `DefaultSampling`.
20
+
21
+ Setting a parameter explicitly to `None` disables it. When all samplers
22
+ are disabled, it's equivalent to `NoSampling` (unmodified probability
23
+ distribution).
24
+
25
+ Attributes:
26
+ max_len_tokens (Optional[int]): Maximum number of tokens to generate.
27
+ Defaults to -1 (no limit).
28
+ top_k (Optional[int]): Number of highest probability tokens to consider.
29
+ Defaults to 40. Set to `None` to disable.
30
+ top_p (Optional[float]): Nucleus sampling threshold (0.0 - 1.0).
31
+ Defaults to 0.95. Set to `None` to disable.
32
+ min_p (Optional[float]): Minimum probability threshold (0.0 - 1.0).
33
+ Defaults to 0.05. Set to `None` to disable.
34
+ temp (Optional[float]): Temperature for sampling (0.0 - inf).
35
+ Defaults to 0.8. Set to `None` to disable.
36
+ frequency_penalty (Optional[float]): Penalty for repeating tokens.
37
+ Defaults to 0.0.
38
+ presence_penalty (Optional[float]): Penalty for generating new tokens.
39
+ Defaults to 0.0.
40
+ repeat_penalty (Optional[float]): Penalty for repeating token sequences.
41
+ Defaults to 1.0.
42
+
43
+ Presets:
44
+ - `GreedyDecoding`: Always chooses the most likely token.
45
+ - `DefaultSampling`: Uses default parameters from llama.cpp.
46
+ - `NoSampling`: Unmodified probability distribution (all parameters disabled).
47
+ - `ClassicSampling`: Reflects old llama.cpp defaults.
48
+ - `SemiSampling`: Halfway between DefaultSampling and SimpleSampling.
49
+ - `TikTokenSampling`: For models with large vocabularies.
50
+ - `LowMinPSampling`, `MinPSampling`, `StrictMinPSampling`: Use `min_p` as the only active sampler.
51
+ - `ContrastiveSearch`, `WarmContrastiveSearch`: Implement contrastive search.
52
+ - `RandomSampling`: Outputs completely random tokens (useless).
53
+ - `LowTempSampling`: Default sampling with reduced temperature.
54
+ - `HighTempSampling`: Default sampling with increased temperature.
55
+ - `LowTopPSampling`, `TopPSampling`, `StrictTopPSampling`: Use `top_p` as the primary sampler.
56
+ - `MidnightMiqu`: For sophosympatheia/Midnight-Miqu-70B-v1.5 model.
57
+ - `Llama3`: For meta-llama/Meta-Llama-3.1-8B-Instruct model.
58
+ - `Nemo`: For mistralai/Mistral-Nemo-Instruct-2407 model.
15
59
  """
16
-
17
- ParamTypes: dict[str, type] = {
18
- 'max_len_tokens': int,
19
- 'temp': float,
20
- 'top_p': float,
21
- 'min_p': float,
22
- 'frequency_penalty': float,
23
- 'presence_penalty': float,
24
- 'repeat_penalty': float,
25
- 'top_k': int
60
+
61
+ param_types: dict[str, tuple[type]] = {
62
+ 'max_len_tokens': (int, NoneType),
63
+ 'top_k': (int, NoneType),
64
+ 'top_p': (float, NoneType),
65
+ 'min_p': (float, NoneType),
66
+ 'temp': (float, NoneType),
67
+ 'frequency_penalty': (float, NoneType),
68
+ 'presence_penalty': (float, NoneType),
69
+ 'repeat_penalty': (float, NoneType)
26
70
  }
27
71
 
28
72
  def __init__(
29
73
  self,
30
- max_len_tokens: int = -1,
31
- temp: float = 0.8,
32
- top_p: float = 0.95,
33
- min_p: float = 0.05,
34
- frequency_penalty: float = 0.0,
35
- presence_penalty: float = 0.0,
36
- repeat_penalty: float = 1.0,
37
- top_k: int = 40
74
+ max_len_tokens: Optional[int] = -1,
75
+ top_k: Optional[int] = 40,
76
+ top_p: Optional[float] = 0.95,
77
+ min_p: Optional[float] = 0.05,
78
+ temp: Optional[float] = 0.8,
79
+ frequency_penalty: Optional[float] = 0.0,
80
+ presence_penalty: Optional[float] = 0.0,
81
+ repeat_penalty: Optional[float] = 1.0
38
82
  ):
39
- """
40
- Construct a new SamplerSettings instance
41
- """
83
+ self.max_len_tokens = max_len_tokens if max_len_tokens is not None else -1
84
+ self.top_k = top_k if top_k is not None else -1
85
+ self.top_p = top_p if top_p is not None else 1.0
86
+ self.min_p = min_p if min_p is not None else 0.0
87
+ self.temp = temp if temp is not None else 1.0
88
+ self.frequency_penalty = frequency_penalty if frequency_penalty is not None else 0.0
89
+ self.presence_penalty = presence_penalty if presence_penalty is not None else 0.0
90
+ self.repeat_penalty = repeat_penalty if repeat_penalty is not None else 1.0
91
+
92
+ # Validate parameters using param_types dictionary
93
+ for param_name, param_value in self.__dict__.items():
94
+ assert_type(param_value, self.param_types[param_name],
95
+ f'{param_name} parameter', 'SamplerSettings')
42
96
 
43
- self.max_len_tokens = max_len_tokens
44
- self.temp = temp
45
- self.top_p = top_p
46
- self.min_p = min_p
47
- self.frequency_penalty = frequency_penalty
48
- self.presence_penalty = presence_penalty
49
- self.repeat_penalty = repeat_penalty
50
- self.top_k = top_k
51
-
52
- for sampler_param in SamplerSettings.ParamTypes:
53
- expected_type = SamplerSettings.ParamTypes[sampler_param]
54
- actual_type = type(getattr(self, sampler_param))
55
- if actual_type != expected_type:
56
- raise TypeError(
57
- f"wrong type for SamplerSettings parameter '{sampler_param}'"
58
- f" - expected {expected_type}, got {actual_type}"
59
- )
60
-
61
97
  def __repr__(self) -> str:
62
- repr_str = 'SamplerSettings('
63
- repr_str += f'max_len_tokens={self.max_len_tokens}, '
64
- repr_str += f'temp={self.temp}, '
65
- repr_str += f'top_p={self.top_p}, '
66
- repr_str += f'min_p={self.min_p}, '
67
- repr_str += f'frequency_penalty={self.frequency_penalty}, '
68
- repr_str += f'presence_penalty={self.presence_penalty}, '
69
- repr_str += f'repeat_penalty={self.repeat_penalty}, '
70
- repr_str += f'top_k={self.top_k})'
71
- return repr_str
72
-
73
- # most likely token is always chosen
74
- GreedyDecoding = SamplerSettings(
75
- temp = 0.0,
76
- )
98
+ params = ', '.join(
99
+ f'{name}={value}' for name, value in self.__dict__.items()
100
+ )
101
+ return f'SamplerSettings({params})'
77
102
 
78
- # reflects llama.cpp
103
+ # Predefined sampler settings
104
+ GreedyDecoding = SamplerSettings(temp=0.0)
79
105
  DefaultSampling = SamplerSettings()
80
-
81
- # unmodified probability distribution (i.e. what the model actually thinks)
82
- SimpleSampling = SamplerSettings(
83
- temp = 1.0,
84
- top_p = 1.0,
85
- min_p = 0.0,
86
- top_k = -1
87
- )
88
-
89
- # reflects old llama.cpp defaults
90
- ClassicSampling = SamplerSettings(
91
- min_p=0.0,
92
- repeat_penalty = 1.1
93
- )
94
-
95
- # halfway between DefaultSampling and SimpleSampling
96
- SemiSampling = SamplerSettings(
97
- temp=0.9,
98
- top_p=0.975,
99
- min_p=0.025,
100
- top_k=80
101
- )
102
-
103
- # for models with large vocabulary, which tend to run hot
104
- TikTokenSampling = SamplerSettings(
105
- temp=0.6,
106
- repeat_penalty=1.1
107
- )
108
-
109
- # use min_p as the only active sampler (more permissive)
110
- LowMinPSampling = SamplerSettings(
111
- temp = 1.0,
112
- top_p = 1.0,
113
- min_p = 0.05,
114
- top_k = -1
115
- )
116
-
117
- # use min_p as the only active sampler (moderate)
118
- MinPSampling = SamplerSettings(
119
- temp = 1.0,
120
- top_p = 1.0,
121
- min_p = 0.1,
122
- top_k = -1
123
- )
124
-
125
- # use min_p as the only active sampler (more restrictive)
126
- StrictMinPSampling = SamplerSettings(
127
- temp = 1.0,
128
- top_p = 1.0,
129
- min_p = 0.2,
130
- top_k = -1
131
- )
132
-
133
- # https://arxiv.org/abs/2210.14140
134
- ContrastiveSearch = SamplerSettings(
135
- temp = 0.0,
136
- presence_penalty = 0.4
137
- )
138
-
139
- # https://arxiv.org/abs/2210.14140
140
- WarmContrastiveSearch = SamplerSettings(
141
- temp = 0.0,
142
- presence_penalty = 0.8
143
- )
144
-
145
- # outputs completely random tokens from vocab (useless)
146
- RandomSampling = SamplerSettings(
147
- temp = MAX_TEMP,
148
- top_p = 1.0,
149
- min_p = 0.0,
150
- top_k = -1
151
- )
152
-
153
- # default sampling with reduced temperature
154
- LowTempSampling = SamplerSettings(
155
- temp = 0.4
156
- )
157
-
158
- # default sampling with increased temperature
159
- HighTempSampling = SamplerSettings(
160
- temp = 1.2
161
- )
106
+ NoSampling = SimpleSampling = SamplerSettings(top_k=None, top_p=None, min_p=None, temp=None)
107
+ ClassicSampling = SamplerSettings(min_p=None, repeat_penalty=1.1)
108
+ SemiSampling = SamplerSettings(top_k=80, top_p=0.975, min_p=0.025, temp=0.9)
109
+ TikTokenSampling = SamplerSettings(temp=0.65)
110
+ LowMinPSampling = SamplerSettings(top_k=None, top_p=None, min_p=0.01, temp=None)
111
+ MinPSampling = SamplerSettings(top_k=None, top_p=None, min_p=0.075, temp=None)
112
+ StrictMinPSampling = SamplerSettings(top_k=None, top_p=None, min_p=0.2, temp=None)
113
+ ContrastiveSearch = SamplerSettings(top_k=None, top_p=None, min_p=None, temp=0.0, presence_penalty=0.6)
114
+ WarmContrastiveSearch = SamplerSettings(top_k=None, top_p=None, min_p=None, temp=0.0, presence_penalty=1.0)
115
+ RandomSampling = SamplerSettings(top_k=None, top_p=None, min_p=None, temp=MAX_TEMP)
116
+ LowTempSampling = SamplerSettings(temp=0.4)
117
+ HighTempSampling = SamplerSettings(temp=1.1)
118
+ LowTopPSampling = SamplerSettings(top_k=None, top_p=0.98, min_p=None, temp=None)
119
+ TopPSampling = SamplerSettings(top_k=None, top_p=0.9, min_p=None, temp=None)
120
+ StrictTopPSampling = SamplerSettings(top_k=None, top_p=0.7, min_p=None, temp=None)
121
+
122
+ # Model-specific samplers
123
+ MidnightMiqu = SamplerSettings(top_k=None, top_p=None, min_p=0.12, temp=1.0, repeat_penalty=1.05) # sophosympatheia/Midnight-Miqu-70B-v1.5
124
+ Llama3 = SamplerSettings(top_k=None, top_p=0.9, min_p=None, temp=0.6) # meta-llama/Meta-Llama-3.1-8B-Instruct
125
+ Nemo = MistralNemo = MistralSmall = SamplerSettings(top_k=None, top_p=0.85, min_p=None, temp=0.7) # mistralai/Mistral-Nemo-Instruct-2407