webscout 8.2.2__py3-none-any.whl → 8.2.7__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 (306) hide show
  1. webscout/AIauto.py +112 -22
  2. webscout/AIbase.py +144 -7
  3. webscout/AIutel.py +249 -131
  4. webscout/Bard.py +579 -206
  5. webscout/DWEBS.py +78 -35
  6. webscout/__init__.py +0 -1
  7. webscout/cli.py +256 -0
  8. webscout/conversation.py +307 -436
  9. webscout/exceptions.py +23 -0
  10. webscout/prompt_manager.py +56 -42
  11. webscout/version.py +1 -1
  12. webscout/webscout_search.py +65 -47
  13. webscout/webscout_search_async.py +81 -126
  14. webscout/yep_search.py +93 -43
  15. {webscout-8.2.2.dist-info → webscout-8.2.7.dist-info}/METADATA +172 -52
  16. webscout-8.2.7.dist-info/RECORD +26 -0
  17. {webscout-8.2.2.dist-info → webscout-8.2.7.dist-info}/WHEEL +1 -1
  18. webscout-8.2.7.dist-info/entry_points.txt +3 -0
  19. webscout-8.2.7.dist-info/top_level.txt +1 -0
  20. inferno/__init__.py +0 -6
  21. inferno/__main__.py +0 -9
  22. inferno/cli.py +0 -6
  23. webscout/Extra/GitToolkit/__init__.py +0 -10
  24. webscout/Extra/GitToolkit/gitapi/__init__.py +0 -12
  25. webscout/Extra/GitToolkit/gitapi/repository.py +0 -195
  26. webscout/Extra/GitToolkit/gitapi/user.py +0 -96
  27. webscout/Extra/GitToolkit/gitapi/utils.py +0 -62
  28. webscout/Extra/YTToolkit/YTdownloader.py +0 -957
  29. webscout/Extra/YTToolkit/__init__.py +0 -3
  30. webscout/Extra/YTToolkit/transcriber.py +0 -476
  31. webscout/Extra/YTToolkit/ytapi/__init__.py +0 -6
  32. webscout/Extra/YTToolkit/ytapi/channel.py +0 -307
  33. webscout/Extra/YTToolkit/ytapi/errors.py +0 -13
  34. webscout/Extra/YTToolkit/ytapi/extras.py +0 -45
  35. webscout/Extra/YTToolkit/ytapi/https.py +0 -88
  36. webscout/Extra/YTToolkit/ytapi/patterns.py +0 -61
  37. webscout/Extra/YTToolkit/ytapi/playlist.py +0 -59
  38. webscout/Extra/YTToolkit/ytapi/pool.py +0 -8
  39. webscout/Extra/YTToolkit/ytapi/query.py +0 -40
  40. webscout/Extra/YTToolkit/ytapi/stream.py +0 -63
  41. webscout/Extra/YTToolkit/ytapi/utils.py +0 -62
  42. webscout/Extra/YTToolkit/ytapi/video.py +0 -232
  43. webscout/Extra/__init__.py +0 -7
  44. webscout/Extra/autocoder/__init__.py +0 -9
  45. webscout/Extra/autocoder/autocoder.py +0 -849
  46. webscout/Extra/autocoder/autocoder_utiles.py +0 -332
  47. webscout/Extra/gguf.py +0 -682
  48. webscout/Extra/tempmail/__init__.py +0 -28
  49. webscout/Extra/tempmail/async_utils.py +0 -141
  50. webscout/Extra/tempmail/base.py +0 -161
  51. webscout/Extra/tempmail/cli.py +0 -187
  52. webscout/Extra/tempmail/emailnator.py +0 -84
  53. webscout/Extra/tempmail/mail_tm.py +0 -361
  54. webscout/Extra/tempmail/temp_mail_io.py +0 -292
  55. webscout/Extra/weather.py +0 -194
  56. webscout/Extra/weather_ascii.py +0 -76
  57. webscout/LLM.py +0 -442
  58. webscout/Litlogger/__init__.py +0 -67
  59. webscout/Litlogger/core/__init__.py +0 -6
  60. webscout/Litlogger/core/level.py +0 -23
  61. webscout/Litlogger/core/logger.py +0 -165
  62. webscout/Litlogger/handlers/__init__.py +0 -12
  63. webscout/Litlogger/handlers/console.py +0 -33
  64. webscout/Litlogger/handlers/file.py +0 -143
  65. webscout/Litlogger/handlers/network.py +0 -173
  66. webscout/Litlogger/styles/__init__.py +0 -7
  67. webscout/Litlogger/styles/colors.py +0 -249
  68. webscout/Litlogger/styles/formats.py +0 -458
  69. webscout/Litlogger/styles/text.py +0 -87
  70. webscout/Litlogger/utils/__init__.py +0 -6
  71. webscout/Litlogger/utils/detectors.py +0 -153
  72. webscout/Litlogger/utils/formatters.py +0 -200
  73. webscout/Local/__init__.py +0 -12
  74. webscout/Local/__main__.py +0 -9
  75. webscout/Local/api.py +0 -576
  76. webscout/Local/cli.py +0 -516
  77. webscout/Local/config.py +0 -75
  78. webscout/Local/llm.py +0 -287
  79. webscout/Local/model_manager.py +0 -253
  80. webscout/Local/server.py +0 -721
  81. webscout/Local/utils.py +0 -93
  82. webscout/Provider/AI21.py +0 -177
  83. webscout/Provider/AISEARCH/DeepFind.py +0 -250
  84. webscout/Provider/AISEARCH/ISou.py +0 -256
  85. webscout/Provider/AISEARCH/Perplexity.py +0 -359
  86. webscout/Provider/AISEARCH/__init__.py +0 -10
  87. webscout/Provider/AISEARCH/felo_search.py +0 -228
  88. webscout/Provider/AISEARCH/genspark_search.py +0 -208
  89. webscout/Provider/AISEARCH/hika_search.py +0 -194
  90. webscout/Provider/AISEARCH/iask_search.py +0 -436
  91. webscout/Provider/AISEARCH/monica_search.py +0 -246
  92. webscout/Provider/AISEARCH/scira_search.py +0 -324
  93. webscout/Provider/AISEARCH/webpilotai_search.py +0 -281
  94. webscout/Provider/Aitopia.py +0 -292
  95. webscout/Provider/AllenAI.py +0 -413
  96. webscout/Provider/Andi.py +0 -228
  97. webscout/Provider/Blackboxai.py +0 -229
  98. webscout/Provider/C4ai.py +0 -432
  99. webscout/Provider/ChatGPTClone.py +0 -226
  100. webscout/Provider/ChatGPTES.py +0 -237
  101. webscout/Provider/ChatGPTGratis.py +0 -194
  102. webscout/Provider/Chatify.py +0 -175
  103. webscout/Provider/Cloudflare.py +0 -273
  104. webscout/Provider/Cohere.py +0 -208
  105. webscout/Provider/DeepSeek.py +0 -196
  106. webscout/Provider/Deepinfra.py +0 -297
  107. webscout/Provider/ElectronHub.py +0 -709
  108. webscout/Provider/ExaAI.py +0 -261
  109. webscout/Provider/ExaChat.py +0 -342
  110. webscout/Provider/Free2GPT.py +0 -241
  111. webscout/Provider/GPTWeb.py +0 -193
  112. webscout/Provider/Gemini.py +0 -169
  113. webscout/Provider/GithubChat.py +0 -367
  114. webscout/Provider/Glider.py +0 -211
  115. webscout/Provider/Groq.py +0 -670
  116. webscout/Provider/HF_space/__init__.py +0 -0
  117. webscout/Provider/HF_space/qwen_qwen2.py +0 -206
  118. webscout/Provider/HeckAI.py +0 -233
  119. webscout/Provider/HuggingFaceChat.py +0 -462
  120. webscout/Provider/Hunyuan.py +0 -272
  121. webscout/Provider/Jadve.py +0 -266
  122. webscout/Provider/Koboldai.py +0 -381
  123. webscout/Provider/LambdaChat.py +0 -392
  124. webscout/Provider/Llama.py +0 -200
  125. webscout/Provider/Llama3.py +0 -204
  126. webscout/Provider/Marcus.py +0 -148
  127. webscout/Provider/Netwrck.py +0 -228
  128. webscout/Provider/OLLAMA.py +0 -396
  129. webscout/Provider/OPENAI/__init__.py +0 -25
  130. webscout/Provider/OPENAI/base.py +0 -46
  131. webscout/Provider/OPENAI/c4ai.py +0 -367
  132. webscout/Provider/OPENAI/chatgpt.py +0 -549
  133. webscout/Provider/OPENAI/chatgptclone.py +0 -460
  134. webscout/Provider/OPENAI/deepinfra.py +0 -272
  135. webscout/Provider/OPENAI/e2b.py +0 -1350
  136. webscout/Provider/OPENAI/exaai.py +0 -404
  137. webscout/Provider/OPENAI/exachat.py +0 -433
  138. webscout/Provider/OPENAI/freeaichat.py +0 -352
  139. webscout/Provider/OPENAI/glider.py +0 -316
  140. webscout/Provider/OPENAI/heckai.py +0 -337
  141. webscout/Provider/OPENAI/llmchatco.py +0 -327
  142. webscout/Provider/OPENAI/netwrck.py +0 -348
  143. webscout/Provider/OPENAI/opkfc.py +0 -488
  144. webscout/Provider/OPENAI/scirachat.py +0 -463
  145. webscout/Provider/OPENAI/sonus.py +0 -294
  146. webscout/Provider/OPENAI/standardinput.py +0 -425
  147. webscout/Provider/OPENAI/textpollinations.py +0 -285
  148. webscout/Provider/OPENAI/toolbaz.py +0 -405
  149. webscout/Provider/OPENAI/typegpt.py +0 -346
  150. webscout/Provider/OPENAI/uncovrAI.py +0 -455
  151. webscout/Provider/OPENAI/utils.py +0 -211
  152. webscout/Provider/OPENAI/venice.py +0 -413
  153. webscout/Provider/OPENAI/wisecat.py +0 -381
  154. webscout/Provider/OPENAI/writecream.py +0 -156
  155. webscout/Provider/OPENAI/x0gpt.py +0 -371
  156. webscout/Provider/OPENAI/yep.py +0 -327
  157. webscout/Provider/OpenGPT.py +0 -199
  158. webscout/Provider/Openai.py +0 -496
  159. webscout/Provider/PI.py +0 -344
  160. webscout/Provider/Perplexitylabs.py +0 -415
  161. webscout/Provider/Phind.py +0 -535
  162. webscout/Provider/PizzaGPT.py +0 -198
  163. webscout/Provider/QwenLM.py +0 -254
  164. webscout/Provider/Reka.py +0 -214
  165. webscout/Provider/StandardInput.py +0 -278
  166. webscout/Provider/TTI/AiForce/__init__.py +0 -22
  167. webscout/Provider/TTI/AiForce/async_aiforce.py +0 -224
  168. webscout/Provider/TTI/AiForce/sync_aiforce.py +0 -245
  169. webscout/Provider/TTI/FreeAIPlayground/__init__.py +0 -9
  170. webscout/Provider/TTI/FreeAIPlayground/async_freeaiplayground.py +0 -181
  171. webscout/Provider/TTI/FreeAIPlayground/sync_freeaiplayground.py +0 -180
  172. webscout/Provider/TTI/ImgSys/__init__.py +0 -23
  173. webscout/Provider/TTI/ImgSys/async_imgsys.py +0 -202
  174. webscout/Provider/TTI/ImgSys/sync_imgsys.py +0 -195
  175. webscout/Provider/TTI/MagicStudio/__init__.py +0 -2
  176. webscout/Provider/TTI/MagicStudio/async_magicstudio.py +0 -111
  177. webscout/Provider/TTI/MagicStudio/sync_magicstudio.py +0 -109
  178. webscout/Provider/TTI/Nexra/__init__.py +0 -22
  179. webscout/Provider/TTI/Nexra/async_nexra.py +0 -286
  180. webscout/Provider/TTI/Nexra/sync_nexra.py +0 -258
  181. webscout/Provider/TTI/PollinationsAI/__init__.py +0 -23
  182. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +0 -311
  183. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +0 -265
  184. webscout/Provider/TTI/__init__.py +0 -12
  185. webscout/Provider/TTI/aiarta/__init__.py +0 -2
  186. webscout/Provider/TTI/aiarta/async_aiarta.py +0 -482
  187. webscout/Provider/TTI/aiarta/sync_aiarta.py +0 -440
  188. webscout/Provider/TTI/artbit/__init__.py +0 -22
  189. webscout/Provider/TTI/artbit/async_artbit.py +0 -155
  190. webscout/Provider/TTI/artbit/sync_artbit.py +0 -148
  191. webscout/Provider/TTI/fastflux/__init__.py +0 -22
  192. webscout/Provider/TTI/fastflux/async_fastflux.py +0 -261
  193. webscout/Provider/TTI/fastflux/sync_fastflux.py +0 -252
  194. webscout/Provider/TTI/huggingface/__init__.py +0 -22
  195. webscout/Provider/TTI/huggingface/async_huggingface.py +0 -199
  196. webscout/Provider/TTI/huggingface/sync_huggingface.py +0 -195
  197. webscout/Provider/TTI/piclumen/__init__.py +0 -23
  198. webscout/Provider/TTI/piclumen/async_piclumen.py +0 -268
  199. webscout/Provider/TTI/piclumen/sync_piclumen.py +0 -233
  200. webscout/Provider/TTI/pixelmuse/__init__.py +0 -4
  201. webscout/Provider/TTI/pixelmuse/async_pixelmuse.py +0 -249
  202. webscout/Provider/TTI/pixelmuse/sync_pixelmuse.py +0 -182
  203. webscout/Provider/TTI/talkai/__init__.py +0 -4
  204. webscout/Provider/TTI/talkai/async_talkai.py +0 -229
  205. webscout/Provider/TTI/talkai/sync_talkai.py +0 -207
  206. webscout/Provider/TTS/__init__.py +0 -7
  207. webscout/Provider/TTS/deepgram.py +0 -156
  208. webscout/Provider/TTS/elevenlabs.py +0 -111
  209. webscout/Provider/TTS/gesserit.py +0 -127
  210. webscout/Provider/TTS/murfai.py +0 -113
  211. webscout/Provider/TTS/parler.py +0 -111
  212. webscout/Provider/TTS/speechma.py +0 -180
  213. webscout/Provider/TTS/streamElements.py +0 -333
  214. webscout/Provider/TTS/utils.py +0 -280
  215. webscout/Provider/TeachAnything.py +0 -187
  216. webscout/Provider/TextPollinationsAI.py +0 -231
  217. webscout/Provider/TwoAI.py +0 -199
  218. webscout/Provider/Venice.py +0 -219
  219. webscout/Provider/VercelAI.py +0 -234
  220. webscout/Provider/WebSim.py +0 -228
  221. webscout/Provider/WiseCat.py +0 -196
  222. webscout/Provider/Writecream.py +0 -211
  223. webscout/Provider/WritingMate.py +0 -197
  224. webscout/Provider/Youchat.py +0 -330
  225. webscout/Provider/__init__.py +0 -198
  226. webscout/Provider/ai4chat.py +0 -202
  227. webscout/Provider/aimathgpt.py +0 -189
  228. webscout/Provider/akashgpt.py +0 -342
  229. webscout/Provider/askmyai.py +0 -158
  230. webscout/Provider/asksteve.py +0 -203
  231. webscout/Provider/bagoodex.py +0 -145
  232. webscout/Provider/cerebras.py +0 -242
  233. webscout/Provider/chatglm.py +0 -205
  234. webscout/Provider/cleeai.py +0 -213
  235. webscout/Provider/copilot.py +0 -428
  236. webscout/Provider/elmo.py +0 -234
  237. webscout/Provider/freeaichat.py +0 -271
  238. webscout/Provider/gaurish.py +0 -244
  239. webscout/Provider/geminiapi.py +0 -208
  240. webscout/Provider/geminiprorealtime.py +0 -160
  241. webscout/Provider/granite.py +0 -187
  242. webscout/Provider/hermes.py +0 -219
  243. webscout/Provider/julius.py +0 -223
  244. webscout/Provider/koala.py +0 -268
  245. webscout/Provider/labyrinth.py +0 -340
  246. webscout/Provider/learnfastai.py +0 -266
  247. webscout/Provider/lepton.py +0 -194
  248. webscout/Provider/llama3mitril.py +0 -180
  249. webscout/Provider/llamatutor.py +0 -192
  250. webscout/Provider/llmchat.py +0 -213
  251. webscout/Provider/llmchatco.py +0 -311
  252. webscout/Provider/meta.py +0 -794
  253. webscout/Provider/multichat.py +0 -325
  254. webscout/Provider/promptrefine.py +0 -193
  255. webscout/Provider/scira_chat.py +0 -277
  256. webscout/Provider/scnet.py +0 -187
  257. webscout/Provider/searchchat.py +0 -293
  258. webscout/Provider/sonus.py +0 -208
  259. webscout/Provider/talkai.py +0 -194
  260. webscout/Provider/toolbaz.py +0 -320
  261. webscout/Provider/turboseek.py +0 -219
  262. webscout/Provider/tutorai.py +0 -252
  263. webscout/Provider/typefully.py +0 -280
  264. webscout/Provider/typegpt.py +0 -232
  265. webscout/Provider/uncovr.py +0 -312
  266. webscout/Provider/x0gpt.py +0 -256
  267. webscout/Provider/yep.py +0 -376
  268. webscout/litagent/__init__.py +0 -29
  269. webscout/litagent/agent.py +0 -455
  270. webscout/litagent/constants.py +0 -60
  271. webscout/litprinter/__init__.py +0 -59
  272. webscout/scout/__init__.py +0 -8
  273. webscout/scout/core/__init__.py +0 -7
  274. webscout/scout/core/crawler.py +0 -140
  275. webscout/scout/core/scout.py +0 -568
  276. webscout/scout/core/search_result.py +0 -96
  277. webscout/scout/core/text_analyzer.py +0 -63
  278. webscout/scout/core/text_utils.py +0 -277
  279. webscout/scout/core/web_analyzer.py +0 -52
  280. webscout/scout/core.py +0 -881
  281. webscout/scout/element.py +0 -460
  282. webscout/scout/parsers/__init__.py +0 -69
  283. webscout/scout/parsers/html5lib_parser.py +0 -172
  284. webscout/scout/parsers/html_parser.py +0 -236
  285. webscout/scout/parsers/lxml_parser.py +0 -178
  286. webscout/scout/utils.py +0 -37
  287. webscout/swiftcli/__init__.py +0 -809
  288. webscout/zeroart/__init__.py +0 -55
  289. webscout/zeroart/base.py +0 -60
  290. webscout/zeroart/effects.py +0 -99
  291. webscout/zeroart/fonts.py +0 -816
  292. webscout-8.2.2.dist-info/RECORD +0 -309
  293. webscout-8.2.2.dist-info/entry_points.txt +0 -5
  294. webscout-8.2.2.dist-info/top_level.txt +0 -3
  295. webstoken/__init__.py +0 -30
  296. webstoken/classifier.py +0 -189
  297. webstoken/keywords.py +0 -216
  298. webstoken/language.py +0 -128
  299. webstoken/ner.py +0 -164
  300. webstoken/normalizer.py +0 -35
  301. webstoken/processor.py +0 -77
  302. webstoken/sentiment.py +0 -206
  303. webstoken/stemmer.py +0 -73
  304. webstoken/tagger.py +0 -60
  305. webstoken/tokenizer.py +0 -158
  306. {webscout-8.2.2.dist-info → webscout-8.2.7.dist-info/licenses}/LICENSE.md +0 -0
webscout/Extra/gguf.py DELETED
@@ -1,682 +0,0 @@
1
- """
2
- Convert Hugging Face models to GGUF format with advanced features.
3
-
4
- >>> python -m webscout.Extra.gguf convert -m "OEvortex/HelpingAI-Lite-1.5T" -q "q4_k_m,q5_k_m"
5
- >>> # With upload options:
6
- >>> python -m webscout.Extra.gguf convert -m "your-model" -u "username" -t "token" -q "q4_k_m"
7
- >>> # With imatrix quantization:
8
- >>> python -m webscout.Extra.gguf convert -m "your-model" -i -q "iq4_nl" -t "train_data.txt"
9
- >>> # With model splitting:
10
- >>> python -m webscout.Extra.gguf convert -m "your-model" -s --split-max-tensors 256
11
- """
12
-
13
- import subprocess
14
- import os
15
- import sys
16
- import signal
17
- import tempfile
18
- import platform
19
- from pathlib import Path
20
- from typing import Optional, Dict, List, Any, Union, Literal, TypedDict, Set
21
-
22
- from huggingface_hub import HfApi
23
- from webscout.zeroart import figlet_format
24
- from rich.console import Console
25
- from rich.panel import Panel
26
- from rich.table import Table
27
- from ..swiftcli import CLI, option
28
-
29
- console = Console()
30
-
31
- class ConversionError(Exception):
32
- """Custom exception for when things don't go as planned! ⚠️"""
33
- pass
34
-
35
- class QuantizationMethod(TypedDict):
36
- """Type definition for quantization method descriptions."""
37
- description: str
38
-
39
- class ModelConverter:
40
- """Handles the conversion of Hugging Face models to GGUF format."""
41
-
42
- VALID_METHODS: Dict[str, str] = {
43
- "fp16": "16-bit floating point - maximum accuracy, largest size",
44
- "q2_k": "2-bit quantization (smallest size, lowest accuracy)",
45
- "q3_k_l": "3-bit quantization (large) - balanced for size/accuracy",
46
- "q3_k_m": "3-bit quantization (medium) - good balance for most use cases",
47
- "q3_k_s": "3-bit quantization (small) - optimized for speed",
48
- "q4_0": "4-bit quantization (version 0) - standard 4-bit compression",
49
- "q4_1": "4-bit quantization (version 1) - improved accuracy over q4_0",
50
- "q4_k_m": "4-bit quantization (medium) - balanced for most models",
51
- "q4_k_s": "4-bit quantization (small) - optimized for speed",
52
- "q5_0": "5-bit quantization (version 0) - high accuracy, larger size",
53
- "q5_1": "5-bit quantization (version 1) - improved accuracy over q5_0",
54
- "q5_k_m": "5-bit quantization (medium) - best balance for quality/size",
55
- "q5_k_s": "5-bit quantization (small) - optimized for speed",
56
- "q6_k": "6-bit quantization - highest accuracy, largest size",
57
- "q8_0": "8-bit quantization - maximum accuracy, largest size"
58
- }
59
-
60
- VALID_IMATRIX_METHODS: Dict[str, str] = {
61
- "iq3_m": "3-bit imatrix quantization (medium) - balanced importance-based",
62
- "iq3_xxs": "3-bit imatrix quantization (extra extra small) - maximum compression",
63
- "q4_k_m": "4-bit imatrix quantization (medium) - balanced importance-based",
64
- "q4_k_s": "4-bit imatrix quantization (small) - optimized for speed",
65
- "iq4_nl": "4-bit imatrix quantization (non-linear) - best accuracy for 4-bit",
66
- "iq4_xs": "4-bit imatrix quantization (extra small) - maximum compression",
67
- "q5_k_m": "5-bit imatrix quantization (medium) - balanced importance-based",
68
- "q5_k_s": "5-bit imatrix quantization (small) - optimized for speed"
69
- }
70
-
71
- def __init__(
72
- self,
73
- model_id: str,
74
- username: Optional[str] = None,
75
- token: Optional[str] = None,
76
- quantization_methods: str = "q4_k_m",
77
- use_imatrix: bool = False,
78
- train_data_file: Optional[str] = None,
79
- split_model: bool = False,
80
- split_max_tensors: int = 256,
81
- split_max_size: Optional[str] = None
82
- ) -> None:
83
- self.model_id = model_id
84
- self.username = username
85
- self.token = token
86
- self.quantization_methods = quantization_methods.split(',')
87
- self.model_name = model_id.split('/')[-1]
88
- self.workspace = Path(os.getcwd())
89
- self.use_imatrix = use_imatrix
90
- self.train_data_file = train_data_file
91
- self.split_model = split_model
92
- self.split_max_tensors = split_max_tensors
93
- self.split_max_size = split_max_size
94
- self.fp16_only = "fp16" in self.quantization_methods and len(self.quantization_methods) == 1
95
-
96
- def validate_inputs(self) -> None:
97
- """Validates all input parameters."""
98
- if not '/' in self.model_id:
99
- raise ValueError("Invalid model ID format. Expected format: 'organization/model-name'")
100
-
101
- if self.use_imatrix:
102
- invalid_methods = [m for m in self.quantization_methods if m not in self.VALID_IMATRIX_METHODS]
103
- if invalid_methods:
104
- raise ValueError(
105
- f"Invalid imatrix quantization methods: {', '.join(invalid_methods)}.\n"
106
- f"Valid methods are: {', '.join(self.VALID_IMATRIX_METHODS.keys())}"
107
- )
108
- if not self.train_data_file and not os.path.exists("llama.cpp/groups_merged.txt"):
109
- raise ValueError("Training data file is required for imatrix quantization")
110
- else:
111
- invalid_methods = [m for m in self.quantization_methods if m not in self.VALID_METHODS]
112
- if invalid_methods:
113
- raise ValueError(
114
- f"Invalid quantization methods: {', '.join(invalid_methods)}.\n"
115
- f"Valid methods are: {', '.join(self.VALID_METHODS.keys())}"
116
- )
117
-
118
- if bool(self.username) != bool(self.token):
119
- raise ValueError("Both username and token must be provided for upload, or neither.")
120
-
121
- if self.split_model and self.split_max_size:
122
- try:
123
- size = int(self.split_max_size[:-1])
124
- unit = self.split_max_size[-1].upper()
125
- if unit not in ['M', 'G']:
126
- raise ValueError("Split max size must end with M or G")
127
- except ValueError:
128
- raise ValueError("Invalid split max size format. Use format like '256M' or '5G'")
129
-
130
- @staticmethod
131
- def check_dependencies() -> Dict[str, bool]:
132
- """Check if all required dependencies are installed."""
133
- dependencies: Dict[str, str] = {
134
- 'git': 'Git version control',
135
- 'pip3': 'Python package installer',
136
- 'huggingface-cli': 'Hugging Face CLI',
137
- 'cmake': 'CMake build system',
138
- 'ninja': 'Ninja build system (optional)'
139
- }
140
-
141
- status: Dict[str, bool] = {}
142
- for cmd, desc in dependencies.items():
143
- status[cmd] = subprocess.run(['which', cmd], capture_output=True, text=True).returncode == 0
144
-
145
- return status
146
-
147
- def detect_hardware(self) -> Dict[str, bool]:
148
- """Detect available hardware acceleration."""
149
- hardware: Dict[str, bool] = {
150
- 'cuda': False,
151
- 'metal': False,
152
- 'opencl': False,
153
- 'vulkan': False,
154
- 'rocm': False
155
- }
156
-
157
- # Check CUDA
158
- try:
159
- if subprocess.run(['nvcc', '--version'], capture_output=True).returncode == 0:
160
- hardware['cuda'] = True
161
- except FileNotFoundError:
162
- pass
163
-
164
- # Check Metal (macOS)
165
- if platform.system() == 'Darwin':
166
- try:
167
- if subprocess.run(['xcrun', '--show-sdk-path'], capture_output=True).returncode == 0:
168
- hardware['metal'] = True
169
- except FileNotFoundError:
170
- pass
171
-
172
- # Check OpenCL
173
- try:
174
- if subprocess.run(['clinfo'], capture_output=True).returncode == 0:
175
- hardware['opencl'] = True
176
- except FileNotFoundError:
177
- pass
178
-
179
- # Check Vulkan
180
- try:
181
- if subprocess.run(['vulkaninfo'], capture_output=True).returncode == 0:
182
- hardware['vulkan'] = True
183
- except FileNotFoundError:
184
- pass
185
-
186
- # Check ROCm
187
- try:
188
- if subprocess.run(['rocm-smi'], capture_output=True).returncode == 0:
189
- hardware['rocm'] = True
190
- except FileNotFoundError:
191
- pass
192
-
193
- return hardware
194
-
195
- def setup_llama_cpp(self) -> None:
196
- """Sets up and builds llama.cpp repository."""
197
- llama_path = self.workspace / "llama.cpp"
198
-
199
- with console.status("[bold green]Setting up llama.cpp...") as status:
200
- # Clone llama.cpp if not exists
201
- if not llama_path.exists():
202
- subprocess.run(['git', 'clone', 'https://github.com/ggerganov/llama.cpp'], check=True)
203
-
204
- os.chdir(llama_path)
205
-
206
- # Check if we're in a Nix environment
207
- is_nix = platform.system() == "Linux" and os.path.exists("/nix/store")
208
-
209
- if is_nix:
210
- console.print("[yellow]Detected Nix environment. Using system Python packages...")
211
- # In Nix, we need to use the system Python packages
212
- try:
213
- # Try to import required packages to check if they're available
214
- import torch # type: ignore
215
- import numpy # type: ignore
216
- import sentencepiece # type: ignore
217
- import transformers # type: ignore
218
- console.print("[green]Required Python packages are already installed.")
219
- except ImportError as e:
220
- console.print("[red]Missing required Python packages in Nix environment.")
221
- console.print("[yellow]Please install them using:")
222
- console.print("nix-shell -p python3Packages.torch python3Packages.numpy python3Packages.sentencepiece python3Packages.transformers")
223
- raise ConversionError("Missing required Python packages in Nix environment")
224
- else:
225
- # In non-Nix environments, install requirements
226
- try:
227
- subprocess.run(['pip3', 'install', '-r', 'requirements.txt'], check=True)
228
- except subprocess.CalledProcessError as e:
229
- if "externally-managed-environment" in str(e):
230
- console.print("[yellow]Detected externally managed Python environment.")
231
- console.print("[yellow]Please install the required packages manually:")
232
- console.print("pip install torch numpy sentencepiece transformers")
233
- raise ConversionError("Failed to install requirements in externally managed environment")
234
- raise
235
-
236
- # Detect available hardware
237
- hardware = self.detect_hardware()
238
- console.print("[bold green]Detected hardware acceleration:")
239
- for hw, available in hardware.items():
240
- console.print(f" {'✓' if available else '✗'} {hw.upper()}")
241
-
242
- # Configure CMake build
243
- cmake_args: List[str] = ['cmake', '-B', 'build']
244
-
245
- # Add hardware acceleration options
246
- if hardware['cuda']:
247
- cmake_args.extend(['-DLLAMA_CUBLAS=ON'])
248
- if hardware['metal']:
249
- cmake_args.extend(['-DLLAMA_METAL=ON'])
250
- if hardware['opencl']:
251
- cmake_args.extend(['-DLLAMA_CLBLAST=ON'])
252
- if hardware['vulkan']:
253
- cmake_args.extend(['-DLLAMA_VULKAN=ON'])
254
- if hardware['rocm']:
255
- cmake_args.extend(['-DLLAMA_HIPBLAS=ON'])
256
-
257
- # Use Ninja if available
258
- if subprocess.run(['which', 'ninja'], capture_output=True).returncode == 0:
259
- cmake_args.extend(['-G', 'Ninja'])
260
-
261
- # Configure the build
262
- subprocess.run(cmake_args, check=True)
263
-
264
- # Build the project
265
- if any(hardware.values()):
266
- status.update("[bold green]Building with hardware acceleration...")
267
- else:
268
- status.update("[bold yellow]Building for CPU only...")
269
-
270
- subprocess.run(['cmake', '--build', 'build', '-j', str(os.cpu_count() or 1)], check=True)
271
-
272
- os.chdir(self.workspace)
273
-
274
- def display_config(self) -> None:
275
- """Displays the current configuration in a formatted table."""
276
- table = Table(title="Configuration", show_header=True, header_style="bold magenta")
277
- table.add_column("Setting", style="cyan")
278
- table.add_column("Value", style="green")
279
-
280
- table.add_row("Model ID", self.model_id)
281
- table.add_row("Model Name", self.model_name)
282
- table.add_row("Username", self.username or "Not provided")
283
- table.add_row("Token", "****" if self.token else "Not provided")
284
- table.add_row("Quantization Methods", "\n".join(
285
- f"{method} ({self.VALID_METHODS[method]})"
286
- for method in self.quantization_methods
287
- ))
288
-
289
- console.print(Panel(table))
290
-
291
- def generate_importance_matrix(self, model_path: str, train_data_path: str, output_path: str) -> None:
292
- """Generates importance matrix for quantization."""
293
- imatrix_command: List[str] = [
294
- "./llama.cpp/build/bin/llama-imatrix",
295
- "-m", model_path,
296
- "-f", train_data_path,
297
- "-ngl", "99",
298
- "--output-frequency", "10",
299
- "-o", output_path,
300
- ]
301
-
302
- if not os.path.isfile(model_path):
303
- raise ConversionError(f"Model file not found: {model_path}")
304
-
305
- console.print("[bold green]Generating importance matrix...")
306
- process = subprocess.Popen(imatrix_command, shell=False)
307
-
308
- try:
309
- process.wait(timeout=60)
310
- except subprocess.TimeoutExpired:
311
- console.print("[yellow]Imatrix computation timed out. Sending SIGINT...")
312
- process.send_signal(signal.SIGINT)
313
- try:
314
- process.wait(timeout=5)
315
- except subprocess.TimeoutExpired:
316
- console.print("[red]Imatrix process still running. Force terminating...")
317
- process.kill()
318
-
319
- if process.returncode != 0:
320
- raise ConversionError("Failed to generate importance matrix")
321
-
322
- console.print("[green]Importance matrix generation completed.")
323
-
324
- def split_model(self, model_path: str, outdir: str) -> List[str]:
325
- """Splits the model into smaller chunks."""
326
- split_cmd: List[str] = [
327
- "./llama.cpp/build/bin/llama-gguf-split",
328
- "--split",
329
- ]
330
-
331
- if self.split_max_size:
332
- split_cmd.extend(["--split-max-size", self.split_max_size])
333
- else:
334
- split_cmd.extend(["--split-max-tensors", str(self.split_max_tensors)])
335
-
336
- model_path_prefix = '.'.join(model_path.split('.')[:-1])
337
- split_cmd.extend([model_path, model_path_prefix])
338
-
339
- console.print(f"[bold green]Splitting model with command: {' '.join(split_cmd)}")
340
-
341
- result = subprocess.run(split_cmd, shell=False, capture_output=True, text=True)
342
-
343
- if result.returncode != 0:
344
- raise ConversionError(f"Error splitting model: {result.stderr}")
345
-
346
- console.print("[green]Model split successfully!")
347
-
348
- # Get list of split files
349
- model_file_prefix = model_path_prefix.split('/')[-1]
350
- split_files = [f for f in os.listdir(outdir)
351
- if f.startswith(model_file_prefix) and f.endswith(".gguf")]
352
-
353
- if not split_files:
354
- raise ConversionError("No split files found")
355
-
356
- return split_files
357
-
358
- def upload_split_files(self, split_files: List[str], outdir: str, repo_id: str) -> None:
359
- """Uploads split model files to Hugging Face."""
360
- api = HfApi(token=self.token)
361
-
362
- for file in split_files:
363
- file_path = os.path.join(outdir, file)
364
- console.print(f"[bold green]Uploading file: {file}")
365
- try:
366
- api.upload_file(
367
- path_or_fileobj=file_path,
368
- path_in_repo=file,
369
- repo_id=repo_id,
370
- )
371
- except Exception as e:
372
- raise ConversionError(f"Error uploading file {file}: {e}")
373
-
374
- def generate_readme(self, quantized_files: List[str]) -> str:
375
- """Generate a README.md file for the Hugging Face Hub."""
376
- readme = f"""# {self.model_name} GGUF
377
-
378
- This repository contains GGUF quantized versions of [{self.model_id}](https://huggingface.co/{self.model_id}).
379
-
380
- ## About
381
-
382
- This model was converted using [Webscout](https://github.com/Webscout/webscout).
383
-
384
- ## Quantization Methods
385
-
386
- The following quantization methods were used:
387
-
388
- """
389
- # Add quantization method descriptions
390
- for method in self.quantization_methods:
391
- if self.use_imatrix:
392
- readme += f"- `{method}`: {self.VALID_IMATRIX_METHODS[method]}\n"
393
- else:
394
- readme += f"- `{method}`: {self.VALID_METHODS[method]}\n"
395
-
396
- readme += """
397
- ## Available Files
398
-
399
- The following quantized files are available:
400
-
401
- """
402
- # Add file information
403
- for file in quantized_files:
404
- readme += f"- `{file}`\n"
405
-
406
- if self.use_imatrix:
407
- readme += """
408
- ## Importance Matrix
409
-
410
- This model was quantized using importance matrix quantization. The `imatrix.dat` file contains the importance matrix used for quantization.
411
-
412
- """
413
-
414
- readme += """
415
- ## Usage
416
-
417
- These GGUF files can be used with [llama.cpp](https://github.com/ggerganov/llama.cpp) and compatible tools.
418
-
419
- Example usage:
420
- ```bash
421
- ./main -m model.gguf -n 1024 --repeat_penalty 1.0 --color -i -r "User:" -f prompts/chat-with-bob.txt
422
- ```
423
-
424
- ## Conversion Process
425
-
426
- This model was converted using the following command:
427
- ```bash
428
- python -m webscout.Extra.gguf convert \\
429
- -m "{self.model_id}" \\
430
- -q "{','.join(self.quantization_methods)}" \\
431
- {f'-i' if self.use_imatrix else ''} \\
432
- {f'--train-data "{self.train_data_file}"' if self.train_data_file else ''} \\
433
- {f'-s' if self.split_model else ''} \\
434
- {f'--split-max-tensors {self.split_max_tensors}' if self.split_model else ''} \\
435
- {f'--split-max-size {self.split_max_size}' if self.split_max_size else ''}
436
- ```
437
-
438
- ## License
439
-
440
- This repository is licensed under the same terms as the original model.
441
- """
442
- return readme
443
-
444
- def upload_readme(self, readme_content: str, repo_id: str) -> None:
445
- """Upload README.md to Hugging Face Hub."""
446
- api = HfApi(token=self.token)
447
- try:
448
- api.upload_file(
449
- path_or_fileobj=readme_content.encode(),
450
- path_in_repo="README.md",
451
- repo_id=repo_id,
452
- )
453
- console.print("[green]README.md uploaded successfully!")
454
- except Exception as e:
455
- console.print(f"[yellow]Warning: Failed to upload README.md: {e}")
456
-
457
- def convert(self) -> None:
458
- """Performs the model conversion process."""
459
- try:
460
- # Display banner and configuration
461
- console.print(f"[bold green]{figlet_format('GGUF Converter')}")
462
- self.display_config()
463
-
464
- # Validate inputs
465
- self.validate_inputs()
466
-
467
- # Check dependencies
468
- deps = self.check_dependencies()
469
- missing = [name for name, installed in deps.items() if not installed and name != 'ninja']
470
- if missing:
471
- raise ConversionError(f"Missing required dependencies: {', '.join(missing)}")
472
-
473
- # Setup llama.cpp
474
- self.setup_llama_cpp()
475
-
476
- # Determine if we need temporary directories (only for uploads)
477
- needs_temp = bool(self.username and self.token)
478
-
479
- if needs_temp:
480
- # Use temporary directories for upload case
481
- with tempfile.TemporaryDirectory() as outdir:
482
- with tempfile.TemporaryDirectory() as tmpdir:
483
- self._convert_with_dirs(tmpdir, outdir)
484
- else:
485
- # Use current directory for local output
486
- outdir = os.getcwd()
487
- tmpdir = os.path.join(outdir, "temp_download")
488
- os.makedirs(tmpdir, exist_ok=True)
489
- try:
490
- self._convert_with_dirs(tmpdir, outdir)
491
- finally:
492
- # Clean up temporary download directory
493
- import shutil
494
- shutil.rmtree(tmpdir, ignore_errors=True)
495
-
496
- # Display success message
497
- console.print(Panel.fit(
498
- "[bold green]✓[/] Conversion completed successfully!\n\n"
499
- f"[cyan]Output files can be found in: {self.workspace / self.model_name}[/]",
500
- title="Success",
501
- border_style="green"
502
- ))
503
-
504
- except Exception as e:
505
- console.print(Panel.fit(
506
- f"[bold red]✗[/] {str(e)}",
507
- title="Error",
508
- border_style="red"
509
- ))
510
- raise
511
-
512
- def _convert_with_dirs(self, tmpdir: str, outdir: str) -> None:
513
- """Helper method to perform conversion with given directories."""
514
- fp16 = str(Path(outdir)/f"{self.model_name}.fp16.gguf")
515
-
516
- # Download model
517
- local_dir = Path(tmpdir)/self.model_name
518
- console.print("[bold green]Downloading model...")
519
- api = HfApi(token=self.token)
520
- api.snapshot_download(
521
- repo_id=self.model_id,
522
- local_dir=local_dir,
523
- local_dir_use_symlinks=False
524
- )
525
-
526
- # Convert to fp16
527
- console.print("[bold green]Converting to fp16...")
528
- result = subprocess.run([
529
- "python", "llama.cpp/convert_hf_to_gguf.py",
530
- str(local_dir),
531
- "--outtype", "f16",
532
- "--outfile", fp16
533
- ], capture_output=True, text=True)
534
-
535
- if result.returncode != 0:
536
- raise ConversionError(f"Error converting to fp16: {result.stderr}")
537
-
538
- # If fp16_only is True, we're done after fp16 conversion
539
- if self.fp16_only:
540
- quantized_files = [f"{self.model_name}.fp16.gguf"]
541
- if self.username and self.token:
542
- api.upload_file(
543
- path_or_fileobj=fp16,
544
- path_in_repo=f"{self.model_name}.fp16.gguf",
545
- repo_id=f"{self.username}/{self.model_name}-GGUF"
546
- )
547
- return
548
-
549
- # Generate importance matrix if needed
550
- imatrix_path: Optional[str] = None
551
- if self.use_imatrix:
552
- train_data_path = self.train_data_file if self.train_data_file else "llama.cpp/groups_merged.txt"
553
- imatrix_path = str(Path(outdir)/"imatrix.dat")
554
- self.generate_importance_matrix(fp16, train_data_path, imatrix_path)
555
-
556
- # Quantize model
557
- console.print("[bold green]Quantizing model...")
558
- quantized_files: List[str] = []
559
- for method in self.quantization_methods:
560
- quantized_name = f"{self.model_name.lower()}-{method.lower()}"
561
- if self.use_imatrix:
562
- quantized_name += "-imat"
563
- quantized_path = str(Path(outdir)/f"{quantized_name}.gguf")
564
-
565
- if self.use_imatrix:
566
- quantize_cmd: List[str] = [
567
- "./llama.cpp/build/bin/llama-quantize",
568
- "--imatrix", imatrix_path,
569
- fp16, quantized_path, method
570
- ]
571
- else:
572
- quantize_cmd = [
573
- "./llama.cpp/build/bin/llama-quantize",
574
- fp16, quantized_path, method
575
- ]
576
-
577
- result = subprocess.run(quantize_cmd, capture_output=True, text=True)
578
- if result.returncode != 0:
579
- raise ConversionError(f"Error quantizing with {method}: {result.stderr}")
580
-
581
- quantized_files.append(f"{quantized_name}.gguf")
582
-
583
- # Split model if requested
584
- if self.split_model:
585
- split_files = self.split_model(quantized_path, outdir)
586
- if self.username and self.token:
587
- self.upload_split_files(split_files, outdir, f"{self.username}/{self.model_name}-GGUF")
588
- else:
589
- # Upload single file if credentials provided
590
- if self.username and self.token:
591
- api.upload_file(
592
- path_or_fileobj=quantized_path,
593
- path_in_repo=f"{self.model_name.lower()}-{self.quantization_methods[0].lower()}.gguf",
594
- repo_id=f"{self.username}/{self.model_name}-GGUF"
595
- )
596
-
597
- # Upload imatrix if generated and credentials provided
598
- if imatrix_path and self.username and self.token:
599
- api.upload_file(
600
- path_or_fileobj=imatrix_path,
601
- path_in_repo="imatrix.dat",
602
- repo_id=f"{self.username}/{self.model_name}-GGUF"
603
- )
604
-
605
- # Generate and upload README if credentials provided
606
- if self.username and self.token:
607
- readme_content = self.generate_readme(quantized_files)
608
- self.upload_readme(readme_content, f"{self.username}/{self.model_name}-GGUF")
609
-
610
- # Initialize CLI with HAI vibes
611
- app = CLI(
612
- name="gguf",
613
- help="Convert HuggingFace models to GGUF format with style! 🔥",
614
- version="1.0.0"
615
- )
616
-
617
- @app.command(name="convert")
618
- @option("-m", "--model-id", help="The HuggingFace model ID (e.g., 'OEvortex/HelpingAI-Lite-1.5T')", required=True)
619
- @option("-u", "--username", help="Your HuggingFace username for uploads", default=None)
620
- @option("-t", "--token", help="Your HuggingFace API token for uploads", default=None)
621
- @option("-q", "--quantization", help="Comma-separated quantization methods", default="q4_k_m")
622
- @option("-i", "--use-imatrix", help="Use importance matrix for quantization", is_flag=True)
623
- @option("--train-data", help="Training data file for imatrix quantization", default=None)
624
- @option("-s", "--split-model", help="Split the model into smaller chunks", is_flag=True)
625
- @option("--split-max-tensors", help="Maximum number of tensors per file when splitting", default=256)
626
- @option("--split-max-size", help="Maximum file size when splitting (e.g., '256M', '5G')", default=None)
627
- def convert_command(
628
- model_id: str,
629
- username: Optional[str] = None,
630
- token: Optional[str] = None,
631
- quantization: str = "q4_k_m",
632
- use_imatrix: bool = False,
633
- train_data: Optional[str] = None,
634
- split_model: bool = False,
635
- split_max_tensors: int = 256,
636
- split_max_size: Optional[str] = None
637
- ) -> None:
638
- """
639
- Convert and quantize HuggingFace models to GGUF format! 🚀
640
-
641
- Args:
642
- model_id (str): Your model's HF ID (like 'OEvortex/HelpingAI-Lite-1.5T') 🎯
643
- username (str, optional): Your HF username for uploads 👤
644
- token (str, optional): Your HF API token 🔑
645
- quantization (str): Quantization methods (default: q4_k_m,q5_k_m) 🎮
646
- use_imatrix (bool): Use importance matrix for quantization 🔍
647
- train_data (str, optional): Training data file for imatrix quantization 📚
648
- split_model (bool): Split the model into smaller chunks 🔪
649
- split_max_tensors (int): Max tensors per file when splitting (default: 256) 📊
650
- split_max_size (str, optional): Max file size when splitting (e.g., '256M', '5G') 📏
651
-
652
- Example:
653
- >>> python -m webscout.Extra.gguf convert \\
654
- ... -m "OEvortex/HelpingAI-Lite-1.5T" \\
655
- ... -q "q4_k_m,q5_k_m"
656
- """
657
- try:
658
- converter = ModelConverter(
659
- model_id=model_id,
660
- username=username,
661
- token=token,
662
- quantization_methods=quantization,
663
- use_imatrix=use_imatrix,
664
- train_data_file=train_data,
665
- split_model=split_model,
666
- split_max_tensors=split_max_tensors,
667
- split_max_size=split_max_size
668
- )
669
- converter.convert()
670
- except (ConversionError, ValueError) as e:
671
- console.print(f"[red]Error: {str(e)}")
672
- sys.exit(1)
673
- except Exception as e:
674
- console.print(f"[red]Unexpected error: {str(e)}")
675
- sys.exit(1)
676
-
677
- def main() -> None:
678
- """Fire up the GGUF converter! 🚀"""
679
- app.run()
680
-
681
- if __name__ == "__main__":
682
- main()