webscout 4.7__py3-none-any.whl → 4.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/Agents/functioncall.py +97 -37
- webscout/Bard.py +365 -0
- webscout/Bing_search.py +124 -0
- webscout/DWEBS.py +141 -777
- webscout/Local/_version.py +1 -1
- webscout/Provider/Andi.py +7 -1
- webscout/Provider/BasedGPT.py +11 -5
- webscout/Provider/Berlin4h.py +11 -5
- webscout/Provider/Blackboxai.py +10 -4
- webscout/Provider/Cloudflare.py +286 -0
- webscout/Provider/Cohere.py +11 -5
- webscout/Provider/DARKAI.py +25 -7
- webscout/Provider/Deepinfra.py +2 -1
- webscout/Provider/Deepseek.py +25 -9
- webscout/Provider/DiscordRocks.py +389 -0
- webscout/Provider/Farfalle.py +227 -0
- webscout/Provider/Gemini.py +1 -1
- webscout/Provider/Groq.py +244 -110
- webscout/Provider/Llama.py +13 -5
- webscout/Provider/Llama3.py +15 -2
- webscout/Provider/OLLAMA.py +8 -7
- webscout/Provider/{Geminiflash.py → PI.py} +96 -40
- webscout/Provider/Perplexity.py +422 -52
- webscout/Provider/Phind.py +6 -5
- webscout/Provider/PizzaGPT.py +7 -1
- webscout/Provider/Youchat.py +98 -76
- webscout/Provider/__init__.py +26 -31
- webscout/Provider/ai4chat.py +193 -0
- webscout/Provider/{VTLchat.py → felo_search.py} +62 -76
- webscout/Provider/julius.py +263 -0
- webscout/Provider/koala.py +11 -5
- webscout/Provider/liaobots.py +268 -0
- webscout/Provider/meta.py +2 -1
- webscout/Provider/{ChatGPTUK.py → turboseek.py} +79 -56
- webscout/Provider/{FreeGemini.py → xdash.py} +51 -18
- webscout/Provider/yep.py +258 -0
- webscout/__init__.py +1 -59
- webscout/version.py +1 -1
- webscout/webai.py +2 -64
- webscout/webscout_search.py +1 -1
- {webscout-4.7.dist-info → webscout-4.9.dist-info}/METADATA +249 -323
- webscout-4.9.dist-info/RECORD +83 -0
- webscout/GoogleS.py +0 -342
- webscout/Provider/Geminipro.py +0 -152
- webscout/Provider/Leo.py +0 -469
- webscout/Provider/OpenGPT.py +0 -867
- webscout/Provider/Xjai.py +0 -230
- webscout/Provider/Yepchat.py +0 -478
- webscout-4.7.dist-info/RECORD +0 -80
- {webscout-4.7.dist-info → webscout-4.9.dist-info}/LICENSE.md +0 -0
- {webscout-4.7.dist-info → webscout-4.9.dist-info}/WHEEL +0 -0
- {webscout-4.7.dist-info → webscout-4.9.dist-info}/entry_points.txt +0 -0
- {webscout-4.7.dist-info → webscout-4.9.dist-info}/top_level.txt +0 -0
webscout/Local/_version.py
CHANGED
webscout/Provider/Andi.py
CHANGED
|
@@ -272,4 +272,10 @@ class AndiSearch(Provider):
|
|
|
272
272
|
str: Message extracted
|
|
273
273
|
"""
|
|
274
274
|
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
275
|
-
return response["text"]
|
|
275
|
+
return response["text"]
|
|
276
|
+
if __name__ == '__main__':
|
|
277
|
+
from rich import print
|
|
278
|
+
ai = AndiSearch()
|
|
279
|
+
response = ai.chat("tell me about india")
|
|
280
|
+
for chunk in response:
|
|
281
|
+
print(chunk, end="", flush=True)
|
webscout/Provider/BasedGPT.py
CHANGED
|
@@ -19,10 +19,10 @@ import io
|
|
|
19
19
|
import re
|
|
20
20
|
import json
|
|
21
21
|
import yaml
|
|
22
|
-
from
|
|
23
|
-
from
|
|
24
|
-
from
|
|
25
|
-
from
|
|
22
|
+
from webscout.AIutel import Optimizers
|
|
23
|
+
from webscout.AIutel import Conversation
|
|
24
|
+
from webscout.AIutel import AwesomePrompts, sanitize_stream
|
|
25
|
+
from webscout.AIbase import Provider, AsyncProvider
|
|
26
26
|
from webscout import exceptions
|
|
27
27
|
from typing import Any, AsyncGenerator, Dict
|
|
28
28
|
import logging
|
|
@@ -225,4 +225,10 @@ class BasedGPT(Provider):
|
|
|
225
225
|
str: Message extracted
|
|
226
226
|
"""
|
|
227
227
|
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
228
|
-
return response["text"]
|
|
228
|
+
return response["text"]
|
|
229
|
+
if __name__ == '__main__':
|
|
230
|
+
from rich import print
|
|
231
|
+
ai = BasedGPT()
|
|
232
|
+
response = ai.chat("tell me about india")
|
|
233
|
+
for chunk in response:
|
|
234
|
+
print(chunk, end="", flush=True)
|
webscout/Provider/Berlin4h.py
CHANGED
|
@@ -2,10 +2,10 @@ import requests
|
|
|
2
2
|
import json
|
|
3
3
|
import uuid
|
|
4
4
|
from typing import Any, Dict, Optional
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from
|
|
5
|
+
from webscout.AIutel import Optimizers
|
|
6
|
+
from webscout.AIutel import Conversation
|
|
7
|
+
from webscout.AIutel import AwesomePrompts, sanitize_stream
|
|
8
|
+
from webscout.AIbase import Provider, AsyncProvider
|
|
9
9
|
from webscout import exceptions
|
|
10
10
|
|
|
11
11
|
class Berlin4h(Provider):
|
|
@@ -208,4 +208,10 @@ class Berlin4h(Provider):
|
|
|
208
208
|
str: Message extracted
|
|
209
209
|
"""
|
|
210
210
|
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
211
|
-
return response["text"]
|
|
211
|
+
return response["text"]
|
|
212
|
+
if __name__ == '__main__':
|
|
213
|
+
from rich import print
|
|
214
|
+
ai = Berlin4h()
|
|
215
|
+
response = ai.chat("tell me about india")
|
|
216
|
+
for chunk in response:
|
|
217
|
+
print(chunk, end="", flush=True)
|
webscout/Provider/Blackboxai.py
CHANGED
|
@@ -19,10 +19,10 @@ import io
|
|
|
19
19
|
import re
|
|
20
20
|
import json
|
|
21
21
|
import yaml
|
|
22
|
-
from
|
|
23
|
-
from
|
|
24
|
-
from
|
|
25
|
-
from
|
|
22
|
+
from webscout.AIutel import Optimizers
|
|
23
|
+
from webscout.AIutel import Conversation
|
|
24
|
+
from webscout.AIutel import AwesomePrompts, sanitize_stream
|
|
25
|
+
from webscout.AIbase import Provider, AsyncProvider
|
|
26
26
|
from Helpingai_T2 import Perplexity
|
|
27
27
|
from webscout import exceptions
|
|
28
28
|
from typing import Any, AsyncGenerator, Dict
|
|
@@ -442,3 +442,9 @@ def clean_response(response_text: str) -> str:
|
|
|
442
442
|
# Remove any remaining special characters or markers
|
|
443
443
|
response_text = re.sub(r'\$~~~', '', response_text)
|
|
444
444
|
return response_text
|
|
445
|
+
if __name__ == '__main__':
|
|
446
|
+
from rich import print
|
|
447
|
+
ai = BLACKBOXAI()
|
|
448
|
+
response = ai.chat("tell me about india")
|
|
449
|
+
for chunk in response:
|
|
450
|
+
print(chunk, end="", flush=True)
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import uuid
|
|
3
|
+
from selenium import webdriver
|
|
4
|
+
from selenium.webdriver.chrome.options import Options
|
|
5
|
+
from selenium.webdriver.common.by import By
|
|
6
|
+
from selenium.webdriver.support import expected_conditions as EC
|
|
7
|
+
from selenium.webdriver.support.ui import WebDriverWait
|
|
8
|
+
import click
|
|
9
|
+
import requests
|
|
10
|
+
from requests import get
|
|
11
|
+
from uuid import uuid4
|
|
12
|
+
from re import findall
|
|
13
|
+
from requests.exceptions import RequestException
|
|
14
|
+
from curl_cffi.requests import get, RequestsError
|
|
15
|
+
import g4f
|
|
16
|
+
from random import randint
|
|
17
|
+
from PIL import Image
|
|
18
|
+
import io
|
|
19
|
+
import re
|
|
20
|
+
import json
|
|
21
|
+
import yaml
|
|
22
|
+
from webscout.AIutel import Optimizers
|
|
23
|
+
from webscout.AIutel import Conversation
|
|
24
|
+
from webscout.AIutel import AwesomePrompts, sanitize_stream
|
|
25
|
+
from webscout.AIbase import Provider, AsyncProvider
|
|
26
|
+
from webscout import exceptions
|
|
27
|
+
from typing import Any, AsyncGenerator, Dict
|
|
28
|
+
import logging
|
|
29
|
+
import httpx
|
|
30
|
+
import cloudscraper
|
|
31
|
+
|
|
32
|
+
class Cloudflare(Provider):
|
|
33
|
+
"""
|
|
34
|
+
This class provides methods for interacting with the Playground AI API
|
|
35
|
+
(Cloudflare) in a consistent provider structure for webscout.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
AVAILABLE_MODELS = [
|
|
39
|
+
"@cf/llava-hf/llava-1.5-7b-hf",
|
|
40
|
+
"@cf/unum/uform-gen2-qwen-500m",
|
|
41
|
+
"@cf/facebook/detr-resnet-50",
|
|
42
|
+
"@cf/facebook/bart-large-cnn",
|
|
43
|
+
"@hf/thebloke/deepseek-coder-6.7b-base-awq",
|
|
44
|
+
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq",
|
|
45
|
+
"@cf/deepseek-ai/deepseek-math-7b-base",
|
|
46
|
+
"@cf/deepseek-ai/deepseek-math-7b-instruct",
|
|
47
|
+
"@cf/thebloke/discolm-german-7b-v1-awq",
|
|
48
|
+
"@cf/tiiuae/falcon-7b-instruct",
|
|
49
|
+
"@cf/google/gemma-2b-it-lora",
|
|
50
|
+
"@hf/google/gemma-7b-it",
|
|
51
|
+
"@cf/google/gemma-7b-it-lora",
|
|
52
|
+
"@hf/nousresearch/hermes-2-pro-mistral-7b",
|
|
53
|
+
"@hf/thebloke/llama-2-13b-chat-awq",
|
|
54
|
+
"@cf/meta-llama/llama-2-7b-chat-hf-lora",
|
|
55
|
+
"@cf/meta/llama-3-8b-instruct",
|
|
56
|
+
"@cf/meta/llama-3-8b-instruct-awq",
|
|
57
|
+
"@cf/meta/llama-3.1-8b-instruct",
|
|
58
|
+
"@hf/thebloke/llamaguard-7b-awq",
|
|
59
|
+
"@hf/thebloke/mistral-7b-instruct-v0.1-awq",
|
|
60
|
+
"@hf/mistral/mistral-7b-instruct-v0.2",
|
|
61
|
+
"@cf/mistral/mistral-7b-instruct-v0.2-lora",
|
|
62
|
+
"@hf/thebloke/neural-chat-7b-v3-1-awq",
|
|
63
|
+
"@cf/openchat/openchat-3.5-0106",
|
|
64
|
+
"@hf/thebloke/openhermes-2.5-mistral-7b-awq",
|
|
65
|
+
"@cf/microsoft/phi-2",
|
|
66
|
+
"@cf/qwen/qwen1.5-0.5b-chat",
|
|
67
|
+
"@cf/qwen/qwen1.5-1.8b-chat",
|
|
68
|
+
"@cf/qwen/qwen1.5-14b-chat-awq",
|
|
69
|
+
"@cf/qwen/qwen1.5-7b-chat-awq",
|
|
70
|
+
"@cf/defog/sqlcoder-7b-2",
|
|
71
|
+
"@hf/nexusflow/starling-lm-7b-beta",
|
|
72
|
+
"@cf/tinyllama/tinyllama-1.1b-chat-v1.0",
|
|
73
|
+
"@cf/fblgit/una-cybertron-7b-v2-bf16",
|
|
74
|
+
"@hf/thebloke/zephyr-7b-beta-awq"
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
def __init__(
|
|
78
|
+
self,
|
|
79
|
+
is_conversation: bool = True,
|
|
80
|
+
max_tokens: int = 600,
|
|
81
|
+
timeout: int = 30,
|
|
82
|
+
intro: str = None,
|
|
83
|
+
filepath: str = None,
|
|
84
|
+
update_file: bool = True,
|
|
85
|
+
proxies: dict = {},
|
|
86
|
+
history_offset: int = 10250,
|
|
87
|
+
act: str = None,
|
|
88
|
+
model: str = "@cf/meta/llama-3.1-8b-instruct",
|
|
89
|
+
system_prompt: str = "You are a helpful assistant."
|
|
90
|
+
):
|
|
91
|
+
"""Instantiates Cloudflare
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
|
|
95
|
+
max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
|
|
96
|
+
timeout (int, optional): Http request timeout. Defaults to 30.
|
|
97
|
+
intro (str, optional): Conversation introductory prompt. Defaults to None.
|
|
98
|
+
filepath (str, optional): Path to file containing conversation history. Defaults to None.
|
|
99
|
+
update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
|
|
100
|
+
proxies (dict, optional): Http request proxies. Defaults to {}.
|
|
101
|
+
history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
|
|
102
|
+
act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
|
|
103
|
+
model (str, optional): Model to use for generating text.
|
|
104
|
+
Defaults to "@cf/meta/llama-3.1-8b-instruct".
|
|
105
|
+
Choose from AVAILABLE_MODELS.
|
|
106
|
+
system_prompt (str, optional): System prompt for Cloudflare.
|
|
107
|
+
Defaults to "You are a helpful assistant.".
|
|
108
|
+
"""
|
|
109
|
+
if model not in self.AVAILABLE_MODELS:
|
|
110
|
+
raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
|
|
111
|
+
|
|
112
|
+
self.scraper = cloudscraper.create_scraper()
|
|
113
|
+
self.is_conversation = is_conversation
|
|
114
|
+
self.max_tokens_to_sample = max_tokens
|
|
115
|
+
self.chat_endpoint = "https://playground.ai.cloudflare.com/api/inference"
|
|
116
|
+
self.stream_chunk_size = 64
|
|
117
|
+
self.timeout = timeout
|
|
118
|
+
self.last_response = {}
|
|
119
|
+
self.model = model
|
|
120
|
+
self.system_prompt = system_prompt
|
|
121
|
+
self.headers = {
|
|
122
|
+
'Accept': 'text/event-stream',
|
|
123
|
+
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
124
|
+
'Accept-Language': 'en-US,en;q=0.9,en-IN;q=0.8',
|
|
125
|
+
'Content-Type': 'application/json',
|
|
126
|
+
'DNT': '1',
|
|
127
|
+
'Origin': 'https://playground.ai.cloudflare.com',
|
|
128
|
+
'Referer': 'https://playground.ai.cloudflare.com/',
|
|
129
|
+
'Sec-CH-UA': '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
|
|
130
|
+
'Sec-CH-UA-Mobile': '?0',
|
|
131
|
+
'Sec-CH-UA-Platform': '"Windows"',
|
|
132
|
+
'Sec-Fetch-Dest': 'empty',
|
|
133
|
+
'Sec-Fetch-Mode': 'cors',
|
|
134
|
+
'Sec-Fetch-Site': 'same-origin',
|
|
135
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0',
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
self.cookies = {
|
|
139
|
+
'cfzs_amplitude': uuid4().hex,
|
|
140
|
+
'cfz_amplitude': uuid4().hex,
|
|
141
|
+
'__cf_bm': uuid4().hex,
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
self.__available_optimizers = (
|
|
145
|
+
method
|
|
146
|
+
for method in dir(Optimizers)
|
|
147
|
+
if callable(getattr(Optimizers, method)) and not method.startswith("__")
|
|
148
|
+
)
|
|
149
|
+
# FIX: Initialize the session here
|
|
150
|
+
self.session = cloudscraper.create_scraper()
|
|
151
|
+
self.session.headers.update(self.headers)
|
|
152
|
+
Conversation.intro = (
|
|
153
|
+
AwesomePrompts().get_act(
|
|
154
|
+
act, raise_not_found=True, default=None, case_insensitive=True
|
|
155
|
+
)
|
|
156
|
+
if act
|
|
157
|
+
else intro or Conversation.intro
|
|
158
|
+
)
|
|
159
|
+
self.conversation = Conversation(
|
|
160
|
+
is_conversation, self.max_tokens_to_sample, filepath, update_file
|
|
161
|
+
)
|
|
162
|
+
self.conversation.history_offset = history_offset
|
|
163
|
+
self.session.proxies = proxies
|
|
164
|
+
|
|
165
|
+
def ask(
|
|
166
|
+
self,
|
|
167
|
+
prompt: str,
|
|
168
|
+
stream: bool = False,
|
|
169
|
+
raw: bool = False,
|
|
170
|
+
optimizer: str = None,
|
|
171
|
+
conversationally: bool = False,
|
|
172
|
+
) -> dict:
|
|
173
|
+
"""Chat with AI
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
prompt (str): Prompt to be send.
|
|
177
|
+
stream (bool, optional): Whether to stream the response. Defaults to False.
|
|
178
|
+
raw (bool, optional): Whether to return the raw response. Defaults to False.
|
|
179
|
+
optimizer (str, optional): The name of the optimizer to use. Defaults to None.
|
|
180
|
+
conversationally (bool, optional): Whether to chat conversationally. Defaults to False.
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
The response from the API.
|
|
184
|
+
"""
|
|
185
|
+
conversation_prompt = self.conversation.gen_complete_prompt(prompt)
|
|
186
|
+
if optimizer:
|
|
187
|
+
if optimizer in self.__available_optimizers:
|
|
188
|
+
conversation_prompt = getattr(Optimizers, optimizer)(
|
|
189
|
+
conversation_prompt if conversationally else prompt
|
|
190
|
+
)
|
|
191
|
+
else:
|
|
192
|
+
raise Exception(
|
|
193
|
+
f"Optimizer is not one of {self.__available_optimizers}"
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
payload = {
|
|
197
|
+
"messages": [
|
|
198
|
+
{"role": "system", "content": self.system_prompt},
|
|
199
|
+
{"role": "user", "content": conversation_prompt}
|
|
200
|
+
],
|
|
201
|
+
"lora": None,
|
|
202
|
+
"model": self.model,
|
|
203
|
+
"max_tokens": 512,
|
|
204
|
+
"stream": True
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
def for_stream():
|
|
208
|
+
response = self.scraper.post(
|
|
209
|
+
self.chat_endpoint, headers=self.headers, cookies=self.cookies, data=json.dumps(payload), stream=True, timeout=self.timeout
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
if not response.ok:
|
|
213
|
+
raise exceptions.FailedToGenerateResponseError(
|
|
214
|
+
f"Failed to generate response - ({response.status_code}, {response.reason})"
|
|
215
|
+
)
|
|
216
|
+
streaming_response = ""
|
|
217
|
+
for line in response.iter_lines(decode_unicode=True):
|
|
218
|
+
if line.startswith('data: ') and line != 'data: [DONE]':
|
|
219
|
+
data = json.loads(line[6:])
|
|
220
|
+
content = data.get('response', '')
|
|
221
|
+
streaming_response += content
|
|
222
|
+
yield content if raw else dict(text=streaming_response)
|
|
223
|
+
self.last_response.update(dict(text=streaming_response))
|
|
224
|
+
self.conversation.update_chat_history(
|
|
225
|
+
prompt, self.get_message(self.last_response)
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
def for_non_stream():
|
|
229
|
+
for _ in for_stream():
|
|
230
|
+
pass
|
|
231
|
+
return self.last_response
|
|
232
|
+
|
|
233
|
+
return for_stream() if stream else for_non_stream()
|
|
234
|
+
|
|
235
|
+
def chat(
|
|
236
|
+
self,
|
|
237
|
+
prompt: str,
|
|
238
|
+
stream: bool = False,
|
|
239
|
+
optimizer: str = None,
|
|
240
|
+
conversationally: bool = False,
|
|
241
|
+
) -> str:
|
|
242
|
+
"""Generate response `str`
|
|
243
|
+
Args:
|
|
244
|
+
prompt (str): Prompt to be send.
|
|
245
|
+
stream (bool, optional): Flag for streaming response. Defaults to False.
|
|
246
|
+
optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
|
|
247
|
+
conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
|
|
248
|
+
Returns:
|
|
249
|
+
str: Response generated
|
|
250
|
+
"""
|
|
251
|
+
|
|
252
|
+
def for_stream():
|
|
253
|
+
for response in self.ask(
|
|
254
|
+
prompt, True, optimizer=optimizer, conversationally=conversationally
|
|
255
|
+
):
|
|
256
|
+
yield self.get_message(response)
|
|
257
|
+
|
|
258
|
+
def for_non_stream():
|
|
259
|
+
return self.get_message(
|
|
260
|
+
self.ask(
|
|
261
|
+
prompt,
|
|
262
|
+
False,
|
|
263
|
+
optimizer=optimizer,
|
|
264
|
+
conversationally=conversationally,
|
|
265
|
+
)
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
return for_stream() if stream else for_non_stream()
|
|
269
|
+
|
|
270
|
+
def get_message(self, response: dict) -> str:
|
|
271
|
+
"""Retrieves message only from response
|
|
272
|
+
|
|
273
|
+
Args:
|
|
274
|
+
response (dict): Response generated by `self.ask`
|
|
275
|
+
|
|
276
|
+
Returns:
|
|
277
|
+
str: Message extracted
|
|
278
|
+
"""
|
|
279
|
+
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
280
|
+
return response["text"]
|
|
281
|
+
if __name__ == '__main__':
|
|
282
|
+
from rich import print
|
|
283
|
+
ai = Cloudflare()
|
|
284
|
+
response = ai.chat(input(">>> "))
|
|
285
|
+
for chunk in response:
|
|
286
|
+
print(chunk, end="", flush=True)
|
webscout/Provider/Cohere.py
CHANGED
|
@@ -19,10 +19,10 @@ import io
|
|
|
19
19
|
import re
|
|
20
20
|
import json
|
|
21
21
|
import yaml
|
|
22
|
-
from
|
|
23
|
-
from
|
|
24
|
-
from
|
|
25
|
-
from
|
|
22
|
+
from webscout.AIutel import Optimizers
|
|
23
|
+
from webscout.AIutel import Conversation
|
|
24
|
+
from webscout.AIutel import AwesomePrompts, sanitize_stream
|
|
25
|
+
from webscout.AIbase import Provider, AsyncProvider
|
|
26
26
|
from Helpingai_T2 import Perplexity
|
|
27
27
|
from webscout import exceptions
|
|
28
28
|
from typing import Any, AsyncGenerator, Dict
|
|
@@ -220,4 +220,10 @@ class Cohere(Provider):
|
|
|
220
220
|
str: Message extracted
|
|
221
221
|
"""
|
|
222
222
|
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
223
|
-
return response["result"]["chatStreamEndEvent"]["response"]["text"]
|
|
223
|
+
return response["result"]["chatStreamEndEvent"]["response"]["text"]
|
|
224
|
+
if __name__ == '__main__':
|
|
225
|
+
from rich import print
|
|
226
|
+
ai = Cohere(api_key="")
|
|
227
|
+
response = ai.chat("tell me about india")
|
|
228
|
+
for chunk in response:
|
|
229
|
+
print(chunk, end="", flush=True)
|
webscout/Provider/DARKAI.py
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import time
|
|
2
2
|
import json
|
|
3
3
|
from typing import Any, Dict, Optional
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from
|
|
4
|
+
from webscout.AIutel import Optimizers
|
|
5
|
+
from webscout.AIutel import Conversation
|
|
6
|
+
from webscout.AIutel import AwesomePrompts, sanitize_stream
|
|
7
|
+
from webscout.AIbase import Provider
|
|
8
8
|
from webscout import exceptions
|
|
9
9
|
import requests
|
|
10
|
+
|
|
10
11
|
class DARKAI(Provider):
|
|
11
12
|
"""
|
|
12
13
|
A class to interact with the DarkAI API.
|
|
13
14
|
"""
|
|
14
15
|
|
|
16
|
+
AVAILABLE_MODELS = [
|
|
17
|
+
"llama-3-70b", # Uncensored
|
|
18
|
+
"llama-3-405b",
|
|
19
|
+
"gpt-3.5-turbo",
|
|
20
|
+
"gpt-4o"
|
|
21
|
+
]
|
|
22
|
+
|
|
15
23
|
def __init__(
|
|
16
24
|
self,
|
|
17
25
|
is_conversation: bool = True,
|
|
@@ -23,7 +31,7 @@ class DARKAI(Provider):
|
|
|
23
31
|
proxies: dict = {},
|
|
24
32
|
history_offset: int = 10250,
|
|
25
33
|
act: str = None,
|
|
26
|
-
model: str = "gpt-4o",
|
|
34
|
+
model: str = "gpt-4o",
|
|
27
35
|
) -> None:
|
|
28
36
|
"""
|
|
29
37
|
Initializes the DARKAI API with given parameters.
|
|
@@ -40,8 +48,12 @@ class DARKAI(Provider):
|
|
|
40
48
|
history_offset (int, optional): Limit conversation history to this number of last texts.
|
|
41
49
|
Defaults to 10250.
|
|
42
50
|
act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
|
|
43
|
-
model (str, optional): AI model to use. Defaults to "gpt-4o".
|
|
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"
|
|
44
53
|
"""
|
|
54
|
+
if model not in self.AVAILABLE_MODELS:
|
|
55
|
+
raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
|
|
56
|
+
|
|
45
57
|
self.session = requests.Session()
|
|
46
58
|
self.is_conversation = is_conversation
|
|
47
59
|
self.max_tokens_to_sample = max_tokens
|
|
@@ -204,4 +216,10 @@ class DARKAI(Provider):
|
|
|
204
216
|
str: Message extracted
|
|
205
217
|
"""
|
|
206
218
|
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
207
|
-
return response["text"]
|
|
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)
|
webscout/Provider/Deepinfra.py
CHANGED
webscout/Provider/Deepseek.py
CHANGED
|
@@ -2,10 +2,10 @@ import requests
|
|
|
2
2
|
import json
|
|
3
3
|
from typing import Any, AsyncGenerator, Dict
|
|
4
4
|
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from
|
|
5
|
+
from webscout.AIutel import Optimizers
|
|
6
|
+
from webscout.AIutel import Conversation
|
|
7
|
+
from webscout.AIutel import AwesomePrompts, sanitize_stream
|
|
8
|
+
from webscout.AIbase import Provider, AsyncProvider
|
|
9
9
|
from webscout import exceptions
|
|
10
10
|
|
|
11
11
|
class DeepSeek(Provider):
|
|
@@ -13,10 +13,15 @@ class DeepSeek(Provider):
|
|
|
13
13
|
A class to interact with the Deepseek API.
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
+
AVAILABLE_MODELS = [
|
|
17
|
+
"deepseek_chat",
|
|
18
|
+
"deepseek_code"
|
|
19
|
+
]
|
|
20
|
+
|
|
16
21
|
def __init__(
|
|
17
22
|
self,
|
|
18
23
|
api_key,
|
|
19
|
-
model: str = "deepseek_chat",
|
|
24
|
+
model: str = "deepseek_chat",
|
|
20
25
|
temperature: float = 0,
|
|
21
26
|
is_conversation: bool = True,
|
|
22
27
|
timeout: int = 30,
|
|
@@ -32,9 +37,10 @@ class DeepSeek(Provider):
|
|
|
32
37
|
Initializes the Deepseek API with given parameters.
|
|
33
38
|
|
|
34
39
|
Args:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
api_key (str): The API token for authentication.
|
|
41
|
+
model (str, optional): The AI model to use for text generation.
|
|
42
|
+
Defaults to "deepseek_chat".
|
|
43
|
+
Options: "deepseek_chat", "deepseek_code".
|
|
38
44
|
temperature (float): The temperature parameter for the model.
|
|
39
45
|
is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
|
|
40
46
|
timeout (int, optional): Http request timeout. Defaults to 30.
|
|
@@ -45,6 +51,9 @@ class DeepSeek(Provider):
|
|
|
45
51
|
history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
|
|
46
52
|
act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
|
|
47
53
|
"""
|
|
54
|
+
if model not in self.AVAILABLE_MODELS:
|
|
55
|
+
raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
|
|
56
|
+
|
|
48
57
|
self.api_token = api_key
|
|
49
58
|
self.api_endpoint = "https://chat.deepseek.com/api/v0/chat/completions"
|
|
50
59
|
self.model = model
|
|
@@ -209,4 +218,11 @@ class DeepSeek(Provider):
|
|
|
209
218
|
str: Message extracted
|
|
210
219
|
"""
|
|
211
220
|
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
212
|
-
return response["text"]
|
|
221
|
+
return response["text"]
|
|
222
|
+
|
|
223
|
+
if __name__ == '__main__':
|
|
224
|
+
from rich import print
|
|
225
|
+
ai = DeepSeek(api_key="")
|
|
226
|
+
response = ai.chat("tell me about india")
|
|
227
|
+
for chunk in response:
|
|
228
|
+
print(chunk, end="", flush=True)
|