webscout 1.0.8__py3-none-any.whl → 1.1.0__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/AI.py +345 -228
- webscout/LLM.py +67 -0
- webscout/version.py +2 -1
- {webscout-1.0.8.dist-info → webscout-1.1.0.dist-info}/METADATA +90 -37
- {webscout-1.0.8.dist-info → webscout-1.1.0.dist-info}/RECORD +9 -8
- {webscout-1.0.8.dist-info → webscout-1.1.0.dist-info}/entry_points.txt +1 -0
- {webscout-1.0.8.dist-info → webscout-1.1.0.dist-info}/LICENSE.md +0 -0
- {webscout-1.0.8.dist-info → webscout-1.1.0.dist-info}/WHEEL +0 -0
- {webscout-1.0.8.dist-info → webscout-1.1.0.dist-info}/top_level.txt +0 -0
webscout/AI.py
CHANGED
|
@@ -1,228 +1,345 @@
|
|
|
1
|
-
import time
|
|
2
|
-
from selenium import webdriver
|
|
3
|
-
from selenium.webdriver.chrome.options import Options
|
|
4
|
-
from selenium.webdriver.common.by import By
|
|
5
|
-
from selenium.webdriver.support import expected_conditions as EC
|
|
6
|
-
from selenium.webdriver.support.ui import WebDriverWait
|
|
7
|
-
from halo import Halo
|
|
8
|
-
import click
|
|
9
|
-
import requests
|
|
10
|
-
import json
|
|
11
|
-
from requests import get
|
|
12
|
-
from uuid import uuid4
|
|
13
|
-
from re import findall
|
|
14
|
-
from requests.exceptions import RequestException
|
|
15
|
-
from curl_cffi.requests import get, RequestsError
|
|
16
|
-
import g4f
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
self.
|
|
25
|
-
self.
|
|
26
|
-
self.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"Sec-
|
|
73
|
-
"Sec-
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
1
|
+
import time
|
|
2
|
+
from selenium import webdriver
|
|
3
|
+
from selenium.webdriver.chrome.options import Options
|
|
4
|
+
from selenium.webdriver.common.by import By
|
|
5
|
+
from selenium.webdriver.support import expected_conditions as EC
|
|
6
|
+
from selenium.webdriver.support.ui import WebDriverWait
|
|
7
|
+
from halo import Halo
|
|
8
|
+
import click
|
|
9
|
+
import requests
|
|
10
|
+
import json
|
|
11
|
+
from requests import get
|
|
12
|
+
from uuid import uuid4
|
|
13
|
+
from re import findall
|
|
14
|
+
from requests.exceptions import RequestException
|
|
15
|
+
from curl_cffi.requests import get, RequestsError
|
|
16
|
+
import g4f
|
|
17
|
+
from random import randint
|
|
18
|
+
from PIL import Image
|
|
19
|
+
import io
|
|
20
|
+
|
|
21
|
+
#------------------------------------------------------phind--------------------------------------------------------
|
|
22
|
+
class PhindSearch:
|
|
23
|
+
def __init__(self, query):
|
|
24
|
+
self.query = query
|
|
25
|
+
self.url = "https://www.phind.com/search?q=" + self.query
|
|
26
|
+
self.chrome_options = Options()
|
|
27
|
+
self.chrome_options.add_argument("--log-level=3") # Fatal errors only
|
|
28
|
+
self.chrome_options.add_argument("--headless")
|
|
29
|
+
self.chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
|
|
30
|
+
self.driver = webdriver.Chrome(options=self.chrome_options)
|
|
31
|
+
|
|
32
|
+
def search(self):
|
|
33
|
+
try:
|
|
34
|
+
spinner = Halo("Getting Answer from Phind...\n\n\n\n\n\n\n \n", spinner="dots")
|
|
35
|
+
spinner.start()
|
|
36
|
+
|
|
37
|
+
self.driver.get(self.url)
|
|
38
|
+
|
|
39
|
+
WebDriverWait(self.driver, timeout=50).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
|
|
40
|
+
time.sleep(15)
|
|
41
|
+
answer_elements = self.driver.find_elements(By.CSS_SELECTOR, "main div.fs-5")
|
|
42
|
+
|
|
43
|
+
paragraph_texts = [answer_element.text.strip() for answer_element in answer_elements]
|
|
44
|
+
|
|
45
|
+
for text in paragraph_texts:
|
|
46
|
+
spinner.stop()
|
|
47
|
+
print(text)
|
|
48
|
+
|
|
49
|
+
finally:
|
|
50
|
+
self.driver.quit()
|
|
51
|
+
|
|
52
|
+
def close(self):
|
|
53
|
+
self.driver.quit()
|
|
54
|
+
|
|
55
|
+
@staticmethod
|
|
56
|
+
def search_cli(query):
|
|
57
|
+
"""Use webscout.AI."""
|
|
58
|
+
search_instance = PhindSearch(query)
|
|
59
|
+
search_instance.search()
|
|
60
|
+
#------------------------------------------------------yep.com--------------------------------------------------------
|
|
61
|
+
class YepChat:
|
|
62
|
+
def __init__(self, message="hello"):
|
|
63
|
+
self.url = "https://api.yep.com/v1/chat/completions"
|
|
64
|
+
self.headers = {
|
|
65
|
+
"Accept": "*/*",
|
|
66
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
67
|
+
"Accept-Language": "en-US,en;q=0.9",
|
|
68
|
+
"Cache-Control": "max-age=0",
|
|
69
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
70
|
+
"Origin": "https://yep.com",
|
|
71
|
+
"Referer": "https://yep.com/",
|
|
72
|
+
"Sec-Ch-Ua": '"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
|
|
73
|
+
"Sec-Ch-Ua-Mobile": "?0",
|
|
74
|
+
"Sec-Ch-Ua-Platform": '"Windows"',
|
|
75
|
+
"Sec-Fetch-Dest": "empty",
|
|
76
|
+
"Sec-Fetch-Mode": "cors",
|
|
77
|
+
"Sec-Fetch-Site": "same-site",
|
|
78
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0.0.0 Safari/537.36"
|
|
79
|
+
}
|
|
80
|
+
self.payload = {
|
|
81
|
+
"stream": True,
|
|
82
|
+
"max_tokens": 1280,
|
|
83
|
+
"top_p": 0.7,
|
|
84
|
+
"temperature": 0.6,
|
|
85
|
+
"messages": [{
|
|
86
|
+
"content": message,
|
|
87
|
+
"role": "user"
|
|
88
|
+
}],
|
|
89
|
+
"model": "Mixtral-8x7B-Instruct-v0.1"
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
def send_request(self):
|
|
93
|
+
response = requests.post(self.url, headers=self.headers, data=json.dumps(self.payload), stream=True)
|
|
94
|
+
print(response.status_code)
|
|
95
|
+
return response
|
|
96
|
+
|
|
97
|
+
def process_response(self, response):
|
|
98
|
+
myset = ""
|
|
99
|
+
for line in response.iter_lines():
|
|
100
|
+
if line:
|
|
101
|
+
myline = line.decode('utf-8').removeprefix("data: ").replace(" null", "False")
|
|
102
|
+
try:
|
|
103
|
+
myval = eval(myline)
|
|
104
|
+
if "choices" in myval and "delta" in myval["choices"][0] and "content" in myval["choices"][0]["delta"]:
|
|
105
|
+
myset += myval["choices"][0]["delta"]["content"]
|
|
106
|
+
except:
|
|
107
|
+
continue
|
|
108
|
+
return myset
|
|
109
|
+
|
|
110
|
+
@staticmethod
|
|
111
|
+
def chat_cli(message):
|
|
112
|
+
"""Sends a request to the Yep API and processes the response."""
|
|
113
|
+
yep_chat = YepChat(message=message)
|
|
114
|
+
response = yep_chat.send_request()
|
|
115
|
+
processed_response = yep_chat.process_response(response)
|
|
116
|
+
print(processed_response)
|
|
117
|
+
#------------------------------------------------------youchat--------------------------------------------------------
|
|
118
|
+
class youChat:
|
|
119
|
+
"""
|
|
120
|
+
This class provides methods for generating completions based on prompts.
|
|
121
|
+
"""
|
|
122
|
+
def create(self, prompt):
|
|
123
|
+
"""
|
|
124
|
+
Generate a completion based on the provided prompt.
|
|
125
|
+
|
|
126
|
+
Args:
|
|
127
|
+
prompt (str): The input prompt to generate a completion from.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
str: The generated completion as a text string.
|
|
131
|
+
|
|
132
|
+
Raises:
|
|
133
|
+
Exception: If the response does not contain the expected "youChatToken".
|
|
134
|
+
"""
|
|
135
|
+
resp = get(
|
|
136
|
+
"https://you.com/api/streamingSearch",
|
|
137
|
+
headers={
|
|
138
|
+
"cache-control": "no-cache",
|
|
139
|
+
"referer": "https://you.com/search?q=gpt4&tbm=youchat",
|
|
140
|
+
"cookie": f"safesearch_guest=Off; uuid_guest={str(uuid4())}",
|
|
141
|
+
},
|
|
142
|
+
params={
|
|
143
|
+
"q": prompt,
|
|
144
|
+
"page": 1,
|
|
145
|
+
"count": 10,
|
|
146
|
+
"safeSearch": "Off",
|
|
147
|
+
"onShoppingPage": False,
|
|
148
|
+
"mkt": "",
|
|
149
|
+
"responseFilter": "WebPages,Translations,TimeZone,Computation,RelatedSearches",
|
|
150
|
+
"domain": "youchat",
|
|
151
|
+
"queryTraceId": str(uuid4()),
|
|
152
|
+
"chat": [],
|
|
153
|
+
},
|
|
154
|
+
impersonate="chrome107",
|
|
155
|
+
)
|
|
156
|
+
if "youChatToken" not in resp.text:
|
|
157
|
+
raise RequestsError("Unable to fetch the response.")
|
|
158
|
+
return (
|
|
159
|
+
"".join(
|
|
160
|
+
findall(
|
|
161
|
+
r"{\"youChatToken\": \"(.*?)\"}",
|
|
162
|
+
resp.content.decode("unicode-escape"),
|
|
163
|
+
)
|
|
164
|
+
)
|
|
165
|
+
.replace("\\n", "\n")
|
|
166
|
+
.replace("\\\\", "\\")
|
|
167
|
+
.replace('\\"', '"')
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
@staticmethod
|
|
171
|
+
def chat_cli(prompt):
|
|
172
|
+
"""Generate completion based on the provided prompt"""
|
|
173
|
+
you_chat = youChat()
|
|
174
|
+
completion = you_chat.create(prompt)
|
|
175
|
+
print(completion)
|
|
176
|
+
#------------------------------------------------------Gemini--------------------------------------------------------
|
|
177
|
+
class Gemini:
|
|
178
|
+
def __init__(self):
|
|
179
|
+
self.messages = []
|
|
180
|
+
|
|
181
|
+
def chat(self, *args):
|
|
182
|
+
assert args != ()
|
|
183
|
+
|
|
184
|
+
message = " ".join(args)
|
|
185
|
+
self.messages.append({"role": "user", "content": message})
|
|
186
|
+
|
|
187
|
+
response = g4f.ChatCompletion.create(
|
|
188
|
+
model=g4f.models.default,
|
|
189
|
+
provider=g4f.Provider.Gemini,
|
|
190
|
+
messages=self.messages,
|
|
191
|
+
stream=True,
|
|
192
|
+
)
|
|
193
|
+
ms = ""
|
|
194
|
+
for message in response:
|
|
195
|
+
ms += message
|
|
196
|
+
print(ms.strip(), end="", flush=True) # Ensure no trailing whitespace is printed
|
|
197
|
+
print()
|
|
198
|
+
self.messages.append({"role": "assistant", "content": ms.strip()}) # Strip whitespace from the message content
|
|
199
|
+
return ms.strip() # Return the message without trailing whitespace
|
|
200
|
+
|
|
201
|
+
@staticmethod
|
|
202
|
+
def chat_cli(message):
|
|
203
|
+
"""Generate completion based on the provided message"""
|
|
204
|
+
gemini = Gemini()
|
|
205
|
+
gemini.chat(message)
|
|
206
|
+
#------------------------------------------------Prodia-------------------------------------------------------------------------
|
|
207
|
+
class Prodia:
|
|
208
|
+
"""
|
|
209
|
+
This class provides methods for generating images based on prompts.
|
|
210
|
+
"""
|
|
211
|
+
|
|
212
|
+
def create(self, prompt):
|
|
213
|
+
"""
|
|
214
|
+
Create a new image generation based on the given prompt.
|
|
215
|
+
|
|
216
|
+
Args:
|
|
217
|
+
prompt (str): The prompt for generating the image.
|
|
218
|
+
|
|
219
|
+
Returns:
|
|
220
|
+
resp: The generated image content
|
|
221
|
+
"""
|
|
222
|
+
headers = {
|
|
223
|
+
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.79 Safari/537.36",
|
|
224
|
+
}
|
|
225
|
+
try:
|
|
226
|
+
resp = get(
|
|
227
|
+
"https://api.prodia.com/generate",
|
|
228
|
+
params={
|
|
229
|
+
"new": "true",
|
|
230
|
+
"prompt": prompt,
|
|
231
|
+
"model": "dreamshaper_6BakedVae.safetensors [114c8abb]",
|
|
232
|
+
"negative_prompt": "(nsfw:1.5),verybadimagenegative_v1.3, ng_deepnegative_v1_75t, (ugly face:0.5),cross-eyed,sketches, (worst quality:2), (low quality:2.1), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, bad anatomy, DeepNegative, facing away, tilted head, {Multiple people}, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worstquality, low quality, normal quality, jpegartifacts, signature, watermark, username, blurry, bad feet, cropped, poorly drawn hands, poorly drawn face, mutation, deformed, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, extra fingers, fewer digits, extra limbs, extra arms,extra legs, malformed limbs, fused fingers, too many fingers, long neck, cross-eyed,mutated hands, polar lowres, bad body, bad proportions, gross proportions, text, error, missing fingers, missing arms, missing legs, extra digit, extra arms, extra leg, extra foot, repeating hair",
|
|
233
|
+
"steps": "50",
|
|
234
|
+
"cfg": "9.5",
|
|
235
|
+
"seed": randint(1, 10000),
|
|
236
|
+
"sampler": "Euler",
|
|
237
|
+
"aspect_ratio": "square",
|
|
238
|
+
},
|
|
239
|
+
headers=headers,
|
|
240
|
+
timeout=30,
|
|
241
|
+
)
|
|
242
|
+
data = resp.json()
|
|
243
|
+
while True:
|
|
244
|
+
resp = get(f"https://api.prodia.com/job/{data['job']}", headers=headers)
|
|
245
|
+
json = resp.json()
|
|
246
|
+
if json["status"] == "succeeded":
|
|
247
|
+
return get(
|
|
248
|
+
f"https://images.prodia.xyz/{data['job']}.png?download=1",
|
|
249
|
+
headers=headers,
|
|
250
|
+
).content
|
|
251
|
+
except RequestException as exc:
|
|
252
|
+
raise RequestException("Unable to fetch the response.") from exc
|
|
253
|
+
|
|
254
|
+
@staticmethod
|
|
255
|
+
def prodia_cli(prompt):
|
|
256
|
+
"""Generate an image based on the provided prompt."""
|
|
257
|
+
generator = Prodia()
|
|
258
|
+
try:
|
|
259
|
+
image_content = generator.create(prompt)
|
|
260
|
+
# Save the image content to a file
|
|
261
|
+
with open('generated_image.png', 'wb') as f:
|
|
262
|
+
f.write(image_content)
|
|
263
|
+
print("Image generated successfully and saved as generated_image.png")
|
|
264
|
+
|
|
265
|
+
# Open the image file and display it
|
|
266
|
+
image = Image.open('generated_image.png')
|
|
267
|
+
image.show()
|
|
268
|
+
except Exception as e:
|
|
269
|
+
print(f"An error occurred: {e}")
|
|
270
|
+
#-------------------------------------------------------Pollination--------------------------------------------------------------------------------------
|
|
271
|
+
class Pollinations:
|
|
272
|
+
"""
|
|
273
|
+
This class provides methods for generating images based on prompts.
|
|
274
|
+
"""
|
|
275
|
+
|
|
276
|
+
def create(self, prompt):
|
|
277
|
+
"""
|
|
278
|
+
Create a new image generation based on the given prompt.
|
|
279
|
+
|
|
280
|
+
Args:
|
|
281
|
+
prompt (str): The prompt for generating the image.
|
|
282
|
+
|
|
283
|
+
Returns:
|
|
284
|
+
resp: The generated image content
|
|
285
|
+
"""
|
|
286
|
+
try:
|
|
287
|
+
return get(
|
|
288
|
+
url=f"https://image.pollinations.ai/prompt/{prompt}{randint(1, 10000)}",
|
|
289
|
+
timeout=30,
|
|
290
|
+
).content
|
|
291
|
+
except RequestException as exc:
|
|
292
|
+
raise RequestException("Unable to fetch the response.") from exc
|
|
293
|
+
|
|
294
|
+
@staticmethod
|
|
295
|
+
def pollinations_cli(prompt):
|
|
296
|
+
"""Generate an image based on the provided prompt."""
|
|
297
|
+
generator = Pollinations()
|
|
298
|
+
try:
|
|
299
|
+
image_content = generator.create(prompt)
|
|
300
|
+
# Save the image content to a file
|
|
301
|
+
with open('generated_image.png', 'wb') as f:
|
|
302
|
+
f.write(image_content)
|
|
303
|
+
print("Image generated successfully and saved as generated_image.png")
|
|
304
|
+
|
|
305
|
+
# Open the image file and display it
|
|
306
|
+
image = Image.open('generated_image.png')
|
|
307
|
+
image.show()
|
|
308
|
+
except Exception as e:
|
|
309
|
+
print(f"An error occurred: {e}")
|
|
310
|
+
|
|
311
|
+
@click.group()
|
|
312
|
+
def cli():
|
|
313
|
+
pass
|
|
314
|
+
|
|
315
|
+
@cli.command()
|
|
316
|
+
@click.option('--query', prompt='Enter your search query', help='The query to search.')
|
|
317
|
+
def phindsearch(query):
|
|
318
|
+
PhindSearch.search_cli(query)
|
|
319
|
+
|
|
320
|
+
@cli.command()
|
|
321
|
+
@click.option('--message', prompt='Enter your message', help='The message to send.')
|
|
322
|
+
def yepchat(message):
|
|
323
|
+
YepChat.chat_cli(message)
|
|
324
|
+
|
|
325
|
+
@cli.command()
|
|
326
|
+
@click.option('--prompt', prompt='Enter your prompt', help='The prompt to generate a completion from.')
|
|
327
|
+
def youchat(prompt):
|
|
328
|
+
youChat.chat_cli(prompt)
|
|
329
|
+
|
|
330
|
+
@cli.command()
|
|
331
|
+
@click.option('--message', prompt='Enter your message', help='The message to send.')
|
|
332
|
+
def gemini(message):
|
|
333
|
+
Gemini.chat_cli(message)
|
|
334
|
+
@cli.command()
|
|
335
|
+
@click.option('--prompt', prompt='Enter your prompt', help='The prompt for generating the image.')
|
|
336
|
+
def prodia(prompt):
|
|
337
|
+
"""Generate an image based on the provided prompt."""
|
|
338
|
+
Prodia.prodia_cli(prompt)
|
|
339
|
+
@cli.command()
|
|
340
|
+
@click.option('--prompt', prompt='Enter your prompt', help='The prompt for generating the image.')
|
|
341
|
+
def pollinations(prompt):
|
|
342
|
+
"""Generate an image based on the provided prompt."""
|
|
343
|
+
Pollinations.pollinations_cli(prompt)
|
|
344
|
+
if __name__ == '__main__':
|
|
345
|
+
cli()
|
webscout/LLM.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import requests
|
|
3
|
+
import json
|
|
4
|
+
from typing import List, Dict, Union
|
|
5
|
+
|
|
6
|
+
class LLM:
|
|
7
|
+
def __init__(self, model: str):
|
|
8
|
+
self.model = model
|
|
9
|
+
self.conversation_history = [{"role": "system", "content": "You are a Helpful AI."}]
|
|
10
|
+
|
|
11
|
+
def mistral_chat(self, messages: List[Dict[str, str]]) -> Union[str, None]:
|
|
12
|
+
url = "https://api.deepinfra.com/v1/openai/chat/completions"
|
|
13
|
+
headers = {
|
|
14
|
+
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
|
|
15
|
+
'Accept-Language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
|
|
16
|
+
'Cache-Control': 'no-cache',
|
|
17
|
+
'Connection': 'keep-alive',
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
'Origin': 'https://deepinfra.com',
|
|
20
|
+
'Pragma': 'no-cache',
|
|
21
|
+
'Referer': 'https://deepinfra.com/',
|
|
22
|
+
'Sec-Fetch-Dest': 'empty',
|
|
23
|
+
'Sec-Fetch-Mode': 'cors',
|
|
24
|
+
'Sec-Fetch-Site': 'same-site',
|
|
25
|
+
'X-Deepinfra-Source': 'web-embed',
|
|
26
|
+
'accept': 'text/event-stream',
|
|
27
|
+
'sec-ch-ua': '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
|
|
28
|
+
'sec-ch-ua-mobile': '?0',
|
|
29
|
+
'sec-ch-ua-platform': '"macOS"'
|
|
30
|
+
}
|
|
31
|
+
data = json.dumps(
|
|
32
|
+
{
|
|
33
|
+
'model': self.model,
|
|
34
|
+
'messages': messages,
|
|
35
|
+
'temperature': 0.7,
|
|
36
|
+
'max_tokens': 4028,
|
|
37
|
+
'stop': [],
|
|
38
|
+
'stream': False
|
|
39
|
+
}, separators=(',', ':')
|
|
40
|
+
)
|
|
41
|
+
try:
|
|
42
|
+
result = requests.post(url=url, data=data, headers=headers)
|
|
43
|
+
return result.json()['choices'][0]['message']['content']
|
|
44
|
+
except:
|
|
45
|
+
return None
|
|
46
|
+
|
|
47
|
+
def chat(self):
|
|
48
|
+
while True:
|
|
49
|
+
prompt = input("👦: ")
|
|
50
|
+
user_message = {"role": "user", "content": prompt}
|
|
51
|
+
self.conversation_history.append(user_message)
|
|
52
|
+
try:
|
|
53
|
+
resp = self.mistral_chat(self.conversation_history)
|
|
54
|
+
print(f"🤖: {resp}")
|
|
55
|
+
self.conversation_history.append({"role": "assistant", "content": resp})
|
|
56
|
+
except Exception as e:
|
|
57
|
+
print(f"🤖: Oops, something went wrong: {e}! Looks like even AI needs some oiling sometimes.")
|
|
58
|
+
|
|
59
|
+
if __name__ == "__main__":
|
|
60
|
+
parser = argparse.ArgumentParser(description='LLM CLI', epilog='To use a specific model, run:\n'
|
|
61
|
+
'python -m webscout.LLM model_name\n'
|
|
62
|
+
'Replace "model_name" with the name of the model you wish to use It supports ALL text generation models on deepinfra.com.')
|
|
63
|
+
parser.add_argument('model', type=str, help='Model to use for text generation. Specify the full model name, e.g., "mistralai/Mistral-7B-Instruct-v0.1".')
|
|
64
|
+
args = parser.parse_args()
|
|
65
|
+
|
|
66
|
+
LLM = LLM(args.model)
|
|
67
|
+
LLM.chat()
|
webscout/version.py
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
__version__ = "1.0
|
|
1
|
+
__version__ = "1.1.0"
|
|
2
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: webscout
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Search for words, documents, images, videos, news, maps and text translation using the DuckDuckGo.com, yep.com, phind.com and you.com Also containes AI models
|
|
5
5
|
Author: OEvortex
|
|
6
6
|
Author-email: helpingai5@gmail.com
|
|
@@ -44,11 +44,12 @@ Also containes AI models that you can use
|
|
|
44
44
|
- [Table of Contents](#table-of-contents)
|
|
45
45
|
- [Install](#install)
|
|
46
46
|
- [CLI version](#cli-version)
|
|
47
|
-
- [CLI version of AI](#cli-version-of-
|
|
47
|
+
- [CLI version of webscout.AI](#cli-version-of-webscoutai)
|
|
48
|
+
- [CLI to use LLM](#cli-to-use-llm)
|
|
48
49
|
- [Regions](#regions)
|
|
49
50
|
- [WEBS and AsyncWEBS classes](#webs-and-asyncwebs-classes)
|
|
50
51
|
- [Exceptions](#exceptions)
|
|
51
|
-
- [usage](#usage)
|
|
52
|
+
- [usage of webscout](#usage-of-webscout)
|
|
52
53
|
- [1. `text()` - text search by DuckDuckGo.com and Yep.com](#1-text---text-search-by-duckduckgocom-and-yepcom)
|
|
53
54
|
- [2. `answers()` - instant answers by DuckDuckGo.com and Yep.com](#2-answers---instant-answers-by-duckduckgocom-and-yepcom)
|
|
54
55
|
- [3. `images()` - image search by DuckDuckGo.com and Yep.com](#3-images---image-search-by-duckduckgocom-and-yepcom)
|
|
@@ -57,11 +58,19 @@ Also containes AI models that you can use
|
|
|
57
58
|
- [6. `maps()` - map search by DuckDuckGo.com and](#6-maps---map-search-by-duckduckgocom-and)
|
|
58
59
|
- [7. `translate()` - translation by DuckDuckGo.com and Yep.com](#7-translate---translation-by-duckduckgocom-and-yepcom)
|
|
59
60
|
- [8. `suggestions()` - suggestions by DuckDuckGo.com and Yep.com](#8-suggestions---suggestions-by-duckduckgocom-and-yepcom)
|
|
60
|
-
|
|
61
|
-
- [
|
|
62
|
-
- [
|
|
63
|
-
- [
|
|
61
|
+
- [usage of webscout.AI](#usage-of-webscoutai)
|
|
62
|
+
- [1. `PhindSearch` - Search using Phind.com](#1-phindsearch---search-using-phindcom)
|
|
63
|
+
- [2. `YepChat` - Chat with mistral 8x7b powered by yepchat](#2-yepchat---chat-with-mistral-8x7b-powered-by-yepchat)
|
|
64
|
+
- [3. `You.com` - search with you.com](#3-youcom---search-with-youcom)
|
|
65
|
+
- [4. `Gemini` - search with google gemini](#4-gemini---search-with-google-gemini)
|
|
66
|
+
- [usage of image generator from Webscout.AI](#usage-of-image-generator-from-webscoutai)
|
|
67
|
+
- [5. `Prodia` - make image using prodia](#5-prodia---make-image-using-prodia)
|
|
68
|
+
- [usage of special .LLM file from webscout (webscout.LLM)](#usage-of-special-llm-file-from-webscout-webscoutllm)
|
|
69
|
+
- [`LLM`](#llm)
|
|
64
70
|
- [Version History](#version-history)
|
|
71
|
+
- [v1.1.0](#v110)
|
|
72
|
+
- [v1.0.9](#v109)
|
|
73
|
+
- [v1.0.8](#v108)
|
|
65
74
|
- [v1.0.7](#v107)
|
|
66
75
|
- [v1.0.6](#v106)
|
|
67
76
|
|
|
@@ -75,24 +84,36 @@ pip install -U webscout
|
|
|
75
84
|
```python3
|
|
76
85
|
python -m webscout --help
|
|
77
86
|
```
|
|
78
|
-
## CLI version of AI
|
|
79
87
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
| Command | Description |
|
|
89
|
+
|-------------------------------------------|-------------------------------------------------------------------------------------------------------|
|
|
90
|
+
| python -m webscout answers -k Text | CLI function to perform an answers search using Webscout. |
|
|
91
|
+
| python -m webscout images -k Text | CLI function to perform an images search using Webscout. |
|
|
92
|
+
| python -m webscout maps -k Text | CLI function to perform a maps search using Webscout. |
|
|
93
|
+
| python -m webscout news -k Text | CLI function to perform a news search using Webscout. |
|
|
94
|
+
| python -m webscout suggestions -k Text | CLI function to perform a suggestions search using Webscout. |
|
|
95
|
+
| python -m webscout text -k Text | CLI function to perform a text search using Webscout. |
|
|
96
|
+
| python -m webscout translate -k Text | CLI function to perform translate using Webscout. |
|
|
97
|
+
| python -m webscout version | A command-line interface command that prints and returns the version of the program. |
|
|
98
|
+
| python -m webscout videos -k Text | CLI function to perform a videos search using DuckDuckGo API. |
|
|
83
99
|
|
|
84
|
-
|
|
85
|
-
python -m webscout.AI yepchat --message "your_message_here"
|
|
86
|
-
```
|
|
100
|
+
## CLI version of webscout.AI
|
|
87
101
|
|
|
88
|
-
```python
|
|
89
|
-
python -m webscout.AI youchat --prompt "your_prompt_here"
|
|
90
|
-
```
|
|
91
102
|
|
|
103
|
+
| Command | Description |
|
|
104
|
+
|--------------------------------------------|--------------------------------------------------------------------------------------------------------|
|
|
105
|
+
| `python -m webscout.AI phindsearch --query "your_query_here"` | CLI function to perform a search query using Webscout.AI's Phindsearch feature. |
|
|
106
|
+
| `python -m webscout.AI yepchat --message "your_message_here"` | CLI function to send a message using Webscout.AI's Yepchat feature. |
|
|
107
|
+
| `python -m webscout.AI youchat --prompt "your_prompt_here"` | CLI function to generate a response based on a prompt using Webscout.AI's Youchat feature. |
|
|
108
|
+
| `python -m webscout.AI gemini --message "tell me about gemma 7b"` | CLI function to get information about a specific topic using Webscout.AI's Gemini feature. |
|
|
109
|
+
| `python -m webscout.AI prodia --prompt "car"` | CLI function to generate content related to a prompt using Webscout.AI's Prodia feature. |
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
## CLI to use LLM
|
|
92
114
|
```python
|
|
93
|
-
python -m
|
|
115
|
+
python -m webscout.LLM model_name
|
|
94
116
|
```
|
|
95
|
-
|
|
96
117
|
[Go To TOP](#TOP)
|
|
97
118
|
|
|
98
119
|
## Regions
|
|
@@ -242,8 +263,7 @@ This ensures proper resource management and cleanup, as the context manager will
|
|
|
242
263
|
Exceptions:
|
|
243
264
|
- `WebscoutE`: Raised when there is a generic exception during the API request.
|
|
244
265
|
|
|
245
|
-
## usage
|
|
246
|
-
Here are the rewritten Python scripts for accessing various functionalities using the WEBS class from the webscout module, in HelpingAI style, for DuckDuckGo.com and Yep.com without explicitly specifying the search engine:
|
|
266
|
+
## usage of webscout
|
|
247
267
|
|
|
248
268
|
### 1. `text()` - text search by DuckDuckGo.com and Yep.com
|
|
249
269
|
|
|
@@ -283,11 +303,10 @@ with WEBS() as WEBS:
|
|
|
283
303
|
region="wt-wt",
|
|
284
304
|
safesearch="off",
|
|
285
305
|
size=None,
|
|
286
|
-
color="Monochrome",
|
|
287
306
|
type_image=None,
|
|
288
307
|
layout=None,
|
|
289
308
|
license_image=None,
|
|
290
|
-
max_results=
|
|
309
|
+
max_results=10,
|
|
291
310
|
)
|
|
292
311
|
for r in WEBS_images_gen:
|
|
293
312
|
print(r)
|
|
@@ -308,7 +327,7 @@ with WEBS() as WEBS:
|
|
|
308
327
|
timelimit="w",
|
|
309
328
|
resolution="high",
|
|
310
329
|
duration="medium",
|
|
311
|
-
max_results=
|
|
330
|
+
max_results=10,
|
|
312
331
|
)
|
|
313
332
|
for r in WEBS_videos_gen:
|
|
314
333
|
print(r)
|
|
@@ -362,15 +381,13 @@ with WEBS() as WEBS:
|
|
|
362
381
|
from webscout import WEBS
|
|
363
382
|
|
|
364
383
|
# Suggestions for the keyword 'fly' using DuckDuckGo.com and Yep
|
|
365
|
-
#
|
|
366
|
-
|
|
367
|
-
.com
|
|
368
384
|
with WEBS() as WEBS:
|
|
369
385
|
for r in WEBS.suggestions("fly"):
|
|
370
386
|
print(r)
|
|
371
387
|
```
|
|
388
|
+
## usage of webscout.AI
|
|
372
389
|
|
|
373
|
-
###
|
|
390
|
+
### 1. `PhindSearch` - Search using Phind.com
|
|
374
391
|
Thanks to Empyros for PhindSearch function
|
|
375
392
|
```python
|
|
376
393
|
from webscout.AI import PhindSearch
|
|
@@ -382,7 +399,7 @@ WEBSAI = PhindSearch(query)
|
|
|
382
399
|
|
|
383
400
|
WEBSAI.search()
|
|
384
401
|
```
|
|
385
|
-
###
|
|
402
|
+
### 2. `YepChat` - Chat with mistral 8x7b powered by yepchat
|
|
386
403
|
Thanks To Divyansh Shukla for This code
|
|
387
404
|
```python
|
|
388
405
|
from webscout.AI import YepChat
|
|
@@ -402,7 +419,7 @@ if __name__ == "__main__":
|
|
|
402
419
|
main()
|
|
403
420
|
```
|
|
404
421
|
|
|
405
|
-
###
|
|
422
|
+
### 3. `You.com` - search with you.com
|
|
406
423
|
```python
|
|
407
424
|
from webscout.AI import youChat
|
|
408
425
|
|
|
@@ -425,7 +442,7 @@ while True:
|
|
|
425
442
|
print("⚠️ An error occurred:", e)
|
|
426
443
|
```
|
|
427
444
|
|
|
428
|
-
###
|
|
445
|
+
### 4. `Gemini` - search with google gemini
|
|
429
446
|
|
|
430
447
|
```python
|
|
431
448
|
from webscout.AI import Gemini
|
|
@@ -439,15 +456,51 @@ response = gemini.chat("Your message here")
|
|
|
439
456
|
# Print the response from the Gemini assistant
|
|
440
457
|
print(response)
|
|
441
458
|
```
|
|
459
|
+
## usage of image generator from Webscout.AI
|
|
460
|
+
### 5. `Prodia` - make image using prodia
|
|
461
|
+
```python
|
|
462
|
+
from webscout.AI import Prodia
|
|
463
|
+
|
|
464
|
+
# Define a prompt for the image generation
|
|
465
|
+
prompt = "A beautiful sunset over the ocean"
|
|
466
|
+
|
|
467
|
+
# Use the prodia_cli method to generate an image based on the prompt
|
|
468
|
+
Prodia.prodia_cli(prompt)
|
|
469
|
+
```
|
|
470
|
+
## usage of special .LLM file from webscout (webscout.LLM)
|
|
471
|
+
|
|
472
|
+
### `LLM`
|
|
473
|
+
```python
|
|
474
|
+
from webscout.LLM import LLM
|
|
475
|
+
|
|
476
|
+
def chat(model_name):
|
|
477
|
+
AI = LLM(model_name)
|
|
478
|
+
AI.chat()
|
|
479
|
+
|
|
480
|
+
if __name__ == "__main__":
|
|
481
|
+
model_name = "mistralai/Mistral-7B-Instruct-v0.1" # name of the model you wish to use It supports ALL text generation models on deepinfra.com.
|
|
482
|
+
chat(model_name)
|
|
483
|
+
```
|
|
442
484
|
|
|
443
485
|
## Version History
|
|
486
|
+
### v1.1.0
|
|
487
|
+
🌟 Added LLMs as webscout.LLM
|
|
488
|
+
🔧 Resolved issue related to Prodia functionality
|
|
489
|
+
|
|
490
|
+
### v1.0.9
|
|
491
|
+
🌌 Added Prodia as an image generator in webscout.AI
|
|
492
|
+
|
|
493
|
+
### v1.0.8
|
|
494
|
+
🚀 Solved issues related to Gemini and Yep Chat functions within the Webscout package.
|
|
495
|
+
🌟 Gemini function now provides correct outputs without duplication.
|
|
496
|
+
🌟 Yep Chat function delivers accurate responses without repeating them multiple times.
|
|
444
497
|
|
|
445
498
|
### v1.0.7
|
|
446
|
-
|
|
499
|
+
🌟 Added Gemini as part of webscout.AI
|
|
447
500
|
|
|
448
501
|
### v1.0.6
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
502
|
+
🌟 Integrated yep.com as a search engine
|
|
503
|
+
🔧 Resolved error associated with the translation feature
|
|
504
|
+
🌟 Introduced Phind AI within webscout.AI
|
|
505
|
+
🌟 Included YepChat as part of webscout.AI
|
|
506
|
+
🌟 Integrated You.com as part of webscout.AI
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
webscout/AI.py,sha256=
|
|
1
|
+
webscout/AI.py,sha256=HUolkJnL_ZPHzp2itGA9lgORLqspjq_79LUPGM-JT70,14030
|
|
2
|
+
webscout/LLM.py,sha256=uyS8BmkFJcWEnfUzOgzcqIw96mF1p-oFqQjJntYn85U,3105
|
|
2
3
|
webscout/__init__.py,sha256=vHJGZexYIaWDTHfMimqA7enct9b7zPDf6jLsS7NDBiA,536
|
|
3
4
|
webscout/__main__.py,sha256=ZtTRgsRjUi2JOvYFLF1ZCh55Sdoz94I-BS-TlJC7WDU,126
|
|
4
5
|
webscout/cli.py,sha256=9opO5KynQ3LA5gPW2czlmy7-ZdfUae6ccrny3vibqzQ,17757
|
|
5
6
|
webscout/exceptions.py,sha256=7u52Mt5iyEUCZvaZuEYwQVV8HL8IdZBv1r5s5Ss_xU0,75
|
|
6
7
|
webscout/models.py,sha256=5iQIdtedT18YuTZ3npoG7kLMwcrKwhQ7928dl_7qZW0,692
|
|
7
8
|
webscout/utils.py,sha256=M2ocDpYOVd9lTZA3VGdK_p80Xsr-VPeAoUUCFaMWCqk,1610
|
|
8
|
-
webscout/version.py,sha256=
|
|
9
|
+
webscout/version.py,sha256=n_RJkcUU1vhYJL1FcReI98Gdzz-G65pYUOJu9K9rJco,25
|
|
9
10
|
webscout/webscout_search.py,sha256=_kuNpRhbgge6MubxlsRe9kzBKlHoPEH6-93ILMpycfg,2351
|
|
10
11
|
webscout/webscout_search_async.py,sha256=lNdR18-y8O9HqFsHvlzBYg18qeI12uLEXIzFMP3D_XU,35070
|
|
11
|
-
webscout-1.0.
|
|
12
|
-
webscout-1.0.
|
|
13
|
-
webscout-1.0.
|
|
14
|
-
webscout-1.0.
|
|
15
|
-
webscout-1.0.
|
|
16
|
-
webscout-1.0.
|
|
12
|
+
webscout-1.1.0.dist-info/LICENSE.md,sha256=mRVwJuT4SXC5O93BFdsfWBjlXjGn2Np90Zm5SocUzM0,3150
|
|
13
|
+
webscout-1.1.0.dist-info/METADATA,sha256=YUGyziqnSd0kqR0yMFGtg7LYbqp8WJZJ5cHPunHKQxw,17493
|
|
14
|
+
webscout-1.1.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
15
|
+
webscout-1.1.0.dist-info/entry_points.txt,sha256=8-93eRslYrzTHs5E-6yFRJrve00C9q-SkXJD113jzRY,197
|
|
16
|
+
webscout-1.1.0.dist-info/top_level.txt,sha256=nYIw7OKBQDr_Z33IzZUKidRD3zQEo8jOJYkMVMeN334,9
|
|
17
|
+
webscout-1.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|