webscout 3.4__py3-none-any.whl → 3.6__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.
- webscout/AIutel.py +11 -7
- webscout/DWEBS.py +772 -176
- webscout/Local/rawdog.py +945 -945
- webscout/Provider/Deepinfra.py +479 -0
- webscout/Provider/Deepseek.py +265 -265
- webscout/Provider/OpenGPT.py +381 -1
- webscout/Provider/Phind.py +489 -0
- webscout/Provider/VTLchat.py +252 -0
- webscout/Provider/__init__.py +13 -2
- webscout/__init__.py +41 -30
- webscout/webai.py +15 -0
- webscout/websx_search.py +370 -0
- {webscout-3.4.dist-info → webscout-3.6.dist-info}/METADATA +251 -225
- {webscout-3.4.dist-info → webscout-3.6.dist-info}/RECORD +18 -27
- {webscout-3.4.dist-info → webscout-3.6.dist-info}/WHEEL +1 -1
- {webscout-3.4.dist-info → webscout-3.6.dist-info}/top_level.txt +0 -1
- DeepWEBS/__init__.py +0 -0
- DeepWEBS/documents/__init__.py +0 -0
- DeepWEBS/documents/query_results_extractor.py +0 -99
- DeepWEBS/documents/webpage_content_extractor.py +0 -145
- DeepWEBS/networks/__init__.py +0 -0
- DeepWEBS/networks/filepath_converter.py +0 -109
- DeepWEBS/networks/google_searcher.py +0 -52
- DeepWEBS/networks/network_configs.py +0 -30
- DeepWEBS/networks/webpage_fetcher.py +0 -95
- DeepWEBS/utilsdw/__init__.py +0 -0
- DeepWEBS/utilsdw/enver.py +0 -78
- DeepWEBS/utilsdw/logger.py +0 -269
- {webscout-3.4.dist-info → webscout-3.6.dist-info}/LICENSE.md +0 -0
- {webscout-3.4.dist-info → webscout-3.6.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,252 @@
|
|
|
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 ..AIutel import Optimizers
|
|
23
|
+
from ..AIutel import Conversation
|
|
24
|
+
from ..AIutel import AwesomePrompts, sanitize_stream
|
|
25
|
+
from ..AIbase import Provider, AsyncProvider
|
|
26
|
+
from Helpingai_T2 import Perplexity
|
|
27
|
+
from webscout import exceptions
|
|
28
|
+
from typing import Any, AsyncGenerator, Dict, Optional
|
|
29
|
+
import logging
|
|
30
|
+
import httpx
|
|
31
|
+
class VTLchat(Provider):
|
|
32
|
+
"""
|
|
33
|
+
A class to interact with the VTLchat AI API.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(
|
|
37
|
+
self,
|
|
38
|
+
is_conversation: bool = True,
|
|
39
|
+
max_tokens: int = 600,
|
|
40
|
+
temperature: float = 0.9,
|
|
41
|
+
presence_penalty: float = 0,
|
|
42
|
+
frequency_penalty: float = 0,
|
|
43
|
+
top_p: float = 1,
|
|
44
|
+
model: str = "gpt-3.5-turbo",
|
|
45
|
+
timeout: int = 30,
|
|
46
|
+
intro: str = None,
|
|
47
|
+
filepath: str = None,
|
|
48
|
+
update_file: bool = True,
|
|
49
|
+
proxies: dict = {},
|
|
50
|
+
history_offset: int = 10250,
|
|
51
|
+
act: str = None,
|
|
52
|
+
system_prompt: Optional[str] = "You are ChatGPT, a large language model trained by OpenAI.\nKnowledge cutoff: 2021-09\nCurrent model: gpt-3.5-turbo\nCurrent time: 5/11/2024, 12:26:29 PM\nLatex inline: $x^2$ \nLatex block: $$e=mc^2$$"
|
|
53
|
+
) -> None:
|
|
54
|
+
"""
|
|
55
|
+
Initializes the VTLchat API with given parameters.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
|
|
59
|
+
max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
|
|
60
|
+
temperature (float, optional): Controls randomness. Default is 0.9.
|
|
61
|
+
presence_penalty (float, optional): Controls repetition. Default is 0.
|
|
62
|
+
frequency_penalty (float, optional): Controls frequency of token usage. Default is 0.
|
|
63
|
+
top_p (float, optional): Controls diversity. Default is 1.
|
|
64
|
+
model (str, optional): The AI model to use. Default is 'gpt-3.5-turbo'.
|
|
65
|
+
timeout (int, optional): Http request timeout. Defaults to 30.
|
|
66
|
+
intro (str, optional): Conversation introductory prompt. Defaults to None.
|
|
67
|
+
filepath (str, optional): Path to file containing conversation history. Defaults to None.
|
|
68
|
+
update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
|
|
69
|
+
proxies (dict, optional): Http request proxies. Defaults to {}.
|
|
70
|
+
history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
|
|
71
|
+
act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
|
|
72
|
+
system_prompt (str, optional): System prompt to prepend to the conversation history.
|
|
73
|
+
"""
|
|
74
|
+
self.session = requests.Session()
|
|
75
|
+
self.is_conversation = is_conversation
|
|
76
|
+
self.max_tokens_to_sample = max_tokens
|
|
77
|
+
self.api_endpoint = "https://vtlchat-g1.vercel.app/api/openai/v1/chat/completions"
|
|
78
|
+
self.stream_chunk_size = 64
|
|
79
|
+
self.timeout = timeout
|
|
80
|
+
self.last_response = {}
|
|
81
|
+
self.model = model
|
|
82
|
+
self.temperature = temperature
|
|
83
|
+
self.presence_penalty = presence_penalty
|
|
84
|
+
self.frequency_penalty = frequency_penalty
|
|
85
|
+
self.top_p = top_p
|
|
86
|
+
self.system_prompt = system_prompt
|
|
87
|
+
self.headers = {"Content-Type": "application/json"}
|
|
88
|
+
|
|
89
|
+
self.__available_optimizers = (
|
|
90
|
+
method
|
|
91
|
+
for method in dir(Optimizers)
|
|
92
|
+
if callable(getattr(Optimizers, method)) and not method.startswith("__")
|
|
93
|
+
)
|
|
94
|
+
self.session.headers.update(self.headers)
|
|
95
|
+
Conversation.intro = (
|
|
96
|
+
AwesomePrompts().get_act(
|
|
97
|
+
act, raise_not_found=True, default=None, case_insensitive=True
|
|
98
|
+
)
|
|
99
|
+
if act
|
|
100
|
+
else intro or Conversation.intro
|
|
101
|
+
)
|
|
102
|
+
self.conversation = Conversation(
|
|
103
|
+
is_conversation, self.max_tokens_to_sample, filepath, update_file
|
|
104
|
+
)
|
|
105
|
+
self.conversation.history_offset = history_offset
|
|
106
|
+
self.session.proxies = proxies
|
|
107
|
+
|
|
108
|
+
def ask(
|
|
109
|
+
self,
|
|
110
|
+
prompt: str,
|
|
111
|
+
stream: bool = False,
|
|
112
|
+
raw: bool = False,
|
|
113
|
+
optimizer: str = None,
|
|
114
|
+
conversationally: bool = False,
|
|
115
|
+
) -> dict:
|
|
116
|
+
"""Chat with AI
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
prompt (str): Prompt to be send.
|
|
120
|
+
stream (bool, optional): Flag for streaming response. Defaults to False.
|
|
121
|
+
raw (bool, optional): Stream back raw response as received. Defaults to False.
|
|
122
|
+
optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
|
|
123
|
+
conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
|
|
124
|
+
Returns:
|
|
125
|
+
dict : {}
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"id": "chatcmpl-TaREJpBZsRVQFRFic1wIA7Q7XfnaD",
|
|
129
|
+
"object": "chat.completion",
|
|
130
|
+
"created": 1704623244,
|
|
131
|
+
"model": "gpt-3.5-turbo",
|
|
132
|
+
"usage": {
|
|
133
|
+
"prompt_tokens": 0,
|
|
134
|
+
"completion_tokens": 0,
|
|
135
|
+
"total_tokens": 0
|
|
136
|
+
},
|
|
137
|
+
"choices": [
|
|
138
|
+
{
|
|
139
|
+
"message": {
|
|
140
|
+
"role": "assistant",
|
|
141
|
+
"content": "Hello! How can I assist you today?"
|
|
142
|
+
},
|
|
143
|
+
"finish_reason": "stop",
|
|
144
|
+
"index": 0
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
"""
|
|
150
|
+
conversation_prompt = self.conversation.gen_complete_prompt(prompt)
|
|
151
|
+
if optimizer:
|
|
152
|
+
if optimizer in self.__available_optimizers:
|
|
153
|
+
conversation_prompt = getattr(Optimizers, optimizer)(
|
|
154
|
+
conversation_prompt if conversationally else prompt
|
|
155
|
+
)
|
|
156
|
+
else:
|
|
157
|
+
raise Exception(
|
|
158
|
+
f"Optimizer is not one of {self.__available_optimizers}"
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
self.session.headers.update(self.headers)
|
|
162
|
+
payload = {
|
|
163
|
+
"messages": [
|
|
164
|
+
{"role": "system", "content": self.system_prompt},
|
|
165
|
+
{"role": "user", "content": conversation_prompt}
|
|
166
|
+
],
|
|
167
|
+
"stream": True,
|
|
168
|
+
"model": self.model,
|
|
169
|
+
"temperature": self.temperature,
|
|
170
|
+
"presence_penalty": self.presence_penalty,
|
|
171
|
+
"frequency_penalty": self.frequency_penalty,
|
|
172
|
+
"top_p": self.top_p
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
def for_stream():
|
|
176
|
+
response = self.session.post(
|
|
177
|
+
self.api_endpoint, json=payload, stream=True, timeout=self.timeout
|
|
178
|
+
)
|
|
179
|
+
if not response.ok:
|
|
180
|
+
raise exceptions.FailedToGenerateResponseError(
|
|
181
|
+
f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
streaming_response = ""
|
|
185
|
+
for line in response.iter_lines(decode_unicode=True, chunk_size=1):
|
|
186
|
+
if line:
|
|
187
|
+
modified_line = re.sub("data:", "", line)
|
|
188
|
+
try:
|
|
189
|
+
json_data = json.loads(modified_line)
|
|
190
|
+
content = json_data['choices'][0]['delta']['content']
|
|
191
|
+
streaming_response += content
|
|
192
|
+
yield content if raw else dict(text=streaming_response)
|
|
193
|
+
except:
|
|
194
|
+
continue
|
|
195
|
+
self.last_response.update(dict(text=streaming_response))
|
|
196
|
+
self.conversation.update_chat_history(
|
|
197
|
+
prompt, self.get_message(self.last_response)
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
def for_non_stream():
|
|
201
|
+
for _ in for_stream():
|
|
202
|
+
pass
|
|
203
|
+
return self.last_response
|
|
204
|
+
|
|
205
|
+
return for_stream() if stream else for_non_stream()
|
|
206
|
+
|
|
207
|
+
def chat(
|
|
208
|
+
self,
|
|
209
|
+
prompt: str,
|
|
210
|
+
stream: bool = False,
|
|
211
|
+
optimizer: str = None,
|
|
212
|
+
conversationally: bool = False,
|
|
213
|
+
) -> str:
|
|
214
|
+
"""Generate response `str`
|
|
215
|
+
Args:
|
|
216
|
+
prompt (str): Prompt to be send.
|
|
217
|
+
stream (bool, optional): Flag for streaming response. Defaults to False.
|
|
218
|
+
optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
|
|
219
|
+
conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
|
|
220
|
+
Returns:
|
|
221
|
+
str: Response generated
|
|
222
|
+
"""
|
|
223
|
+
|
|
224
|
+
def for_stream():
|
|
225
|
+
for response in self.ask(
|
|
226
|
+
prompt, True, optimizer=optimizer, conversationally=conversationally
|
|
227
|
+
):
|
|
228
|
+
yield self.get_message(response)
|
|
229
|
+
|
|
230
|
+
def for_non_stream():
|
|
231
|
+
return self.get_message(
|
|
232
|
+
self.ask(
|
|
233
|
+
prompt,
|
|
234
|
+
False,
|
|
235
|
+
optimizer=optimizer,
|
|
236
|
+
conversationally=conversationally,
|
|
237
|
+
)
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
return for_stream() if stream else for_non_stream()
|
|
241
|
+
|
|
242
|
+
def get_message(self, response: dict) -> str:
|
|
243
|
+
"""Retrieves message only from response
|
|
244
|
+
|
|
245
|
+
Args:
|
|
246
|
+
response (dict): Response generated by `self.ask`
|
|
247
|
+
|
|
248
|
+
Returns:
|
|
249
|
+
str: Message extracted
|
|
250
|
+
"""
|
|
251
|
+
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
252
|
+
return response["text"]
|
webscout/Provider/__init__.py
CHANGED
|
@@ -14,13 +14,16 @@ from .Leo import LEO
|
|
|
14
14
|
from .Leo import AsyncLEO
|
|
15
15
|
from .Koboldai import KOBOLDAI
|
|
16
16
|
from .Koboldai import AsyncKOBOLDAI
|
|
17
|
-
from .OpenGPT import OPENGPT
|
|
17
|
+
from .OpenGPT import OPENGPT
|
|
18
|
+
from .OpenGPT import OPENGPTv2
|
|
18
19
|
from .OpenGPT import AsyncOPENGPT
|
|
19
20
|
from .Perplexity import PERPLEXITY
|
|
20
21
|
from .Blackboxai import BLACKBOXAI
|
|
21
22
|
from .Blackboxai import AsyncBLACKBOXAI
|
|
22
23
|
from .Phind import PhindSearch
|
|
23
24
|
from .Phind import AsyncPhindSearch
|
|
25
|
+
from .Phind import Phindv2
|
|
26
|
+
from .Phind import AsyncPhindv2
|
|
24
27
|
from .Yepchat import YEPCHAT
|
|
25
28
|
from .Yepchat import AsyncYEPCHAT
|
|
26
29
|
from .Youchat import YouChat
|
|
@@ -30,7 +33,8 @@ from .ChatGPTUK import ChatGPTUK
|
|
|
30
33
|
from .Poe import POE
|
|
31
34
|
from .BasedGPT import BasedGPT
|
|
32
35
|
from .Deepseek import DeepSeek
|
|
33
|
-
|
|
36
|
+
from .Deepinfra import DeepInfra, VLM, AsyncDeepInfra
|
|
37
|
+
from .VTLchat import VTLchat
|
|
34
38
|
__all__ = [
|
|
35
39
|
'ThinkAnyAI',
|
|
36
40
|
'Xjai',
|
|
@@ -62,5 +66,12 @@ __all__ = [
|
|
|
62
66
|
'POE',
|
|
63
67
|
'BasedGPT',
|
|
64
68
|
'DeepSeek',
|
|
69
|
+
'DeepInfra',
|
|
70
|
+
'VLM',
|
|
71
|
+
'AsyncDeepInfra',
|
|
72
|
+
'VTLchat',
|
|
73
|
+
'AsyncPhindv2',
|
|
74
|
+
'Phindv2',
|
|
75
|
+
'OPENGPTv2',
|
|
65
76
|
|
|
66
77
|
]
|
webscout/__init__.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from .webscout_search import WEBS
|
|
2
2
|
from .webscout_search_async import AsyncWEBS
|
|
3
3
|
from .version import __version__
|
|
4
|
-
from .DWEBS import
|
|
4
|
+
from .DWEBS import *
|
|
5
5
|
from .transcriber import transcriber
|
|
6
6
|
from .voice import play_audio
|
|
7
|
-
|
|
7
|
+
from .websx_search import WEBSX
|
|
8
|
+
|
|
8
9
|
from .LLM import LLM
|
|
9
10
|
# from .Local import *
|
|
10
11
|
import g4f
|
|
@@ -36,6 +37,7 @@ webai = [
|
|
|
36
37
|
"poe",
|
|
37
38
|
"basedgpt",
|
|
38
39
|
"deepseek",
|
|
40
|
+
"deepinfra",
|
|
39
41
|
]
|
|
40
42
|
|
|
41
43
|
gpt4free_providers = [
|
|
@@ -61,34 +63,43 @@ __all__ = [
|
|
|
61
63
|
# "formats",
|
|
62
64
|
|
|
63
65
|
# AI Providers
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
66
|
+
'ThinkAnyAI',
|
|
67
|
+
'Xjai',
|
|
68
|
+
'LLAMA2',
|
|
69
|
+
'AsyncLLAMA2',
|
|
70
|
+
'Cohere',
|
|
71
|
+
'REKA',
|
|
72
|
+
'GROQ',
|
|
73
|
+
'AsyncGROQ',
|
|
74
|
+
'OPENAI',
|
|
75
|
+
'AsyncOPENAI',
|
|
76
|
+
'LEO',
|
|
77
|
+
'AsyncLEO',
|
|
78
|
+
'KOBOLDAI',
|
|
79
|
+
'AsyncKOBOLDAI',
|
|
80
|
+
'OPENGPT',
|
|
81
|
+
'AsyncOPENGPT',
|
|
82
|
+
'PERPLEXITY',
|
|
83
|
+
'BLACKBOXAI',
|
|
84
|
+
'AsyncBLACKBOXAI',
|
|
85
|
+
'PhindSearch',
|
|
86
|
+
'AsyncPhindSearch',
|
|
87
|
+
'YEPCHAT',
|
|
88
|
+
'AsyncYEPCHAT',
|
|
89
|
+
'YouChat',
|
|
90
|
+
'GEMINI',
|
|
91
|
+
'Berlin4h',
|
|
92
|
+
'ChatGPTUK',
|
|
93
|
+
'POE',
|
|
94
|
+
'BasedGPT',
|
|
95
|
+
'DeepSeek',
|
|
96
|
+
'DeepInfra',
|
|
97
|
+
'VLM',
|
|
98
|
+
'AsyncDeepInfra',
|
|
99
|
+
'VTLchat',
|
|
100
|
+
'AsyncPhindv2',
|
|
101
|
+
'Phindv2',
|
|
102
|
+
'OPENGPTv2',
|
|
92
103
|
]
|
|
93
104
|
|
|
94
105
|
import logging
|
webscout/webai.py
CHANGED
|
@@ -658,6 +658,21 @@ class Main(cmd.Cmd):
|
|
|
658
658
|
history_offset=history_offset,
|
|
659
659
|
act=awesome_prompt,
|
|
660
660
|
)
|
|
661
|
+
elif provider == "deepinfra":
|
|
662
|
+
from webscout import DeepInfra
|
|
663
|
+
|
|
664
|
+
self.bot = DeepInfra(
|
|
665
|
+
is_conversation=disable_conversation,
|
|
666
|
+
max_tokens=max_tokens,
|
|
667
|
+
timeout=timeout,
|
|
668
|
+
intro=intro,
|
|
669
|
+
filepath=filepath,
|
|
670
|
+
update_file=update_file,
|
|
671
|
+
proxies=proxies,
|
|
672
|
+
model=getOr(model, "Qwen/Qwen2-72B-Instruct"),
|
|
673
|
+
history_offset=history_offset,
|
|
674
|
+
act=awesome_prompt,
|
|
675
|
+
)
|
|
661
676
|
elif provider == "xjai":
|
|
662
677
|
from webscout import Xjai
|
|
663
678
|
|