webscout 7.8__py3-none-any.whl → 7.9__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/Bard.py +5 -25
- webscout/DWEBS.py +476 -476
- webscout/Extra/__init__.py +2 -0
- webscout/Extra/autocoder/__init__.py +1 -1
- webscout/Extra/autocoder/{rawdog.py → autocoder.py} +849 -849
- webscout/Extra/tempmail/__init__.py +26 -0
- webscout/Extra/tempmail/async_utils.py +141 -0
- webscout/Extra/tempmail/base.py +156 -0
- webscout/Extra/tempmail/cli.py +187 -0
- webscout/Extra/tempmail/mail_tm.py +361 -0
- webscout/Extra/tempmail/temp_mail_io.py +292 -0
- webscout/Provider/Deepinfra.py +288 -286
- webscout/Provider/ElectronHub.py +709 -716
- webscout/Provider/ExaChat.py +20 -5
- webscout/Provider/Gemini.py +167 -165
- webscout/Provider/Groq.py +38 -24
- webscout/Provider/LambdaChat.py +2 -1
- webscout/Provider/TextPollinationsAI.py +232 -230
- webscout/Provider/__init__.py +0 -4
- webscout/Provider/copilot.py +427 -427
- webscout/Provider/freeaichat.py +8 -1
- webscout/Provider/uncovr.py +312 -299
- webscout/Provider/yep.py +64 -12
- webscout/__init__.py +38 -36
- webscout/cli.py +293 -293
- webscout/conversation.py +350 -17
- webscout/litprinter/__init__.py +59 -667
- webscout/optimizers.py +419 -419
- webscout/update_checker.py +14 -12
- webscout/version.py +1 -1
- webscout/webscout_search.py +1282 -1282
- webscout/webscout_search_async.py +813 -813
- {webscout-7.8.dist-info → webscout-7.9.dist-info}/METADATA +44 -39
- {webscout-7.8.dist-info → webscout-7.9.dist-info}/RECORD +38 -35
- webscout/Provider/DARKAI.py +0 -225
- webscout/Provider/EDITEE.py +0 -192
- webscout/litprinter/colors.py +0 -54
- {webscout-7.8.dist-info → webscout-7.9.dist-info}/LICENSE.md +0 -0
- {webscout-7.8.dist-info → webscout-7.9.dist-info}/WHEEL +0 -0
- {webscout-7.8.dist-info → webscout-7.9.dist-info}/entry_points.txt +0 -0
- {webscout-7.8.dist-info → webscout-7.9.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: webscout
|
|
3
|
-
Version: 7.
|
|
3
|
+
Version: 7.9
|
|
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 and more
|
|
5
5
|
Author: OEvortex
|
|
6
6
|
Author-email: helpingai5@gmail.com
|
|
@@ -59,35 +59,40 @@ Provides-Extra: dev
|
|
|
59
59
|
Requires-Dist: ruff>=0.1.6; extra == "dev"
|
|
60
60
|
Requires-Dist: pytest>=7.4.2; extra == "dev"
|
|
61
61
|
|
|
62
|
-
<div align="center">
|
|
63
|
-
<!-- Replace `#` with your actual links -->
|
|
64
|
-
<a href="https://t.me/PyscoutAI"><img alt="Telegram" src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white"></a>
|
|
65
|
-
<a href="https://www.instagram.com/oevortex/"><img alt="Instagram" src="https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white"></a>
|
|
66
|
-
<a href="https://www.linkedin.com/in/oe-vortex-29a407265/"><img alt="LinkedIn" src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white"></a>
|
|
67
|
-
<a href="https://buymeacoffee.com/oevortex"><img alt="Buy Me A Coffee" src="https://img.shields.io/badge/Buy%20Me%20A%20Coffee-FFDD00?style=for-the-badge&logo=buymeacoffee&logoColor=black"></a>
|
|
68
|
-
</div>
|
|
69
62
|
|
|
70
63
|
<div align="center">
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
<a href="https://github.com/OEvortex/Webscout">
|
|
65
|
+
<!-- Consider adding a dedicated Webscout logo here if you have one -->
|
|
66
|
+
<img src="https://img.shields.io/badge/WebScout-Ultimate%20Toolkit-blue?style=for-the-badge&logo=python&logoColor=white" alt="WebScout Logo">
|
|
67
|
+
</a>
|
|
68
|
+
<br/>
|
|
69
|
+
<h1>Webscout</h1>
|
|
70
|
+
<p><strong>Your All-in-One Python Toolkit for Web Search, AI Interaction, Digital Utilities, and More.</strong></p>
|
|
71
|
+
<p>
|
|
72
|
+
Access diverse search engines, cutting-edge AI models, temporary communication tools, media utilities, developer helpers, and powerful CLI interfaces – all through one unified library.
|
|
73
|
+
</p>
|
|
74
|
+
|
|
75
|
+
<!-- Badges -->
|
|
76
|
+
<p>
|
|
77
|
+
<a href="https://pypi.org/project/webscout/"><img src="https://img.shields.io/pypi/v/webscout.svg?style=flat-square&logo=pypi&label=PyPI" alt="PyPI Version"></a>
|
|
78
|
+
<a href="https://pepy.tech/project/webscout"><img src="https://static.pepy.tech/badge/webscout/month?style=flat-square" alt="Monthly Downloads"></a>
|
|
79
|
+
<a href="https://pepy.tech/project/webscout"><img src="https://static.pepy.tech/badge/webscout?style=flat-square" alt="Total Downloads"></a>
|
|
80
|
+
<a href="#"><img src="https://img.shields.io/pypi/pyversions/webscout?style=flat-square&logo=python" alt="Python Version"></a>
|
|
81
|
+
<!-- Add License Badge if applicable: <a href="LICENSE"><img src="https://img.shields.io/pypi/l/webscout?style=flat-square" alt="License"></a> -->
|
|
82
|
+
<!-- Add Build Status Badge if applicable -->
|
|
83
|
+
</p>
|
|
84
|
+
|
|
85
|
+
<!-- Social/Support Links -->
|
|
86
|
+
<div>
|
|
87
|
+
<a href="https://t.me/PyscoutAI"><img alt="Telegram Group" src="https://img.shields.io/badge/Telegram%20Group-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white"></a>
|
|
88
|
+
<a href="https://t.me/ANONYMOUS_56788"><img alt="Developer Telegram" src="https://img.shields.io/badge/Developer%20Contact-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white"></a>
|
|
89
|
+
<a href="https://youtube.com/@OEvortex"><img alt="YouTube" src="https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge&logo=youtube&logoColor=white"></a>
|
|
90
|
+
<a href="https://www.linkedin.com/in/oe-vortex-29a407265/"><img alt="LinkedIn" src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white"></a>
|
|
91
|
+
<a href="https://www.instagram.com/oevortex/"><img alt="Instagram" src="https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white"></a>
|
|
92
|
+
<a href="https://buymeacoffee.com/oevortex"><img alt="Buy Me A Coffee" src="https://img.shields.io/badge/Buy%20Me%20A%20Coffee-FFDD00?style=for-the-badge&logo=buymeacoffee&logoColor=black"></a>
|
|
93
|
+
</div>
|
|
73
94
|
</div>
|
|
74
|
-
<div align="center">
|
|
75
|
-
<a href="https://t.me/ANONYMOUS_56788">📢 Anonymous Coder's Telegram</a>
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
<p align="center">
|
|
79
|
-
<strong>Webscout</strong> is the all-in-one search and AI toolkit you need.
|
|
80
|
-
<br>
|
|
81
|
-
Discover insights with Yep.com, DuckDuckGo, and Phind; access cutting-edge AI models; transcribe YouTube videos; generate temporary emails and phone numbers; perform text-to-speech conversions; and much more!
|
|
82
|
-
</p>
|
|
83
95
|
|
|
84
|
-
<div align="center">
|
|
85
|
-
<img src="https://img.shields.io/badge/WebScout-API-blue?style=for-the-badge&logo=WebScout" alt="WebScout API Badge">
|
|
86
|
-
<a href="#"><img src="https://img.shields.io/pypi/pyversions/webscout" alt="Python Version"></a>
|
|
87
|
-
<a href="https://pepy.tech/project/webscout"><img src="https://static.pepy.tech/badge/webscout" alt="Downloads"></a>
|
|
88
|
-
</div>
|
|
89
|
-
|
|
90
|
-
---
|
|
91
96
|
|
|
92
97
|
## 🚀 Features
|
|
93
98
|
|
|
@@ -95,7 +100,7 @@ Requires-Dist: pytest>=7.4.2; extra == "dev"
|
|
|
95
100
|
* **AI Powerhouse:** Access and interact with various AI models, including OpenAI, Cohere, and more.
|
|
96
101
|
* **[YouTube Toolkit](webscout/Extra/YTToolkit):** Advanced YouTube video and transcript management with multi-language support, versatile downloading, and intelligent data extraction
|
|
97
102
|
* **[GitAPI](webscout/Extra/GitToolkit/gitapi):** Powerful GitHub data extraction toolkit for seamless repository and user information retrieval, featuring commit tracking, issue management, and comprehensive user analytics - all without authentication requirements for public data
|
|
98
|
-
* **Tempmail & Temp Number:** Generate temporary email addresses and phone numbers for enhanced privacy.
|
|
103
|
+
* **[Tempmail](webscout/Extra/tempmail/README.md) & Temp Number:** Generate temporary email addresses and phone numbers for enhanced privacy.
|
|
99
104
|
* **[Text-to-Speech (TTS)](webscout/Provider/TTS/README.md):** Convert text into natural-sounding speech using multiple AI-powered providers like ElevenLabs, StreamElements, and Voicepods.
|
|
100
105
|
* **GGUF Conversion & Quantization:** Convert and quantize Hugging Face models to GGUF format.
|
|
101
106
|
* **[SwiftCLI](webscout/swiftcli/Readme.md):** A powerful and elegant CLI framework that makes it easy to create beautiful command-line interfaces.
|
|
@@ -151,13 +156,13 @@ async def main():
|
|
|
151
156
|
if numbers:
|
|
152
157
|
number = numbers[0]['full_number']
|
|
153
158
|
inbox = vn.get_number_inbox(country, number)
|
|
154
|
-
|
|
159
|
+
|
|
155
160
|
# Serialize inbox data to JSON string
|
|
156
161
|
json_data = json.dumps(inbox, ensure_ascii=False, indent=4)
|
|
157
|
-
|
|
162
|
+
|
|
158
163
|
# Print with UTF-8 encoding
|
|
159
164
|
print(json_data)
|
|
160
|
-
|
|
165
|
+
|
|
161
166
|
async with TempMail() as client:
|
|
162
167
|
domains = await client.get_domains()
|
|
163
168
|
print("Available Domains:", domains)
|
|
@@ -333,7 +338,7 @@ await main()
|
|
|
333
338
|
```python
|
|
334
339
|
from webscout import WEBS
|
|
335
340
|
|
|
336
|
-
# Text search for 'live free or die' using DuckDuckGo.com
|
|
341
|
+
# Text search for 'live free or die' using DuckDuckGo.com
|
|
337
342
|
with WEBS() as WEBS:
|
|
338
343
|
for r in WEBS.text('live free or die', region='wt-wt', safesearch='off', timelimit='y', max_results=10):
|
|
339
344
|
print(r)
|
|
@@ -347,7 +352,7 @@ with WEBS() as WEBS:
|
|
|
347
352
|
```python
|
|
348
353
|
from webscout import WEBS
|
|
349
354
|
|
|
350
|
-
# Instant answers for the query "sun" using DuckDuckGo.com
|
|
355
|
+
# Instant answers for the query "sun" using DuckDuckGo.com
|
|
351
356
|
with WEBS() as WEBS:
|
|
352
357
|
for r in WEBS.answers("sun"):
|
|
353
358
|
print(r)
|
|
@@ -358,7 +363,7 @@ with WEBS() as WEBS:
|
|
|
358
363
|
```python
|
|
359
364
|
from webscout import WEBS
|
|
360
365
|
|
|
361
|
-
# Image search for the keyword 'butterfly' using DuckDuckGo.com
|
|
366
|
+
# Image search for the keyword 'butterfly' using DuckDuckGo.com
|
|
362
367
|
with WEBS() as WEBS:
|
|
363
368
|
keywords = 'butterfly'
|
|
364
369
|
WEBS_images_gen = WEBS.images(
|
|
@@ -380,7 +385,7 @@ with WEBS() as WEBS:
|
|
|
380
385
|
```python
|
|
381
386
|
from webscout import WEBS
|
|
382
387
|
|
|
383
|
-
# Video search for the keyword 'tesla' using DuckDuckGo.com
|
|
388
|
+
# Video search for the keyword 'tesla' using DuckDuckGo.com
|
|
384
389
|
with WEBS() as WEBS:
|
|
385
390
|
keywords = 'tesla'
|
|
386
391
|
WEBS_videos_gen = WEBS.videos(
|
|
@@ -711,7 +716,7 @@ print(response["message"]) # Access the text message
|
|
|
711
716
|
print("Sources:", response["sources"]) # Access sources (if any)
|
|
712
717
|
|
|
713
718
|
# Image generation
|
|
714
|
-
response = meta_ai.ask("Create an image of a cat wearing a hat.")
|
|
719
|
+
response = meta_ai.ask("Create an image of a cat wearing a hat.")
|
|
715
720
|
print(response["message"]) # Print the text message from the response
|
|
716
721
|
for media in response["media"]:
|
|
717
722
|
print(media["url"]) # Access image URLs
|
|
@@ -896,7 +901,7 @@ a = AndiSearch()
|
|
|
896
901
|
print(a.chat("HelpingAI-9B"))
|
|
897
902
|
```
|
|
898
903
|
|
|
899
|
-
### `LLAMA`, `C4ai`, `Venice`, `Copilot`, `HuggingFaceChat`, `TwoAI`, `HeckAI`, `AllenAI`, `PerplexityLabs`, `AkashGPT`, `DeepSeek`, `WiseCat`, `IBMGranite`, `QwenLM`, `ChatGPTGratis`, `TextPollinationsAI`, `GliderAI`, `Cohere`, `REKA`, `GROQ`, `AsyncGROQ`, `OPENAI`, `AsyncOPENAI`, `KOBOLDAI`, `AsyncKOBOLDAI`, `BLACKBOXAI`, `PhindSearch`, `GEMINI`, `DeepInfra`, `AI4Chat`, `Phindv2`, `OLLAMA`, `AndiSearch`, `PIZZAGPT`, `Sambanova`, `
|
|
904
|
+
### `LLAMA`, `C4ai`, `Venice`, `Copilot`, `HuggingFaceChat`, `TwoAI`, `HeckAI`, `AllenAI`, `PerplexityLabs`, `AkashGPT`, `DeepSeek`, `WiseCat`, `IBMGranite`, `QwenLM`, `ChatGPTGratis`, `TextPollinationsAI`, `GliderAI`, `Cohere`, `REKA`, `GROQ`, `AsyncGROQ`, `OPENAI`, `AsyncOPENAI`, `KOBOLDAI`, `AsyncKOBOLDAI`, `BLACKBOXAI`, `PhindSearch`, `GEMINI`, `DeepInfra`, `AI4Chat`, `Phindv2`, `OLLAMA`, `AndiSearch`, `PIZZAGPT`, `Sambanova`, `KOALA`, `Meta`, `AskMyAI`, `PiAI`, `Julius`, `YouChat`, `YEPCHAT`, `Cloudflare`, `TurboSeek`, `TeachAnything`, `AI21`, `Chatify`, `X0GPT`, `Cerebras`, `Lepton`, `GEMINIAPI`, `Cleeai`, `Elmo`, `Free2GPT`, `GPTWeb`, `Netwrck`, `LlamaTutor`, `PromptRefine`, `TutorAI`, `ChatGPTES`, `Bagoodex`, `AIMathGPT`, `GaurishCerebras`, `GeminiPro`, `LLMChat`, `Talkai`, `Llama3Mitril`, `Marcus`, `TypeGPT`, `Netwrck`, `MultiChatAI`, `JadveOpenAI`, `ChatGLM`, `NousHermes`, `FreeAIChat`, `ElectronHub`, `GithubChat`, `Flowith`, `SonusAI`, `UncovrAI`, `LabyrinthAI`, `WebSim`, `LambdaChat`, `ChatGPTClone`, `VercelAI`, `ExaChat`, `AskSteve`, `Aitopia`, `SearchChatAI`
|
|
900
905
|
|
|
901
906
|
Code is similar to other providers.
|
|
902
907
|
|
|
@@ -930,9 +935,9 @@ Webscout provides tools to convert and quantize Hugging Face models into the GGU
|
|
|
930
935
|
from webscout.Extra.gguf import ModelConverter
|
|
931
936
|
"""
|
|
932
937
|
Valid quantization methods:
|
|
933
|
-
"q2_k", "q3_k_l", "q3_k_m", "q3_k_s",
|
|
934
|
-
"q4_0", "q4_1", "q4_k_m", "q4_k_s",
|
|
935
|
-
"q5_0", "q5_1", "q5_k_m", "q5_k_s",
|
|
938
|
+
"q2_k", "q3_k_l", "q3_k_m", "q3_k_s",
|
|
939
|
+
"q4_0", "q4_1", "q4_k_m", "q4_k_s",
|
|
940
|
+
"q5_0", "q5_1", "q5_k_m", "q5_k_s",
|
|
936
941
|
"q6_k", "q8_0"
|
|
937
942
|
"""
|
|
938
943
|
# Create a converter instance
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
webscout/AIauto.py,sha256=7zf3YHvSItQwKvfbS3Nl1sGdaqha5mjaQOizdFNcMlQ,4928
|
|
2
2
|
webscout/AIbase.py,sha256=gksLU3cxp_GnbUqD4mX58tlr4-e6_rqdwVhTUXmJncM,3762
|
|
3
3
|
webscout/AIutel.py,sha256=3o3tc2-0ro9ITTozFuA35oe0aPKwgm8DtzSSPKmpAYg,4046
|
|
4
|
-
webscout/Bard.py,sha256=
|
|
5
|
-
webscout/DWEBS.py,sha256=
|
|
4
|
+
webscout/Bard.py,sha256=WIquaAjoDck5XTq27uT6YVyA5RKTdF8xQ9YNFrLrj1w,20503
|
|
5
|
+
webscout/DWEBS.py,sha256=UvUlOfoGN9DcVXFlWC6QKCRGtKYr5f2YTqLiIwBNDFs,16279
|
|
6
6
|
webscout/LLM.py,sha256=p8Zq5P8lCcg98R1b6YQeUIzmf0b6pJDX_QDjwOXl870,16788
|
|
7
|
-
webscout/__init__.py,sha256=
|
|
7
|
+
webscout/__init__.py,sha256=Ce-d49C2BuIRwp4I_Cwl9D0AZxfHFZkYXZqBUkw44NI,1060
|
|
8
8
|
webscout/__main__.py,sha256=qtkMZK5jzQ79ZkFAuZBxMgayuhmw3aRDj1F8Pt06NW4,108
|
|
9
|
-
webscout/cli.py,sha256=
|
|
10
|
-
webscout/conversation.py,sha256=
|
|
9
|
+
webscout/cli.py,sha256=JRuln7gu7E3-8-CgYcZZwJu4Q-1K2xl55hG_jKW_L9k,12106
|
|
10
|
+
webscout/conversation.py,sha256=wmRZ1xvlx9L1gdOnSSQlxze1cSbFwgm6TEBykNOh2QI,21829
|
|
11
11
|
webscout/exceptions.py,sha256=9rSq7sUFgZYe9UJ6qOlC20xowfzHDTghwGCS6osA8hM,12007
|
|
12
12
|
webscout/models.py,sha256=C7QY-KDkqFCI698t9pvTHQ27rYadPIvwaYHJ3-AOCJI,6566
|
|
13
|
-
webscout/optimizers.py,sha256=
|
|
13
|
+
webscout/optimizers.py,sha256=NlnxWCav7cTyjfeLHuq2pUCgqgW1pljWbMTklHYMGwo,9954
|
|
14
14
|
webscout/prompt_manager.py,sha256=F42AiUIqYIcB-8HNE6VznFwfddAw6DBtfQnGqlDtkMQ,9642
|
|
15
15
|
webscout/tempid.py,sha256=lqTTOjVSwDMmC0UoThdyshFyIAxTikVaN613-6K3g_s,4968
|
|
16
|
-
webscout/update_checker.py,sha256=
|
|
16
|
+
webscout/update_checker.py,sha256=5FCr6p1zLVASXcXkxKEgR7bFvICbpzJdgRTr3teKFCs,4217
|
|
17
17
|
webscout/utils.py,sha256=o2hU3qaVPk25sog3e4cyVZO3l8xwaZpYRziZPotEzNo,3075
|
|
18
|
-
webscout/version.py,sha256=
|
|
19
|
-
webscout/webscout_search.py,sha256=
|
|
20
|
-
webscout/webscout_search_async.py,sha256=
|
|
18
|
+
webscout/version.py,sha256=FD01AZbLTdTygE25Ve3lLKXlM7JzsKUOp887qfipnC8,44
|
|
19
|
+
webscout/webscout_search.py,sha256=OlKFDiAX8175gzOP-GbQ8pRaokJGeKMazMKhPeAxYGE,52895
|
|
20
|
+
webscout/webscout_search_async.py,sha256=suBEYwrh24Rqc_1l2OvzqSpnTwfDWiFAfRQ4I_tfzuY,32796
|
|
21
21
|
webscout/yep_search.py,sha256=4jIn9KKXD6zJMdg302o4rzHQwFAy4haWoIagFn1XjLM,10429
|
|
22
|
-
webscout/Extra/__init__.py,sha256=
|
|
22
|
+
webscout/Extra/__init__.py,sha256=KvJRsRBRO-fZp2jSCl6KQnPppi93hriA6O_U1O1s31c,177
|
|
23
23
|
webscout/Extra/gguf.py,sha256=KpkKIIQf2wtCrWuAdqThLQjQGPziPsGzgcSVuNhObfk,29220
|
|
24
24
|
webscout/Extra/weather.py,sha256=Xfxzt43U5m7qpK3h4pzQ55Zh9JVu5HS6XUeLJccASkE,7841
|
|
25
25
|
webscout/Extra/weather_ascii.py,sha256=k6U0F9w5xXPvYK-Wq3pjUh7W0gGJG4e_YhxeUI65Vpk,2612
|
|
@@ -38,9 +38,15 @@ webscout/Extra/YTToolkit/ytapi/query.py,sha256=A5WJv3ZCz-s_92PFjJwRnmYFv6T7N39da
|
|
|
38
38
|
webscout/Extra/YTToolkit/ytapi/stream.py,sha256=yjIrAFgSNN0Ba8JxwN3M85EgrAMnknZp631w_udAiJ8,2101
|
|
39
39
|
webscout/Extra/YTToolkit/ytapi/utils.py,sha256=mmmUCDMXy3TKauPj6T7PWfEYBAcQ8WiR13xspmlT_SM,2028
|
|
40
40
|
webscout/Extra/YTToolkit/ytapi/video.py,sha256=8KBUDgC4bTpFCANSdexGqbTJOzT95wmaqg5cLortR-c,4050
|
|
41
|
-
webscout/Extra/autocoder/__init__.py,sha256=
|
|
41
|
+
webscout/Extra/autocoder/__init__.py,sha256=Py5-Lq6xLwzp4odeJdGVJ91EgKpPLRMcNyX6jAZpOvQ,230
|
|
42
|
+
webscout/Extra/autocoder/autocoder.py,sha256=ifyaG0uf5ahOZ-2jBpsj19yf55xiEvU6SXKsnJD1N7I,33332
|
|
42
43
|
webscout/Extra/autocoder/autocoder_utiles.py,sha256=JNdeuoo6SmfH5KOOOvklb1jdfNNTmJ8tTyQhRnEtHdM,20574
|
|
43
|
-
webscout/Extra/
|
|
44
|
+
webscout/Extra/tempmail/__init__.py,sha256=f8zICH2hUG7unTX0qelHNJYRnOaPWc6Ws4KZEEglIQo,570
|
|
45
|
+
webscout/Extra/tempmail/async_utils.py,sha256=2IB6OY8NcfYPTqjWd_RLOk1lzYsuzWeJHlmbtWA-E10,4415
|
|
46
|
+
webscout/Extra/tempmail/base.py,sha256=WNUE5VwObXatGMe0QtloQgbqsqv5Y-58fLWLLH4cwew,5211
|
|
47
|
+
webscout/Extra/tempmail/cli.py,sha256=7KBMVodQtN2vM17WMo3OkGesNId6Vch0twjkyB122NY,7017
|
|
48
|
+
webscout/Extra/tempmail/mail_tm.py,sha256=yDGZjVcMU_gJsXJKs3ceLULoon71QZBt4HS26DdDIro,12966
|
|
49
|
+
webscout/Extra/tempmail/temp_mail_io.py,sha256=CrF7VERHqxdgAUHDmhijko3DzaWbsoQsem2DhNotUSM,9715
|
|
44
50
|
webscout/Litlogger/__init__.py,sha256=0lHzxdl5CpGBAABvW4YqVb1-FOibEvTe4SOx8ORHmzs,1568
|
|
45
51
|
webscout/Litlogger/core/__init__.py,sha256=zgZvP-lBrspukBu8LhQb7SUkSIh9HdsVbzpoZyaq110,130
|
|
46
52
|
webscout/Litlogger/core/level.py,sha256=fe0Lz5G-gMpsKAzoLgTUJ53IaFaa5ruXiw4q1ritGI4,584
|
|
@@ -68,24 +74,22 @@ webscout/Provider/ChatGPTGratis.py,sha256=HgqvYSfSvbfqG-nh3vpBWj9TweWn-yrOzoV3MN
|
|
|
68
74
|
webscout/Provider/Chatify.py,sha256=_NoYKkz4kBZNx6n0UZ6_DouYJ1TAbUHPbug0_nAjeJg,6300
|
|
69
75
|
webscout/Provider/Cloudflare.py,sha256=6pUZjdO6c63CLR9NG55Y7lJN8aWnGavsdWv4I9eQzsw,11497
|
|
70
76
|
webscout/Provider/Cohere.py,sha256=oL9kAv--RSkEQxwkPTq1Wi57Wkgg0WNvL82CpTj22YY,8264
|
|
71
|
-
webscout/Provider/DARKAI.py,sha256=Q-t6ti96cGNyAzibj5pMiU5GyU82cxvWsUWPRDf6Qv8,8981
|
|
72
77
|
webscout/Provider/DeepSeek.py,sha256=8NmP3QaD1sjoyWCejd5PcYTdqI7SL79Fa4Icc4DUPjw,7540
|
|
73
|
-
webscout/Provider/Deepinfra.py,sha256=
|
|
74
|
-
webscout/Provider/
|
|
75
|
-
webscout/Provider/
|
|
76
|
-
webscout/Provider/ExaChat.py,sha256=2V9YUWEJ9S_WuWFZ68AmLUTMUDPvvuzQNFLvEukX5nQ,10851
|
|
78
|
+
webscout/Provider/Deepinfra.py,sha256=2hYjF048hEXmc6tpgH6dctFklCJUdajP7LTQfa9kgnU,12512
|
|
79
|
+
webscout/Provider/ElectronHub.py,sha256=nKfLw9HwYd6K9p-sDEl_dud4mPnqzOD9VKSJ3gXIXQI,24372
|
|
80
|
+
webscout/Provider/ExaChat.py,sha256=PRgmqh8mqBOiAyKf2Lvb6-26xRW_0Bb3_JUKeGA9wUs,11277
|
|
77
81
|
webscout/Provider/Free2GPT.py,sha256=FJLn2Ho5oC1bJ2syDfIVvMpMwyFJu32S0ls1rAyr-R0,9213
|
|
78
82
|
webscout/Provider/GPTWeb.py,sha256=xh_mnBko6RDyz2v3KhMux-yIipipkZfVVVoUJWkbzcQ,7466
|
|
79
|
-
webscout/Provider/Gemini.py,sha256=
|
|
83
|
+
webscout/Provider/Gemini.py,sha256=8RQPrxJ58mpSEpbo9mCn5tlo6z7krH8igqSNmHxhkbs,6558
|
|
80
84
|
webscout/Provider/GithubChat.py,sha256=jHwLPR7o8iRaL5KsRIS5suBnTtjx6wVvg1RjJtFBaX4,13856
|
|
81
85
|
webscout/Provider/Glider.py,sha256=q2c6uFNMyKT6qsovZt0KHehXL7LJ1CSrplIGckEFTUA,8475
|
|
82
|
-
webscout/Provider/Groq.py,sha256=
|
|
86
|
+
webscout/Provider/Groq.py,sha256=jlhbTsx32OAb1fiyxN6ypJYLYTvOpJsRPSOrvqruVYo,29563
|
|
83
87
|
webscout/Provider/HeckAI.py,sha256=yihna7seFQ6vMqL6t28KNha3Wz1K0BnmZ4BzN57i_Nw,8869
|
|
84
88
|
webscout/Provider/HuggingFaceChat.py,sha256=iyyDMIJUthdq0P6uv8J-oyMb60C1xLQkYOHw4A71TmQ,19412
|
|
85
89
|
webscout/Provider/Hunyuan.py,sha256=45wHp9OR8iD_r5B8bLgRY7LhtevzAFQ-WXBZ44Ro8dE,11419
|
|
86
90
|
webscout/Provider/Jadve.py,sha256=F4wM1LbCawZVX6040DDCPmJdXdRvHpmp9TS0QWuQths,10820
|
|
87
91
|
webscout/Provider/Koboldai.py,sha256=0mnpya8GBbmBf8s2qAl88h2PjqavwbRab8G6l5mbJlU,15204
|
|
88
|
-
webscout/Provider/LambdaChat.py,sha256=
|
|
92
|
+
webscout/Provider/LambdaChat.py,sha256=Eg_lJ6ywC8cUohTNxR70S1idn60uN-O0xRS7Ces1qyg,15999
|
|
89
93
|
webscout/Provider/Llama.py,sha256=ySwmr3drK58bekE8nxMma7U5kViYW7_WrbqXhOpn5TM,7718
|
|
90
94
|
webscout/Provider/Llama3.py,sha256=aaW0jT403a4KJw07Dogp1jDMuWcDEbsSEA3qdikk2Aw,7671
|
|
91
95
|
webscout/Provider/Marcus.py,sha256=Zhbu8JX-Q8-WmQ8CyBMeX3R7tpZ-BUyGsEEeQiVfhBc,5285
|
|
@@ -99,14 +103,14 @@ webscout/Provider/PizzaGPT.py,sha256=8iSPQgFpev4JEtoIREs2A5L5xATTUS-hWKVMmm75mW0
|
|
|
99
103
|
webscout/Provider/QwenLM.py,sha256=lxnSF38wrupb1e7XhN8f0py8v6efwOndFh2SwvIy7Sc,10430
|
|
100
104
|
webscout/Provider/Reka.py,sha256=dWw4vX91nJhAn-X1SXK72gttRaTqWNGUBFaeRJobTJg,8519
|
|
101
105
|
webscout/Provider/TeachAnything.py,sha256=3hmi94hgu9lDmjxRWQgQFMK5xvJumzKBsquObpI-SnE,7176
|
|
102
|
-
webscout/Provider/TextPollinationsAI.py,sha256=
|
|
106
|
+
webscout/Provider/TextPollinationsAI.py,sha256=kAFXJGgAItBE6Ilc31PSM4_NODArrBuoaaJTjUKuFmE,8885
|
|
103
107
|
webscout/Provider/TwoAI.py,sha256=6-JZ1rxoZY3cgXpK__y4LhbUrptgzMxALef5q5NLKm0,7247
|
|
104
108
|
webscout/Provider/Venice.py,sha256=64qSUwlz-zdw6sSizaZF-5Rg-lPT592P3M2oFjLS0FA,8347
|
|
105
109
|
webscout/Provider/VercelAI.py,sha256=Gqn_TLBwSIgWEHqz612NSy1Dm8PdzMWCgwANR33K7OY,8462
|
|
106
110
|
webscout/Provider/WebSim.py,sha256=8Ea1rKV-LCOL6H6ffgNeS2Vr70rslQUd0yVVtKRjUHA,8819
|
|
107
111
|
webscout/Provider/WiseCat.py,sha256=qYffSfSbgSbERYzkQ4W8YqREMY0AFhh6h8dxT54XPIg,6997
|
|
108
112
|
webscout/Provider/Youchat.py,sha256=PllEeJrUnj9O--ZmZNkaY5zZxhH1P0FrDjh_2pwh9dU,11501
|
|
109
|
-
webscout/Provider/__init__.py,sha256=
|
|
113
|
+
webscout/Provider/__init__.py,sha256=t4bEny045eaECzoTZyx5zld5yieRjYrWaLBRxuMhdRo,3865
|
|
110
114
|
webscout/Provider/ai4chat.py,sha256=mcVr9Q6rni4DPfD7m6poibGhnyOnL3i_4ilxfyVf3fU,8147
|
|
111
115
|
webscout/Provider/aimathgpt.py,sha256=X1dPGdJ-Jc-6nQOnm-Bivzlo0B_n_j2A5cQK1bNrDlA,7176
|
|
112
116
|
webscout/Provider/akashgpt.py,sha256=3FUT3Fj0mK0JdYFWKDMMVIAjNR_OB0FrL1prOXFsry4,12425
|
|
@@ -116,10 +120,10 @@ webscout/Provider/bagoodex.py,sha256=XOmIvOn_P7dpNBgylCveaCIXpAU6awGkvEphZZHrYCM
|
|
|
116
120
|
webscout/Provider/cerebras.py,sha256=cloRZdjz6ZfdPJJD_narRsJac9fZgoPMugheajkev1s,8595
|
|
117
121
|
webscout/Provider/chatglm.py,sha256=0pOS8HQ5bnUjY5E7yjenLLycpQVieNZmD06Wm4KhiwI,8220
|
|
118
122
|
webscout/Provider/cleeai.py,sha256=lgIBs5JpNaY-gfwUBorZdSeA_Q7tawfTvkWWTg7EfuI,7981
|
|
119
|
-
webscout/Provider/copilot.py,sha256=
|
|
123
|
+
webscout/Provider/copilot.py,sha256=Au04Xw0VW5LJB6ODuO7qt097qr7jxG9C4UpoVyfTlNI,19006
|
|
120
124
|
webscout/Provider/elmo.py,sha256=5myTgfEuZTtFHw5C2NT7iY2BjPUwEEkdLlo1m3Nhygc,9317
|
|
121
125
|
webscout/Provider/flowith.py,sha256=o5V7DCeS7ysZ-Ttm9OtmmvYm9_3V-kUFPChga0Of6DE,7719
|
|
122
|
-
webscout/Provider/freeaichat.py,sha256=
|
|
126
|
+
webscout/Provider/freeaichat.py,sha256=5dWWTtzzO_u4cpefwG1yJl7UFEaS0rTmnOrqNlUdM0g,9744
|
|
123
127
|
webscout/Provider/gaurish.py,sha256=-OVX6STSjt0pYn6lH5RiJZ5YPsYtWEorjBgENEsvsAQ,9998
|
|
124
128
|
webscout/Provider/geminiapi.py,sha256=-_QbDBF_IiYyOJ0_uAIcE-gfzIs8H86nA5VWX52SRoY,8505
|
|
125
129
|
webscout/Provider/geminiprorealtime.py,sha256=2ThViylzCGgKl7UfdFQoPdcsYJKIvf4t4wU0cXXQ43I,5775
|
|
@@ -142,9 +146,9 @@ webscout/Provider/talkai.py,sha256=18EB9FPx2rOWdnuqMtBZc_QbLWKNFj06n1Xdtm6npwg,7
|
|
|
142
146
|
webscout/Provider/turboseek.py,sha256=R2vbYHU7vJyhjRKHpPYfVl7P6V23_WuZSL5vlxuKnFA,8563
|
|
143
147
|
webscout/Provider/tutorai.py,sha256=d__8jPhXtJKeOGlqwlxqW3f5meRDi2e3vNWVrOhEMrs,11278
|
|
144
148
|
webscout/Provider/typegpt.py,sha256=ET-tUh3p-72sY6F39aMwVi5k1PGwjBjhanlXhhMGdxY,17369
|
|
145
|
-
webscout/Provider/uncovr.py,sha256=
|
|
149
|
+
webscout/Provider/uncovr.py,sha256=0-OlppjOjKO5_ozzYtzUtut2CbReAlv3bXG4GpuVdH0,13393
|
|
146
150
|
webscout/Provider/x0gpt.py,sha256=5THMLSDxTOzIXh4ZJFnBTxp1uU-6ospTo_u9vrThJ1Y,9459
|
|
147
|
-
webscout/Provider/yep.py,sha256=
|
|
151
|
+
webscout/Provider/yep.py,sha256=Hul4EtWM9kqx_mYaLdoVdyYqGydta4tNrJUffY0fgKU,16957
|
|
148
152
|
webscout/Provider/AISEARCH/DeepFind.py,sha256=WF9y92ep-1Vlxd0TRlOOqrUK7-0ACmpJLV65PjYDG7s,10315
|
|
149
153
|
webscout/Provider/AISEARCH/ISou.py,sha256=CWKq0YE0Qt0e5J2MPjlCNgll7k_-5GrK1UI0r-kZZ_M,9982
|
|
150
154
|
webscout/Provider/AISEARCH/__init__.py,sha256=mO1mvCXUK7pAkjD7LAg3CFqqr0TbiX_B72e7P7niGIo,104
|
|
@@ -204,8 +208,7 @@ webscout/Provider/TTS/utils.py,sha256=pO3GsBmIZ7CHywjOGyrdpHdvch40QMvfAfvAeRBp-O
|
|
|
204
208
|
webscout/litagent/__init__.py,sha256=2HydGSdDVBZ7SRNgGzXX-TJiuol1sxzNJBw7wVAFueo,882
|
|
205
209
|
webscout/litagent/agent.py,sha256=1ZXAYjADlRQw5FKz9vVy9qryNJUFvS6WRFBsIX6EtSY,19101
|
|
206
210
|
webscout/litagent/constants.py,sha256=3_3tWXhmyZ2dFIO8f0YWL4CRkoFoL18h0_jNttTN7mk,2175
|
|
207
|
-
webscout/litprinter/__init__.py,sha256=
|
|
208
|
-
webscout/litprinter/colors.py,sha256=5L_WmYFcp2JoX1rCS4GvFCNCOlj2EhEJRGWvqvs8M54,1247
|
|
211
|
+
webscout/litprinter/__init__.py,sha256=iBYLF0IapDD7piPbNsBHWshg0WQWyP4EvodEPrP3lwI,2452
|
|
209
212
|
webscout/scout/__init__.py,sha256=1dy8mhj4d-X_RDnb3Ip2LKC-2fqgP5zRsHkhdQjAGzE,333
|
|
210
213
|
webscout/scout/core.py,sha256=vOBK8AOBmmdXf5jLeYpbO-qBDsdL0M5Kz3bhj8VLiQ8,29585
|
|
211
214
|
webscout/scout/element.py,sha256=5s_eSY4TbwM-4zLN5rBEHMA5U4rgeyd-z1tGstsUhco,15300
|
|
@@ -237,9 +240,9 @@ webstoken/sentiment.py,sha256=yHtaHXJNS_sH1UTHZsOIgyhdijr8oi1pMlg_QE2wtxw,8202
|
|
|
237
240
|
webstoken/stemmer.py,sha256=VXWkBpPaH328WEQxw9e9ff-p2e27xDdbpVSy0nTnXYE,2624
|
|
238
241
|
webstoken/tagger.py,sha256=p4ScFnxn5sShYDVRoHK5pn_mzaDTsEtx3EHRvuvOlfE,2306
|
|
239
242
|
webstoken/tokenizer.py,sha256=XJ-d1MFRp0Trw6gtOtZ8_wAcaSQidnSCHLNpV1-OFJc,6016
|
|
240
|
-
webscout-7.
|
|
241
|
-
webscout-7.
|
|
242
|
-
webscout-7.
|
|
243
|
-
webscout-7.
|
|
244
|
-
webscout-7.
|
|
245
|
-
webscout-7.
|
|
243
|
+
webscout-7.9.dist-info/LICENSE.md,sha256=hyfFlVn7pWcrvuvs-piB8k4J8DlXdOsYje9RyPxc6Ik,7543
|
|
244
|
+
webscout-7.9.dist-info/METADATA,sha256=iW8b4jnDr3wZfwkgQkBBoChPjdn8U5xxh-7CHhjdmnM,32697
|
|
245
|
+
webscout-7.9.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
246
|
+
webscout-7.9.dist-info/entry_points.txt,sha256=7thMsVUoHiXGoIH1NeoocKpxlszWflNsNyrnDqGzvO0,70
|
|
247
|
+
webscout-7.9.dist-info/top_level.txt,sha256=KQtbgkA3gxcsADB0hIIx-heydmEYXpAY7xn3LjwDx0E,19
|
|
248
|
+
webscout-7.9.dist-info/RECORD,,
|
webscout/Provider/DARKAI.py
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
from typing import Union, Any, Dict, Optional
|
|
3
|
-
from webscout.AIutel import Optimizers
|
|
4
|
-
from webscout.AIutel import Conversation
|
|
5
|
-
from webscout.AIutel import AwesomePrompts, sanitize_stream
|
|
6
|
-
from webscout.AIbase import Provider
|
|
7
|
-
from webscout import exceptions
|
|
8
|
-
from webscout.litagent import LitAgent
|
|
9
|
-
import requests
|
|
10
|
-
|
|
11
|
-
class DARKAI(Provider):
|
|
12
|
-
"""
|
|
13
|
-
A class to interact with the DarkAI API.
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
AVAILABLE_MODELS = [
|
|
17
|
-
"llama-3-70b", # Uncensored
|
|
18
|
-
"llama-3-405b",
|
|
19
|
-
"gpt-3.5-turbo",
|
|
20
|
-
"gpt-4o"
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
def __init__(
|
|
24
|
-
self,
|
|
25
|
-
is_conversation: bool = True,
|
|
26
|
-
max_tokens: int = 600,
|
|
27
|
-
timeout: int = 30,
|
|
28
|
-
intro: str = None,
|
|
29
|
-
filepath: str = None,
|
|
30
|
-
update_file: bool = True,
|
|
31
|
-
proxies: dict = {},
|
|
32
|
-
history_offset: int = 10250,
|
|
33
|
-
act: str = None,
|
|
34
|
-
model: str = "gpt-4o",
|
|
35
|
-
) -> None:
|
|
36
|
-
"""
|
|
37
|
-
Initializes the DARKAI API with given parameters.
|
|
38
|
-
|
|
39
|
-
Args:
|
|
40
|
-
is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
|
|
41
|
-
max_tokens (int, optional): Maximum number of tokens to be generated upon completion.
|
|
42
|
-
Defaults to 600.
|
|
43
|
-
timeout (int, optional): Http request timeout. Defaults to 30.
|
|
44
|
-
intro (str, optional): Conversation introductory prompt. Defaults to None.
|
|
45
|
-
filepath (str, optional): Path to file containing conversation history. Defaults to None.
|
|
46
|
-
update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
|
|
47
|
-
proxies (dict, optional): Http request proxies. Defaults to {}.
|
|
48
|
-
history_offset (int, optional): Limit conversation history to this number of last texts.
|
|
49
|
-
Defaults to 10250.
|
|
50
|
-
act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
|
|
51
|
-
model (str, optional): AI model to use. Defaults to "gpt-4o".
|
|
52
|
-
Options: "llama-3-70b" (uncensored), "llama-3-405b", "gpt-3.5-turbo", "gpt-4o"
|
|
53
|
-
"""
|
|
54
|
-
if model not in self.AVAILABLE_MODELS:
|
|
55
|
-
raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
|
|
56
|
-
|
|
57
|
-
self.session = requests.Session()
|
|
58
|
-
self.is_conversation = is_conversation
|
|
59
|
-
self.max_tokens_to_sample = max_tokens
|
|
60
|
-
self.api_endpoint = "https://darkai.foundation/chat"
|
|
61
|
-
self.stream_chunk_size = 64
|
|
62
|
-
self.timeout = timeout
|
|
63
|
-
self.last_response = {}
|
|
64
|
-
self.model = model
|
|
65
|
-
self.headers = {
|
|
66
|
-
"accept": "text/event-stream",
|
|
67
|
-
"accept-encoding": "gzip, deflate, br, zstd",
|
|
68
|
-
"accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
|
|
69
|
-
"content-type": "application/json",
|
|
70
|
-
"dnt": "1",
|
|
71
|
-
"origin": "https://www.aiuncensored.info",
|
|
72
|
-
"referer": "https://www.aiuncensored.info/",
|
|
73
|
-
"sec-ch-ua": '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
|
|
74
|
-
"sec-ch-ua-mobile": "?0",
|
|
75
|
-
"sec-ch-ua-platform": '"Windows"',
|
|
76
|
-
"sec-fetch-dest": "empty",
|
|
77
|
-
"sec-fetch-mode": "cors",
|
|
78
|
-
"sec-fetch-site": "cross-site",
|
|
79
|
-
"user-agent": LitAgent().random(),
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
self.__available_optimizers = (
|
|
83
|
-
method
|
|
84
|
-
for method in dir(Optimizers)
|
|
85
|
-
if callable(getattr(Optimizers, method)) and not method.startswith("__")
|
|
86
|
-
)
|
|
87
|
-
self.session.headers.update(self.headers)
|
|
88
|
-
Conversation.intro = (
|
|
89
|
-
AwesomePrompts().get_act(
|
|
90
|
-
act, raise_not_found=True, default=None, case_insensitive=True
|
|
91
|
-
)
|
|
92
|
-
if act
|
|
93
|
-
else intro or Conversation.intro
|
|
94
|
-
)
|
|
95
|
-
self.conversation = Conversation(
|
|
96
|
-
is_conversation, self.max_tokens_to_sample, filepath, update_file
|
|
97
|
-
)
|
|
98
|
-
self.conversation.history_offset = history_offset
|
|
99
|
-
self.session.proxies = proxies
|
|
100
|
-
|
|
101
|
-
def ask(
|
|
102
|
-
self,
|
|
103
|
-
prompt: str,
|
|
104
|
-
stream: bool = False,
|
|
105
|
-
raw: bool = False,
|
|
106
|
-
optimizer: str = None,
|
|
107
|
-
conversationally: bool = False,
|
|
108
|
-
) -> Dict[str, Any]:
|
|
109
|
-
"""
|
|
110
|
-
Sends a prompt to the DarkAI API and returns the response.
|
|
111
|
-
|
|
112
|
-
Args:
|
|
113
|
-
prompt: The text prompt to generate text from.
|
|
114
|
-
stream (bool, optional): Whether to stream the response. Defaults to False.
|
|
115
|
-
raw (bool, optional): Whether to return the raw response. Defaults to False.
|
|
116
|
-
optimizer (str, optional): The name of the optimizer to use. Defaults to None.
|
|
117
|
-
conversationally (bool, optional): Whether to chat conversationally. Defaults to False.
|
|
118
|
-
|
|
119
|
-
Returns:
|
|
120
|
-
The response from the API.
|
|
121
|
-
"""
|
|
122
|
-
conversation_prompt = self.conversation.gen_complete_prompt(prompt)
|
|
123
|
-
if optimizer:
|
|
124
|
-
if optimizer in self.__available_optimizers:
|
|
125
|
-
conversation_prompt = getattr(Optimizers, optimizer)(
|
|
126
|
-
conversation_prompt if conversationally else prompt
|
|
127
|
-
)
|
|
128
|
-
else:
|
|
129
|
-
raise Exception(
|
|
130
|
-
f"Optimizer is not one of {self.__available_optimizers}"
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
payload = {
|
|
134
|
-
"query": conversation_prompt,
|
|
135
|
-
"model": self.model
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
def for_stream():
|
|
139
|
-
response = self.session.post(
|
|
140
|
-
self.api_endpoint, json=payload, headers=self.headers, stream=True, timeout=self.timeout
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
if not response.ok:
|
|
144
|
-
raise exceptions.FailedToGenerateResponseError(
|
|
145
|
-
f"Failed to generate response - ({response.status_code}, {response.reason})"
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
streaming_response = ""
|
|
149
|
-
for line in response.iter_lines():
|
|
150
|
-
if line:
|
|
151
|
-
decoded_line = line.decode('utf-8')
|
|
152
|
-
if decoded_line.startswith("data:"):
|
|
153
|
-
data = decoded_line[len("data:"):].strip()
|
|
154
|
-
if data:
|
|
155
|
-
try:
|
|
156
|
-
event = json.loads(data)
|
|
157
|
-
if event.get("event") == "final-response":
|
|
158
|
-
message = event['data'].get('message', '')
|
|
159
|
-
streaming_response += message
|
|
160
|
-
yield message if raw else dict(text=message)
|
|
161
|
-
except json.decoder.JSONDecodeError:
|
|
162
|
-
continue
|
|
163
|
-
self.last_response.update(dict(text=streaming_response))
|
|
164
|
-
self.conversation.update_chat_history(
|
|
165
|
-
prompt, self.get_message(self.last_response)
|
|
166
|
-
)
|
|
167
|
-
def for_non_stream():
|
|
168
|
-
for _ in for_stream():
|
|
169
|
-
pass
|
|
170
|
-
return self.last_response
|
|
171
|
-
|
|
172
|
-
return for_stream() if stream else for_non_stream()
|
|
173
|
-
|
|
174
|
-
def chat(
|
|
175
|
-
self,
|
|
176
|
-
prompt: str,
|
|
177
|
-
stream: bool = False,
|
|
178
|
-
optimizer: str = None,
|
|
179
|
-
conversationally: bool = False,
|
|
180
|
-
) -> str:
|
|
181
|
-
"""Generate response `str`
|
|
182
|
-
Args:
|
|
183
|
-
prompt (str): Prompt to be send.
|
|
184
|
-
stream (bool, optional): Flag for streaming response. Defaults to False.
|
|
185
|
-
optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
|
|
186
|
-
conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
|
|
187
|
-
Returns:
|
|
188
|
-
str: Response generated
|
|
189
|
-
"""
|
|
190
|
-
|
|
191
|
-
def for_stream():
|
|
192
|
-
for response in self.ask(
|
|
193
|
-
prompt, True, optimizer=optimizer, conversationally=conversationally
|
|
194
|
-
):
|
|
195
|
-
yield self.get_message(response)
|
|
196
|
-
|
|
197
|
-
def for_non_stream():
|
|
198
|
-
return self.get_message(
|
|
199
|
-
self.ask(
|
|
200
|
-
prompt,
|
|
201
|
-
False,
|
|
202
|
-
optimizer=optimizer,
|
|
203
|
-
conversationally=conversationally,
|
|
204
|
-
)
|
|
205
|
-
)
|
|
206
|
-
|
|
207
|
-
return for_stream() if stream else for_non_stream()
|
|
208
|
-
|
|
209
|
-
def get_message(self, response: dict) -> str:
|
|
210
|
-
"""Retrieves message only from response
|
|
211
|
-
|
|
212
|
-
Args:
|
|
213
|
-
response (dict): Response generated by `self.ask`
|
|
214
|
-
|
|
215
|
-
Returns:
|
|
216
|
-
str: Message extracted
|
|
217
|
-
"""
|
|
218
|
-
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
219
|
-
return response["text"]
|
|
220
|
-
if __name__ == '__main__':
|
|
221
|
-
from rich import print
|
|
222
|
-
ai = DARKAI()
|
|
223
|
-
response = ai.chat("tell me about india")
|
|
224
|
-
for chunk in response:
|
|
225
|
-
print(chunk, end="", flush=True)
|