webscout 8.2.6__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 (292) hide show
  1. webscout/AIutel.py +97 -87
  2. webscout/version.py +1 -1
  3. {webscout-8.2.6.dist-info → webscout-8.2.7.dist-info}/METADATA +2 -15
  4. webscout-8.2.7.dist-info/RECORD +26 -0
  5. {webscout-8.2.6.dist-info → webscout-8.2.7.dist-info}/WHEEL +1 -1
  6. webscout-8.2.7.dist-info/entry_points.txt +3 -0
  7. webscout-8.2.7.dist-info/top_level.txt +1 -0
  8. webscout/Extra/GitToolkit/__init__.py +0 -10
  9. webscout/Extra/GitToolkit/gitapi/__init__.py +0 -12
  10. webscout/Extra/GitToolkit/gitapi/repository.py +0 -195
  11. webscout/Extra/GitToolkit/gitapi/user.py +0 -96
  12. webscout/Extra/GitToolkit/gitapi/utils.py +0 -62
  13. webscout/Extra/YTToolkit/YTdownloader.py +0 -957
  14. webscout/Extra/YTToolkit/__init__.py +0 -3
  15. webscout/Extra/YTToolkit/transcriber.py +0 -476
  16. webscout/Extra/YTToolkit/ytapi/__init__.py +0 -6
  17. webscout/Extra/YTToolkit/ytapi/channel.py +0 -307
  18. webscout/Extra/YTToolkit/ytapi/errors.py +0 -13
  19. webscout/Extra/YTToolkit/ytapi/extras.py +0 -45
  20. webscout/Extra/YTToolkit/ytapi/https.py +0 -88
  21. webscout/Extra/YTToolkit/ytapi/patterns.py +0 -61
  22. webscout/Extra/YTToolkit/ytapi/playlist.py +0 -59
  23. webscout/Extra/YTToolkit/ytapi/pool.py +0 -8
  24. webscout/Extra/YTToolkit/ytapi/query.py +0 -40
  25. webscout/Extra/YTToolkit/ytapi/stream.py +0 -63
  26. webscout/Extra/YTToolkit/ytapi/utils.py +0 -62
  27. webscout/Extra/YTToolkit/ytapi/video.py +0 -232
  28. webscout/Extra/__init__.py +0 -7
  29. webscout/Extra/autocoder/__init__.py +0 -9
  30. webscout/Extra/autocoder/autocoder.py +0 -910
  31. webscout/Extra/autocoder/autocoder_utiles.py +0 -332
  32. webscout/Extra/gguf.py +0 -684
  33. webscout/Extra/tempmail/__init__.py +0 -28
  34. webscout/Extra/tempmail/async_utils.py +0 -141
  35. webscout/Extra/tempmail/base.py +0 -161
  36. webscout/Extra/tempmail/cli.py +0 -187
  37. webscout/Extra/tempmail/emailnator.py +0 -84
  38. webscout/Extra/tempmail/mail_tm.py +0 -361
  39. webscout/Extra/tempmail/temp_mail_io.py +0 -292
  40. webscout/Extra/weather.py +0 -194
  41. webscout/Extra/weather_ascii.py +0 -76
  42. webscout/Litlogger/__init__.py +0 -67
  43. webscout/Litlogger/core/__init__.py +0 -6
  44. webscout/Litlogger/core/level.py +0 -23
  45. webscout/Litlogger/core/logger.py +0 -165
  46. webscout/Litlogger/handlers/__init__.py +0 -12
  47. webscout/Litlogger/handlers/console.py +0 -33
  48. webscout/Litlogger/handlers/file.py +0 -143
  49. webscout/Litlogger/handlers/network.py +0 -173
  50. webscout/Litlogger/styles/__init__.py +0 -7
  51. webscout/Litlogger/styles/colors.py +0 -249
  52. webscout/Litlogger/styles/formats.py +0 -458
  53. webscout/Litlogger/styles/text.py +0 -87
  54. webscout/Litlogger/utils/__init__.py +0 -6
  55. webscout/Litlogger/utils/detectors.py +0 -153
  56. webscout/Litlogger/utils/formatters.py +0 -200
  57. webscout/Provider/AI21.py +0 -177
  58. webscout/Provider/AISEARCH/DeepFind.py +0 -250
  59. webscout/Provider/AISEARCH/ISou.py +0 -256
  60. webscout/Provider/AISEARCH/Perplexity.py +0 -359
  61. webscout/Provider/AISEARCH/__init__.py +0 -10
  62. webscout/Provider/AISEARCH/felo_search.py +0 -228
  63. webscout/Provider/AISEARCH/genspark_search.py +0 -208
  64. webscout/Provider/AISEARCH/hika_search.py +0 -198
  65. webscout/Provider/AISEARCH/iask_search.py +0 -436
  66. webscout/Provider/AISEARCH/monica_search.py +0 -246
  67. webscout/Provider/AISEARCH/scira_search.py +0 -322
  68. webscout/Provider/AISEARCH/webpilotai_search.py +0 -281
  69. webscout/Provider/Aitopia.py +0 -316
  70. webscout/Provider/AllenAI.py +0 -447
  71. webscout/Provider/Andi.py +0 -228
  72. webscout/Provider/Blackboxai.py +0 -229
  73. webscout/Provider/ChatGPTClone.py +0 -237
  74. webscout/Provider/ChatGPTGratis.py +0 -194
  75. webscout/Provider/ChatSandbox.py +0 -342
  76. webscout/Provider/Cloudflare.py +0 -325
  77. webscout/Provider/Cohere.py +0 -208
  78. webscout/Provider/Deepinfra.py +0 -338
  79. webscout/Provider/ElectronHub.py +0 -773
  80. webscout/Provider/ExaAI.py +0 -261
  81. webscout/Provider/ExaChat.py +0 -358
  82. webscout/Provider/Free2GPT.py +0 -241
  83. webscout/Provider/GPTWeb.py +0 -249
  84. webscout/Provider/Gemini.py +0 -169
  85. webscout/Provider/GithubChat.py +0 -370
  86. webscout/Provider/GizAI.py +0 -285
  87. webscout/Provider/Glider.py +0 -222
  88. webscout/Provider/Groq.py +0 -801
  89. webscout/Provider/HF_space/__init__.py +0 -0
  90. webscout/Provider/HF_space/qwen_qwen2.py +0 -206
  91. webscout/Provider/HeckAI.py +0 -257
  92. webscout/Provider/HuggingFaceChat.py +0 -469
  93. webscout/Provider/Hunyuan.py +0 -283
  94. webscout/Provider/Jadve.py +0 -291
  95. webscout/Provider/Koboldai.py +0 -381
  96. webscout/Provider/LambdaChat.py +0 -411
  97. webscout/Provider/Llama3.py +0 -259
  98. webscout/Provider/MCPCore.py +0 -315
  99. webscout/Provider/Marcus.py +0 -206
  100. webscout/Provider/Nemotron.py +0 -218
  101. webscout/Provider/Netwrck.py +0 -270
  102. webscout/Provider/OLLAMA.py +0 -396
  103. webscout/Provider/OPENAI/__init__.py +0 -28
  104. webscout/Provider/OPENAI/ai4chat.py +0 -286
  105. webscout/Provider/OPENAI/base.py +0 -46
  106. webscout/Provider/OPENAI/c4ai.py +0 -367
  107. webscout/Provider/OPENAI/chatgpt.py +0 -549
  108. webscout/Provider/OPENAI/chatgptclone.py +0 -481
  109. webscout/Provider/OPENAI/deepinfra.py +0 -309
  110. webscout/Provider/OPENAI/e2b.py +0 -1350
  111. webscout/Provider/OPENAI/exaai.py +0 -404
  112. webscout/Provider/OPENAI/exachat.py +0 -437
  113. webscout/Provider/OPENAI/freeaichat.py +0 -352
  114. webscout/Provider/OPENAI/glider.py +0 -316
  115. webscout/Provider/OPENAI/groq.py +0 -354
  116. webscout/Provider/OPENAI/heckai.py +0 -341
  117. webscout/Provider/OPENAI/llmchatco.py +0 -327
  118. webscout/Provider/OPENAI/mcpcore.py +0 -376
  119. webscout/Provider/OPENAI/multichat.py +0 -368
  120. webscout/Provider/OPENAI/netwrck.py +0 -350
  121. webscout/Provider/OPENAI/opkfc.py +0 -488
  122. webscout/Provider/OPENAI/scirachat.py +0 -462
  123. webscout/Provider/OPENAI/sonus.py +0 -294
  124. webscout/Provider/OPENAI/standardinput.py +0 -425
  125. webscout/Provider/OPENAI/textpollinations.py +0 -329
  126. webscout/Provider/OPENAI/toolbaz.py +0 -406
  127. webscout/Provider/OPENAI/typegpt.py +0 -346
  128. webscout/Provider/OPENAI/uncovrAI.py +0 -455
  129. webscout/Provider/OPENAI/utils.py +0 -211
  130. webscout/Provider/OPENAI/venice.py +0 -413
  131. webscout/Provider/OPENAI/wisecat.py +0 -381
  132. webscout/Provider/OPENAI/writecream.py +0 -156
  133. webscout/Provider/OPENAI/x0gpt.py +0 -371
  134. webscout/Provider/OPENAI/yep.py +0 -327
  135. webscout/Provider/OpenGPT.py +0 -209
  136. webscout/Provider/Openai.py +0 -496
  137. webscout/Provider/PI.py +0 -429
  138. webscout/Provider/Perplexitylabs.py +0 -415
  139. webscout/Provider/QwenLM.py +0 -254
  140. webscout/Provider/Reka.py +0 -214
  141. webscout/Provider/StandardInput.py +0 -290
  142. webscout/Provider/TTI/AiForce/__init__.py +0 -22
  143. webscout/Provider/TTI/AiForce/async_aiforce.py +0 -224
  144. webscout/Provider/TTI/AiForce/sync_aiforce.py +0 -245
  145. webscout/Provider/TTI/FreeAIPlayground/__init__.py +0 -9
  146. webscout/Provider/TTI/FreeAIPlayground/async_freeaiplayground.py +0 -181
  147. webscout/Provider/TTI/FreeAIPlayground/sync_freeaiplayground.py +0 -180
  148. webscout/Provider/TTI/ImgSys/__init__.py +0 -23
  149. webscout/Provider/TTI/ImgSys/async_imgsys.py +0 -202
  150. webscout/Provider/TTI/ImgSys/sync_imgsys.py +0 -195
  151. webscout/Provider/TTI/MagicStudio/__init__.py +0 -2
  152. webscout/Provider/TTI/MagicStudio/async_magicstudio.py +0 -111
  153. webscout/Provider/TTI/MagicStudio/sync_magicstudio.py +0 -109
  154. webscout/Provider/TTI/Nexra/__init__.py +0 -22
  155. webscout/Provider/TTI/Nexra/async_nexra.py +0 -286
  156. webscout/Provider/TTI/Nexra/sync_nexra.py +0 -258
  157. webscout/Provider/TTI/PollinationsAI/__init__.py +0 -23
  158. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +0 -311
  159. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +0 -265
  160. webscout/Provider/TTI/__init__.py +0 -12
  161. webscout/Provider/TTI/aiarta/__init__.py +0 -2
  162. webscout/Provider/TTI/aiarta/async_aiarta.py +0 -482
  163. webscout/Provider/TTI/aiarta/sync_aiarta.py +0 -440
  164. webscout/Provider/TTI/artbit/__init__.py +0 -22
  165. webscout/Provider/TTI/artbit/async_artbit.py +0 -155
  166. webscout/Provider/TTI/artbit/sync_artbit.py +0 -148
  167. webscout/Provider/TTI/fastflux/__init__.py +0 -22
  168. webscout/Provider/TTI/fastflux/async_fastflux.py +0 -261
  169. webscout/Provider/TTI/fastflux/sync_fastflux.py +0 -252
  170. webscout/Provider/TTI/huggingface/__init__.py +0 -22
  171. webscout/Provider/TTI/huggingface/async_huggingface.py +0 -199
  172. webscout/Provider/TTI/huggingface/sync_huggingface.py +0 -195
  173. webscout/Provider/TTI/piclumen/__init__.py +0 -23
  174. webscout/Provider/TTI/piclumen/async_piclumen.py +0 -268
  175. webscout/Provider/TTI/piclumen/sync_piclumen.py +0 -233
  176. webscout/Provider/TTI/pixelmuse/__init__.py +0 -4
  177. webscout/Provider/TTI/pixelmuse/async_pixelmuse.py +0 -249
  178. webscout/Provider/TTI/pixelmuse/sync_pixelmuse.py +0 -182
  179. webscout/Provider/TTI/talkai/__init__.py +0 -4
  180. webscout/Provider/TTI/talkai/async_talkai.py +0 -229
  181. webscout/Provider/TTI/talkai/sync_talkai.py +0 -207
  182. webscout/Provider/TTS/__init__.py +0 -8
  183. webscout/Provider/TTS/base.py +0 -159
  184. webscout/Provider/TTS/deepgram.py +0 -156
  185. webscout/Provider/TTS/elevenlabs.py +0 -111
  186. webscout/Provider/TTS/gesserit.py +0 -128
  187. webscout/Provider/TTS/murfai.py +0 -113
  188. webscout/Provider/TTS/parler.py +0 -111
  189. webscout/Provider/TTS/speechma.py +0 -180
  190. webscout/Provider/TTS/streamElements.py +0 -333
  191. webscout/Provider/TTS/utils.py +0 -280
  192. webscout/Provider/TeachAnything.py +0 -233
  193. webscout/Provider/TextPollinationsAI.py +0 -306
  194. webscout/Provider/TwoAI.py +0 -280
  195. webscout/Provider/TypliAI.py +0 -305
  196. webscout/Provider/Venice.py +0 -258
  197. webscout/Provider/VercelAI.py +0 -253
  198. webscout/Provider/WiseCat.py +0 -233
  199. webscout/Provider/WrDoChat.py +0 -370
  200. webscout/Provider/Writecream.py +0 -237
  201. webscout/Provider/WritingMate.py +0 -269
  202. webscout/Provider/Youchat.py +0 -330
  203. webscout/Provider/__init__.py +0 -178
  204. webscout/Provider/ai4chat.py +0 -203
  205. webscout/Provider/aimathgpt.py +0 -189
  206. webscout/Provider/akashgpt.py +0 -335
  207. webscout/Provider/asksteve.py +0 -212
  208. webscout/Provider/bagoodex.py +0 -145
  209. webscout/Provider/cerebras.py +0 -288
  210. webscout/Provider/chatglm.py +0 -215
  211. webscout/Provider/cleeai.py +0 -213
  212. webscout/Provider/copilot.py +0 -425
  213. webscout/Provider/elmo.py +0 -283
  214. webscout/Provider/freeaichat.py +0 -285
  215. webscout/Provider/geminiapi.py +0 -208
  216. webscout/Provider/geminiprorealtime.py +0 -160
  217. webscout/Provider/granite.py +0 -235
  218. webscout/Provider/hermes.py +0 -266
  219. webscout/Provider/julius.py +0 -223
  220. webscout/Provider/koala.py +0 -268
  221. webscout/Provider/learnfastai.py +0 -325
  222. webscout/Provider/llama3mitril.py +0 -215
  223. webscout/Provider/llmchat.py +0 -255
  224. webscout/Provider/llmchatco.py +0 -306
  225. webscout/Provider/meta.py +0 -798
  226. webscout/Provider/multichat.py +0 -364
  227. webscout/Provider/scira_chat.py +0 -297
  228. webscout/Provider/scnet.py +0 -243
  229. webscout/Provider/searchchat.py +0 -292
  230. webscout/Provider/sonus.py +0 -258
  231. webscout/Provider/talkai.py +0 -194
  232. webscout/Provider/toolbaz.py +0 -353
  233. webscout/Provider/turboseek.py +0 -266
  234. webscout/Provider/typefully.py +0 -330
  235. webscout/Provider/typegpt.py +0 -289
  236. webscout/Provider/uncovr.py +0 -368
  237. webscout/Provider/x0gpt.py +0 -299
  238. webscout/Provider/yep.py +0 -389
  239. webscout/litagent/__init__.py +0 -29
  240. webscout/litagent/agent.py +0 -455
  241. webscout/litagent/constants.py +0 -60
  242. webscout/litprinter/__init__.py +0 -59
  243. webscout/scout/__init__.py +0 -8
  244. webscout/scout/core/__init__.py +0 -7
  245. webscout/scout/core/crawler.py +0 -140
  246. webscout/scout/core/scout.py +0 -568
  247. webscout/scout/core/search_result.py +0 -96
  248. webscout/scout/core/text_analyzer.py +0 -63
  249. webscout/scout/core/text_utils.py +0 -277
  250. webscout/scout/core/web_analyzer.py +0 -52
  251. webscout/scout/core.py +0 -881
  252. webscout/scout/element.py +0 -460
  253. webscout/scout/parsers/__init__.py +0 -69
  254. webscout/scout/parsers/html5lib_parser.py +0 -172
  255. webscout/scout/parsers/html_parser.py +0 -236
  256. webscout/scout/parsers/lxml_parser.py +0 -178
  257. webscout/scout/utils.py +0 -37
  258. webscout/swiftcli/__init__.py +0 -95
  259. webscout/swiftcli/core/__init__.py +0 -7
  260. webscout/swiftcli/core/cli.py +0 -297
  261. webscout/swiftcli/core/context.py +0 -104
  262. webscout/swiftcli/core/group.py +0 -241
  263. webscout/swiftcli/decorators/__init__.py +0 -28
  264. webscout/swiftcli/decorators/command.py +0 -221
  265. webscout/swiftcli/decorators/options.py +0 -220
  266. webscout/swiftcli/decorators/output.py +0 -252
  267. webscout/swiftcli/exceptions.py +0 -21
  268. webscout/swiftcli/plugins/__init__.py +0 -9
  269. webscout/swiftcli/plugins/base.py +0 -135
  270. webscout/swiftcli/plugins/manager.py +0 -262
  271. webscout/swiftcli/utils/__init__.py +0 -59
  272. webscout/swiftcli/utils/formatting.py +0 -252
  273. webscout/swiftcli/utils/parsing.py +0 -267
  274. webscout/zeroart/__init__.py +0 -55
  275. webscout/zeroart/base.py +0 -60
  276. webscout/zeroart/effects.py +0 -99
  277. webscout/zeroart/fonts.py +0 -816
  278. webscout-8.2.6.dist-info/RECORD +0 -307
  279. webscout-8.2.6.dist-info/entry_points.txt +0 -3
  280. webscout-8.2.6.dist-info/top_level.txt +0 -2
  281. webstoken/__init__.py +0 -30
  282. webstoken/classifier.py +0 -189
  283. webstoken/keywords.py +0 -216
  284. webstoken/language.py +0 -128
  285. webstoken/ner.py +0 -164
  286. webstoken/normalizer.py +0 -35
  287. webstoken/processor.py +0 -77
  288. webstoken/sentiment.py +0 -206
  289. webstoken/stemmer.py +0 -73
  290. webstoken/tagger.py +0 -60
  291. webstoken/tokenizer.py +0 -158
  292. {webscout-8.2.6.dist-info → webscout-8.2.7.dist-info}/licenses/LICENSE.md +0 -0
@@ -1,228 +0,0 @@
1
- import requests
2
- from uuid import uuid4
3
- import json
4
- from typing import Any, Dict, Generator, Optional, Union
5
-
6
- from webscout.AIbase import AISearch
7
- from webscout import exceptions
8
- from webscout.litagent import LitAgent
9
-
10
-
11
- class Response:
12
- """A wrapper class for API responses.
13
-
14
- This class automatically converts response objects to their text representation
15
- when printed or converted to string.
16
-
17
- Attributes:
18
- text (str): The text content of the response
19
-
20
- Example:
21
- >>> response = Response("Hello, world!")
22
- >>> print(response)
23
- Hello, world!
24
- >>> str(response)
25
- 'Hello, world!'
26
- """
27
- def __init__(self, text: str):
28
- self.text = text
29
-
30
- def __str__(self):
31
- return self.text
32
-
33
- def __repr__(self):
34
- return self.text
35
-
36
-
37
- class Felo(AISearch):
38
- """A class to interact with the Felo AI search API.
39
-
40
- Felo provides a powerful search interface that returns AI-generated responses
41
- based on web content. It supports both streaming and non-streaming responses.
42
-
43
- Basic Usage:
44
- >>> from webscout import Felo
45
- >>> ai = Felo()
46
- >>> # Non-streaming example
47
- >>> response = ai.search("What is Python?")
48
- >>> print(response)
49
- Python is a high-level programming language...
50
-
51
- >>> # Streaming example
52
- >>> for chunk in ai.search("Tell me about AI", stream=True):
53
- ... print(chunk, end="", flush=True)
54
- Artificial Intelligence is...
55
-
56
- >>> # Raw response format
57
- >>> for chunk in ai.search("Hello", stream=True, raw=True):
58
- ... print(chunk)
59
- {'text': 'Hello'}
60
- {'text': ' there!'}
61
-
62
- Args:
63
- timeout (int, optional): Request timeout in seconds. Defaults to 30.
64
- proxies (dict, optional): Proxy configuration for requests. Defaults to None.
65
-
66
- Attributes:
67
- api_endpoint (str): The Felo API endpoint URL.
68
- stream_chunk_size (int): Size of chunks when streaming responses.
69
- timeout (int): Request timeout in seconds.
70
- headers (dict): HTTP headers used in requests.
71
- """
72
-
73
- def __init__(
74
- self,
75
- timeout: int = 30,
76
- proxies: Optional[dict] = None,
77
- ):
78
- """Initialize the Felo API client.
79
-
80
- Args:
81
- timeout (int, optional): Request timeout in seconds. Defaults to 30.
82
- proxies (dict, optional): Proxy configuration for requests. Defaults to None.
83
-
84
- Example:
85
- >>> ai = Felo(timeout=60) # Longer timeout
86
- >>> ai = Felo(proxies={'http': 'http://proxy.com:8080'}) # With proxy
87
- """
88
- self.session = requests.Session()
89
- self.chat_endpoint = "https://api.felo.ai/search/threads"
90
- self.stream_chunk_size = 64
91
- self.timeout = timeout
92
- self.last_response = {}
93
- self.headers = {
94
- "accept": "*/*",
95
- "accept-encoding": "gzip, deflate, br, zstd",
96
- "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
97
- "content-type": "application/json",
98
- "cookie": "_clck=1gifk45%7C2%7Cfoa%7C0%7C1686; _clsk=1g5lv07%7C1723558310439%7C1%7C1%7Cu.clarity.ms%2Fcollect; _ga=GA1.1.877307181.1723558313; _ga_8SZPRV97HV=GS1.1.1723558313.1.1.1723558341.0.0.0; _ga_Q9Q1E734CC=GS1.1.1723558313.1.1.1723558341.0.0.0",
99
- "dnt": "1",
100
- "origin": "https://felo.ai",
101
- "referer": "https://felo.ai/",
102
- "sec-ch-ua": '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
103
- "sec-ch-ua-mobile": "?0",
104
- "sec-ch-ua-platform": '"Windows"',
105
- "sec-fetch-dest": "empty",
106
- "sec-fetch-mode": "cors",
107
- "sec-fetch-site": "same-site",
108
- "user-agent": LitAgent().random()
109
- }
110
- self.session.headers.update(self.headers)
111
- self.proxies = proxies
112
-
113
- def search(
114
- self,
115
- prompt: str,
116
- stream: bool = False,
117
- raw: bool = False,
118
- ) -> Union[Response, Generator[Union[Dict[str, str], Response], None, None]]:
119
- """Search using the Felo API and get AI-generated responses.
120
-
121
- This method sends a search query to Felo and returns the AI-generated response.
122
- It supports both streaming and non-streaming modes, as well as raw response format.
123
-
124
- Args:
125
- prompt (str): The search query or prompt to send to the API.
126
- stream (bool, optional): If True, yields response chunks as they arrive.
127
- If False, returns complete response. Defaults to False.
128
- raw (bool, optional): If True, returns raw response dictionaries with 'text' key.
129
- If False, returns Response objects that convert to text automatically.
130
- Defaults to False.
131
-
132
- Returns:
133
- Union[Response, Generator[Union[Dict[str, str], Response], None, None]]:
134
- - If stream=False: Returns complete response as Response object
135
- - If stream=True: Yields response chunks as either Dict or Response objects
136
-
137
- Raises:
138
- APIConnectionError: If the API request fails
139
-
140
- Examples:
141
- Basic search:
142
- >>> ai = Felo()
143
- >>> response = ai.search("What is Python?")
144
- >>> print(response)
145
- Python is a programming language...
146
-
147
- Streaming response:
148
- >>> for chunk in ai.search("Tell me about AI", stream=True):
149
- ... print(chunk, end="")
150
- Artificial Intelligence...
151
-
152
- Raw response format:
153
- >>> for chunk in ai.search("Hello", stream=True, raw=True):
154
- ... print(chunk)
155
- {'text': 'Hello'}
156
- {'text': ' there!'}
157
-
158
- Error handling:
159
- >>> try:
160
- ... response = ai.search("My question")
161
- ... except exceptions.APIConnectionError as e:
162
- ... print(f"API error: {e}")
163
- """
164
- payload = {
165
- "query": prompt,
166
- "search_uuid": uuid4().hex,
167
- "lang": "",
168
- "agent_lang": "en",
169
- "search_options": {
170
- "langcode": "en-US"
171
- },
172
- "search_video": True,
173
- "contexts_from": "google"
174
- }
175
-
176
- def for_stream():
177
- try:
178
- with self.session.post(
179
- self.chat_endpoint,
180
- json=payload,
181
- stream=True,
182
- timeout=self.timeout,
183
- ) as response:
184
- if not response.ok:
185
- raise exceptions.APIConnectionError(
186
- f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
187
- )
188
-
189
- streaming_text = ""
190
- for line in response.iter_lines(decode_unicode=True):
191
- if line.startswith('data:'):
192
- try:
193
- data = json.loads(line[5:].strip())
194
- if data['type'] == 'answer' and 'text' in data['data']:
195
- new_text = data['data']['text']
196
- if len(new_text) > len(streaming_text):
197
- delta = new_text[len(streaming_text):]
198
- streaming_text = new_text
199
- if raw:
200
- yield {"text": delta}
201
- else:
202
- yield Response(delta)
203
- except json.JSONDecodeError:
204
- pass
205
- self.last_response = Response(streaming_text)
206
- except requests.exceptions.RequestException as e:
207
- raise exceptions.APIConnectionError(f"Request failed: {e}")
208
-
209
- def for_non_stream():
210
- full_response = ""
211
- for chunk in for_stream():
212
- if raw:
213
- yield chunk
214
- else:
215
- full_response += str(chunk)
216
- if not raw:
217
- self.last_response = Response(full_response)
218
- return self.last_response
219
-
220
- return for_stream() if stream else for_non_stream()
221
-
222
-
223
- if __name__ == "__main__":
224
- from rich import print
225
- ai = Felo()
226
- response = ai.search(input(">>> "), stream=True, raw=False)
227
- for chunk in response:
228
- print(chunk, end="", flush=True)
@@ -1,208 +0,0 @@
1
- import cloudscraper
2
- from uuid import uuid4
3
- import json
4
- import re
5
- from typing import Dict, Optional, Generator, Union, Any
6
-
7
- from webscout.AIbase import AISearch
8
- from webscout import exceptions
9
- from webscout.litagent import LitAgent
10
-
11
-
12
- class Response:
13
- """A wrapper class for Genspark API responses.
14
-
15
- This class automatically converts response objects to their text representation
16
- when printed or converted to string.
17
-
18
- Attributes:
19
- text (str): The text content of the response
20
-
21
- Example:
22
- >>> response = Response("Hello, world!")
23
- >>> print(response)
24
- Hello, world!
25
- >>> str(response)
26
- 'Hello, world!'
27
- """
28
- def __init__(self, text: str):
29
- self.text = text
30
-
31
- def __str__(self):
32
- return self.text
33
-
34
- def __repr__(self):
35
- return self.text
36
-
37
-
38
- class Genspark(AISearch):
39
- """A class to interact with the Genspark AI search API.
40
-
41
- Genspark provides a powerful search interface that returns AI-generated responses
42
- based on web content. It supports both streaming and non-streaming responses.
43
-
44
- Basic Usage:
45
- >>> from webscout import Genspark
46
- >>> ai = Genspark()
47
- >>> # Non-streaming example
48
- >>> response = ai.search("What is Python?")
49
- >>> print(response)
50
- Python is a high-level programming language...
51
-
52
- >>> # Streaming example
53
- >>> for chunk in ai.search("Tell me about AI", stream=True):
54
- ... print(chunk, end="", flush=True)
55
- Artificial Intelligence is...
56
-
57
- >>> # Raw response format
58
- >>> for chunk in ai.search("Hello", stream=True, raw=True):
59
- ... print(chunk)
60
- {'text': 'Hello'}
61
- {'text': ' there!'}
62
-
63
- Args:
64
- timeout (int, optional): Request timeout in seconds. Defaults to 30.
65
- proxies (dict, optional): Proxy configuration for requests. Defaults to None.
66
- max_tokens (int, optional): Maximum tokens to generate. Defaults to 600.
67
- """
68
-
69
- def __init__(
70
- self,
71
- timeout: int = 30,
72
- proxies: Optional[dict] = None,
73
- max_tokens: int = 600,
74
- ):
75
- """Initialize the Genspark API client.
76
-
77
- Args:
78
- timeout (int, optional): Request timeout in seconds. Defaults to 30.
79
- proxies (dict, optional): Proxy configuration for requests. Defaults to None.
80
- max_tokens (int, optional): Maximum tokens to generate. Defaults to 600.
81
- """
82
- self.session = cloudscraper.create_scraper()
83
- self.max_tokens = max_tokens
84
- self.chat_endpoint = "https://www.genspark.ai/api/search/stream"
85
- self.stream_chunk_size = 64
86
- self.timeout = timeout
87
- self.last_response = {}
88
-
89
- self.headers = {
90
- "Accept": "*/*",
91
- "Accept-Encoding": "gzip, deflate, br, zstd",
92
- "Accept-Language": "en-US,en;q=0.9,en-IN;q=0.8",
93
- "Content-Type": "application/json",
94
- "DNT": "1",
95
- "Origin": "https://www.genspark.ai",
96
- "Priority": "u=1, i",
97
- "Sec-CH-UA": '"Chromium";v="128", "Not;A=Brand";v="24", "Microsoft Edge";v="128"',
98
- "Sec-CH-UA-Mobile": "?0",
99
- "Sec-CH-UA-Platform": '"Windows"',
100
- "Sec-Fetch-Dest": "empty",
101
- "Sec-Fetch-Mode": "cors",
102
- "Sec-Fetch-Site": "same-origin",
103
- "User-Agent": LitAgent().random(),
104
- }
105
-
106
- self.cookies = {
107
- "i18n_redirected": "en-US",
108
- "agree_terms": "0",
109
- "session_id": uuid4().hex,
110
- }
111
-
112
- self.session.headers.update(self.headers)
113
- self.session.proxies = proxies or {}
114
-
115
- def search(
116
- self,
117
- prompt: str,
118
- stream: bool = False,
119
- raw: bool = False,
120
- ) -> Union[Response, Generator[Union[Dict[str, str], Response], None, None]]:
121
- """Search using the Genspark API and get AI-generated responses.
122
-
123
- Args:
124
- prompt (str): The search query or prompt to send to the API.
125
- stream (bool, optional): If True, yields response chunks as they arrive.
126
- If False, returns complete response. Defaults to False.
127
- raw (bool, optional): If True, returns raw response dictionaries with 'text' key.
128
- If False, returns Response objects that convert to text automatically.
129
- Defaults to False.
130
-
131
- Returns:
132
- Union[Dict[str, Any], Generator[Union[Dict[str, Any], str], None, None]]:
133
- - If stream=False: Returns complete response
134
- - If stream=True: Yields response chunks as they arrive
135
-
136
- Raises:
137
- APIConnectionError: If the API request fails
138
- """
139
- url = f"https://www.genspark.ai/api/search/stream?query={prompt.replace(' ', '%20')}"
140
-
141
- def for_stream():
142
- try:
143
- with self.session.post(
144
- url,
145
- headers=self.headers,
146
- cookies=self.cookies,
147
- json={}, # Empty payload as query is in URL
148
- stream=True,
149
- timeout=self.timeout,
150
- ) as response:
151
- if not response.ok:
152
- raise exceptions.APIConnectionError(
153
- f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
154
- )
155
-
156
- for line in response.iter_lines(decode_unicode=True):
157
- if line and line.startswith("data: "):
158
- try:
159
- data = json.loads(line[6:])
160
- if "field_name" in data and "delta" in data:
161
- if data["field_name"].startswith("streaming_detail_answer"):
162
- delta_text = data.get("delta", "")
163
-
164
- # Clean up markdown links in text
165
- delta_text = re.sub(r"\[.*?\]\(.*?\)", "", delta_text)
166
-
167
- if raw:
168
- yield {"text": delta_text}
169
- else:
170
- yield Response(delta_text)
171
- except json.JSONDecodeError:
172
- continue
173
-
174
- except cloudscraper.exceptions as e:
175
- raise exceptions.APIConnectionError(f"Request failed: {e}")
176
-
177
- def for_non_stream():
178
- full_response = ""
179
- for chunk in for_stream():
180
- if raw:
181
- yield chunk
182
- else:
183
- full_response += str(chunk)
184
-
185
- if not raw:
186
- # Process the full response to clean up any JSON structures
187
- try:
188
- text_json = json.loads(full_response)
189
- if isinstance(text_json, dict) and "detailAnswer" in text_json:
190
- full_response = text_json.get("detailAnswer", full_response)
191
- except (json.JSONDecodeError, TypeError):
192
- # Not valid JSON or not a dictionary, keep as is
193
- pass
194
-
195
- self.last_response = Response(full_response)
196
- return self.last_response
197
-
198
- return for_stream() if stream else for_non_stream()
199
-
200
-
201
- if __name__ == "__main__":
202
-
203
- from rich import print
204
-
205
- ai = Genspark()
206
- response = ai.search(input(">>> "), stream=True, raw=False)
207
- for chunk in response:
208
- print(chunk, end="", flush=True)
@@ -1,198 +0,0 @@
1
- import requests
2
- import hashlib
3
- import json
4
- import random
5
- import time
6
- import re
7
- from typing import Dict, Optional, Generator, Union, Any
8
-
9
- from webscout.AIbase import AISearch
10
- from webscout import exceptions
11
- from webscout.litagent import LitAgent
12
-
13
-
14
- class Response:
15
- """A wrapper class for Hika API responses."""
16
- def __init__(self, text: str):
17
- self.text = text
18
-
19
- def __str__(self):
20
- return self.text
21
-
22
- def __repr__(self):
23
- return self.text
24
-
25
-
26
- class Hika(AISearch):
27
- """A class to interact with the Hika AI search API."""
28
-
29
- def __init__(
30
- self,
31
- timeout: int = 60,
32
- proxies: Optional[dict] = None,
33
- language: str = "en",
34
- model: str = "deepseek-r1",
35
-
36
- ):
37
- self.session = requests.Session()
38
- self.base_url = "https://api.hika.fyi/api/"
39
- self.endpoint = "kbase/web"
40
- self.timeout = timeout
41
- self.language = language
42
- self.model = model
43
- self.last_response = {}
44
-
45
- self.headers = {
46
- "Content-Type": "application/json",
47
- "Origin": "https://hika.fyi",
48
- "Referer": "https://hika.fyi/",
49
- "User-Agent": LitAgent().random()
50
- }
51
-
52
- self.session.headers.update(self.headers)
53
- self.proxies = proxies
54
-
55
- def generate_id(self):
56
- """Generate a unique ID and hash for the request."""
57
- uid = ''.join(random.choice('0123456789abcdefghijklmnopqrstuvwxyz') for _ in range(10))
58
- uid += hex(int(time.time()))[2:]
59
- hash_id = hashlib.sha256(f"#{uid}*".encode()).hexdigest()
60
- return {"uid": uid, "hashId": hash_id}
61
-
62
- def clean_text(self, text):
63
- """Clean all XML tags and control markers from text.
64
-
65
- Args:
66
- text (str): The text to clean
67
-
68
- Returns:
69
- str: Cleaned text
70
- """
71
- if not text:
72
- return ""
73
-
74
- # Remove XML tags and special markers
75
- # First remove <r> tag at the beginning
76
- text = text.lstrip("<r>")
77
-
78
- # Remove any remaining XML tags
79
- text = re.sub(r'<[^>]+>', '', text)
80
-
81
- # Remove [DONE] marker at the end
82
- text = re.sub(r'\[DONE\]\s*$', '', text)
83
-
84
- return text
85
-
86
- def search(
87
- self,
88
- prompt: str,
89
- stream: bool = False,
90
- raw: bool = False,
91
- ) -> Union[Response, Generator[Union[Dict[str, str], Response], None, None]]:
92
- """Search using the Hika API and get AI-generated responses."""
93
- if not prompt or len(prompt) < 2:
94
- raise exceptions.APIConnectionError("Search query must be at least 2 characters long")
95
-
96
- # Generate ID for this request
97
- id_data = self.generate_id()
98
- uid, hash_id = id_data["uid"], id_data["hashId"]
99
-
100
- # Update headers with request-specific values
101
- request_headers = {
102
- **self.headers,
103
- "x-hika": hash_id,
104
- "x-uid": uid
105
- }
106
-
107
- # Prepare payload
108
- payload = {
109
- "keyword": prompt,
110
- "model": self.model,
111
- "language": self.language,
112
- "stream": True # Always request streaming for consistent handling
113
- }
114
-
115
- def for_stream():
116
- try:
117
- with self.session.post(
118
- f"{self.base_url}{self.endpoint}",
119
- json=payload,
120
- headers=request_headers,
121
- stream=True,
122
- timeout=self.timeout,
123
- proxies=self.proxies
124
- ) as response:
125
- if not response.ok:
126
- raise exceptions.APIConnectionError(
127
- f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
128
- )
129
-
130
- for line in response.iter_lines(decode_unicode=True):
131
- if line and line.startswith("data: "):
132
- try:
133
- data = json.loads(line[6:])
134
- if "chunk" in data:
135
- chunk = data["chunk"]
136
-
137
- # Skip [DONE] markers completely
138
- if "[DONE]" in chunk:
139
- continue
140
-
141
- # Clean the chunk
142
- clean_chunk = self.clean_text(chunk)
143
-
144
- if clean_chunk: # Only yield if there's content after cleaning
145
- if raw:
146
- yield {"text": clean_chunk}
147
- else:
148
- yield Response(clean_chunk)
149
- except json.JSONDecodeError:
150
- pass
151
-
152
- except requests.exceptions.RequestException as e:
153
- raise exceptions.APIConnectionError(f"Request failed: {e}")
154
-
155
- def for_non_stream():
156
- full_response = ""
157
- for chunk in for_stream():
158
- if raw:
159
- yield chunk
160
- else:
161
- full_response += str(chunk)
162
-
163
- if not raw:
164
- # Clean up the response text one final time
165
- cleaned_response = self.format_response(full_response)
166
- self.last_response = Response(cleaned_response)
167
- return self.last_response
168
-
169
- return for_stream() if stream else for_non_stream()
170
-
171
- def format_response(self, text: str) -> str:
172
- """Format the response text for better readability."""
173
- if not text:
174
- return ""
175
-
176
- # First clean any tags or markers
177
- cleaned_text = self.clean_text(text)
178
-
179
- # Remove any empty lines
180
- cleaned_text = re.sub(r'\n\s*\n', '\n\n', cleaned_text)
181
-
182
- # Remove any trailing whitespace
183
- cleaned_text = cleaned_text.strip()
184
-
185
- return cleaned_text
186
-
187
-
188
- if __name__ == "__main__":
189
- from rich import print
190
- ai = Hika()
191
- try:
192
- response = ai.search(input(">>> "), stream=True, raw=False)
193
- for chunk in response:
194
- print(chunk, end="", flush=True)
195
- except KeyboardInterrupt:
196
- print("\nSearch interrupted by user.")
197
- except Exception as e:
198
- print(f"\nError: {e}")