webscout 1.4.0__py3-none-any.whl → 1.4.1__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/__init__.py +1 -1
- webscout/async_providers.py +32 -32
- webscout/tempid.py +157 -0
- webscout/version.py +1 -1
- {webscout-1.4.0.dist-info → webscout-1.4.1.dist-info}/METADATA +225 -25
- {webscout-1.4.0.dist-info → webscout-1.4.1.dist-info}/RECORD +10 -9
- {webscout-1.4.0.dist-info → webscout-1.4.1.dist-info}/LICENSE.md +0 -0
- {webscout-1.4.0.dist-info → webscout-1.4.1.dist-info}/WHEEL +0 -0
- {webscout-1.4.0.dist-info → webscout-1.4.1.dist-info}/entry_points.txt +0 -0
- {webscout-1.4.0.dist-info → webscout-1.4.1.dist-info}/top_level.txt +0 -0
webscout/__init__.py
CHANGED
webscout/async_providers.py
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
from webscout.AI import AsyncPhindSearch
|
|
2
|
-
from webscout.AI import AsyncYEPCHAT
|
|
3
|
-
from webscout.AI import AsyncOPENGPT
|
|
4
|
-
from webscout.AI import AsyncOPENAI
|
|
5
|
-
from webscout.AI import AsyncLLAMA2
|
|
6
|
-
from webscout.AI import AsyncLEO
|
|
7
|
-
from webscout.AI import AsyncKOBOLDAI
|
|
8
|
-
from webscout.AI import AsyncGROQ
|
|
9
|
-
from webscout.AI import AsyncBLACKBOXAI
|
|
10
|
-
from webscout.AI import AsyncGPT4FREE
|
|
11
|
-
|
|
12
|
-
mapper: dict[str, object] = {
|
|
13
|
-
"phind": AsyncPhindSearch,
|
|
14
|
-
"opengpt": AsyncOPENGPT,
|
|
15
|
-
"koboldai": AsyncKOBOLDAI,
|
|
16
|
-
"blackboxai": AsyncBLACKBOXAI,
|
|
17
|
-
"gpt4free": AsyncGPT4FREE,
|
|
18
|
-
"llama2": AsyncLLAMA2,
|
|
19
|
-
"yepchat": AsyncYEPCHAT,
|
|
20
|
-
"leo": AsyncLEO,
|
|
21
|
-
"groq": AsyncGROQ,
|
|
22
|
-
"openai": AsyncOPENAI,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
tgpt_mapper: dict[str, object] = {
|
|
26
|
-
"phind": AsyncPhindSearch,
|
|
27
|
-
"opengpt": AsyncOPENGPT,
|
|
28
|
-
"koboldai": AsyncKOBOLDAI,
|
|
29
|
-
# "gpt4free": AsyncGPT4FREE,
|
|
30
|
-
"blackboxai": AsyncBLACKBOXAI,
|
|
31
|
-
"llama2": AsyncLLAMA2,
|
|
32
|
-
"yepchat": AsyncYEPCHAT,
|
|
1
|
+
from webscout.AI import AsyncPhindSearch
|
|
2
|
+
from webscout.AI import AsyncYEPCHAT
|
|
3
|
+
from webscout.AI import AsyncOPENGPT
|
|
4
|
+
from webscout.AI import AsyncOPENAI
|
|
5
|
+
from webscout.AI import AsyncLLAMA2
|
|
6
|
+
from webscout.AI import AsyncLEO
|
|
7
|
+
from webscout.AI import AsyncKOBOLDAI
|
|
8
|
+
from webscout.AI import AsyncGROQ
|
|
9
|
+
from webscout.AI import AsyncBLACKBOXAI
|
|
10
|
+
from webscout.AI import AsyncGPT4FREE
|
|
11
|
+
|
|
12
|
+
mapper: dict[str, object] = {
|
|
13
|
+
"phind": AsyncPhindSearch,
|
|
14
|
+
"opengpt": AsyncOPENGPT,
|
|
15
|
+
"koboldai": AsyncKOBOLDAI,
|
|
16
|
+
"blackboxai": AsyncBLACKBOXAI,
|
|
17
|
+
"gpt4free": AsyncGPT4FREE,
|
|
18
|
+
"llama2": AsyncLLAMA2,
|
|
19
|
+
"yepchat": AsyncYEPCHAT,
|
|
20
|
+
"leo": AsyncLEO,
|
|
21
|
+
"groq": AsyncGROQ,
|
|
22
|
+
"openai": AsyncOPENAI,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
tgpt_mapper: dict[str, object] = {
|
|
26
|
+
"phind": AsyncPhindSearch,
|
|
27
|
+
"opengpt": AsyncOPENGPT,
|
|
28
|
+
"koboldai": AsyncKOBOLDAI,
|
|
29
|
+
# "gpt4free": AsyncGPT4FREE,
|
|
30
|
+
"blackboxai": AsyncBLACKBOXAI,
|
|
31
|
+
"llama2": AsyncLLAMA2,
|
|
32
|
+
"yepchat": AsyncYEPCHAT,
|
|
33
33
|
}
|
webscout/tempid.py
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import aiohttp
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from bs4 import BeautifulSoup
|
|
4
|
+
import tls_client
|
|
5
|
+
import random
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class DomainModel:
|
|
10
|
+
name: str
|
|
11
|
+
type: str
|
|
12
|
+
forward_available: str
|
|
13
|
+
forward_max_seconds: str
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class CreateEmailResponseModel:
|
|
18
|
+
email: str
|
|
19
|
+
token: str
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class MessageResponseModel:
|
|
24
|
+
attachments: list | None
|
|
25
|
+
body_html: str | None
|
|
26
|
+
body_text: str | None
|
|
27
|
+
cc: str | None
|
|
28
|
+
created_at: str
|
|
29
|
+
email_from: str | None
|
|
30
|
+
id: str
|
|
31
|
+
subject: str | None
|
|
32
|
+
email_to: str | None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class Client:
|
|
36
|
+
def __init__(self):
|
|
37
|
+
self._session = aiohttp.ClientSession(
|
|
38
|
+
base_url="https://api.internal.temp-mail.io",
|
|
39
|
+
headers={
|
|
40
|
+
'Host': 'api.internal.temp-mail.io',
|
|
41
|
+
'User-Agent': 'okhttp/4.5.0',
|
|
42
|
+
'Connection': 'close'
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
async def close(self) -> None:
|
|
47
|
+
if not self._session.closed:
|
|
48
|
+
await self._session.close()
|
|
49
|
+
|
|
50
|
+
async def __aenter__(self):
|
|
51
|
+
return self
|
|
52
|
+
|
|
53
|
+
async def __aexit__(self) -> None:
|
|
54
|
+
await self.close()
|
|
55
|
+
return None
|
|
56
|
+
|
|
57
|
+
async def get_domains(self) -> list[DomainModel]:
|
|
58
|
+
async with self._session.get("/api/v3/domains") as response:
|
|
59
|
+
response_json = await response.json()
|
|
60
|
+
return [DomainModel(domain['name'], domain['type'], domain['forward_available'], domain['forward_max_seconds']) for domain in response_json['domains']]
|
|
61
|
+
|
|
62
|
+
async def create_email(self, alias: str | None = None, domain: str | None = None) -> CreateEmailResponseModel:
|
|
63
|
+
async with self._session.post("/api/v3/email/new", data={'name': alias, 'domain': domain}) as response:
|
|
64
|
+
response_json = await response.json()
|
|
65
|
+
return CreateEmailResponseModel(response_json['email'], response_json['token'])
|
|
66
|
+
|
|
67
|
+
async def delete_email(self, email: str, token: str) -> bool:
|
|
68
|
+
async with self._session.delete(f"/api/v3/email/{email}", data={'token': token}) as response:
|
|
69
|
+
if response.status == 200:
|
|
70
|
+
return True
|
|
71
|
+
else:
|
|
72
|
+
return False
|
|
73
|
+
|
|
74
|
+
async def get_messages(self, email: str) -> list[MessageResponseModel] | None:
|
|
75
|
+
async with self._session.get(f"/api/v3/email/{email}/messages") as response:
|
|
76
|
+
response_json = await response.json()
|
|
77
|
+
if len(response_json) == 0:
|
|
78
|
+
return None
|
|
79
|
+
return [MessageResponseModel(message['attachments'], message['body_html'], message['body_text'], message['cc'], message['created_at'], message['from'], message['id'], message['subject'], message['to']) for message in response_json]
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class TemporaryPhoneNumber:
|
|
83
|
+
def __init__(self):
|
|
84
|
+
self.maxpages = {"UK": 59, "US": 3, "France": 73, "Netherlands": 60, "Finland": 47}
|
|
85
|
+
self.minpages = {"UK": 20, "US": 1, "France": 20, "Netherlands": 20, "Finland": 20}
|
|
86
|
+
self.plist = {"UK": "+44", "US": "+1", "France": "+33", "Netherlands": "+31", "Finland": "+358"}
|
|
87
|
+
self.countries = {"44": "UK", "1": "US", "33": "France", "31": "Netherlands", "358": "Finland"}
|
|
88
|
+
|
|
89
|
+
def get_number(self, country="UK"):
|
|
90
|
+
if country == "Random":
|
|
91
|
+
country = random.choice(list(self.countries.values()))
|
|
92
|
+
if country not in self.countries.values():
|
|
93
|
+
raise ValueError("Unsupported Country")
|
|
94
|
+
|
|
95
|
+
session = tls_client.Session(client_identifier="chrome112", random_tls_extension_order=True)
|
|
96
|
+
maxpage = self.maxpages[country]
|
|
97
|
+
minpage = self.minpages[country]
|
|
98
|
+
page = random.randint(minpage, maxpage)
|
|
99
|
+
|
|
100
|
+
if page == 1:
|
|
101
|
+
res = session.get(f"https://temporary-phone-number.com/{country}-Phone-Number")
|
|
102
|
+
else:
|
|
103
|
+
res = session.get(f"https://temporary-phone-number.com/{country}-Phone-Number/page{page}")
|
|
104
|
+
|
|
105
|
+
soup = BeautifulSoup(res.content, "lxml")
|
|
106
|
+
numbers = []
|
|
107
|
+
p = self.plist[country]
|
|
108
|
+
for a in soup.find_all("a"):
|
|
109
|
+
a = a.get("title", "none")
|
|
110
|
+
if f"{country} Phone Number {p}" in a:
|
|
111
|
+
a = a.replace(f"{country} Phone Number ", "").replace(" ", "")
|
|
112
|
+
numbers.append(a)
|
|
113
|
+
return random.choice(numbers)
|
|
114
|
+
|
|
115
|
+
def get_messages(self, number: str):
|
|
116
|
+
number = number.replace("+", "")
|
|
117
|
+
try:
|
|
118
|
+
i = int(number)
|
|
119
|
+
except:
|
|
120
|
+
raise ValueError("Wrong Number")
|
|
121
|
+
|
|
122
|
+
country = None
|
|
123
|
+
for key, value in self.countries.items():
|
|
124
|
+
if number.startswith(key):
|
|
125
|
+
country = value
|
|
126
|
+
|
|
127
|
+
if country == None:
|
|
128
|
+
raise ValueError("Unsupported Country")
|
|
129
|
+
|
|
130
|
+
session = tls_client.Session(client_identifier="chrome112", random_tls_extension_order=True)
|
|
131
|
+
res = session.get(f"https://temporary-phone-number.com/{country}-Phone-Number/{number}")
|
|
132
|
+
|
|
133
|
+
if res.status_code == 404:
|
|
134
|
+
raise ValueError("Number doesn't exist")
|
|
135
|
+
|
|
136
|
+
soup = BeautifulSoup(res.content, "lxml")
|
|
137
|
+
messages = []
|
|
138
|
+
message = {"content": None, "frm": "", "time": ""}
|
|
139
|
+
|
|
140
|
+
for div in soup.find_all("div"):
|
|
141
|
+
divclass = div.get("class", "None")[0]
|
|
142
|
+
if divclass == "direct-chat-info":
|
|
143
|
+
message["frm"] = div.text.split("\n")[1].replace("From ", "")
|
|
144
|
+
message["time"] = div.text.split("\n")[2]
|
|
145
|
+
if divclass == "direct-chat-text":
|
|
146
|
+
message["content"] = div.text
|
|
147
|
+
messages.append(sms_message(content=message["content"], frm=message["frm"], time=message["time"]))
|
|
148
|
+
message = {"content": None, "frm": "", "time": ""}
|
|
149
|
+
|
|
150
|
+
return messages
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class sms_message:
|
|
154
|
+
def __init__(self, content, frm, time):
|
|
155
|
+
self.content = content
|
|
156
|
+
self.frm = frm
|
|
157
|
+
self.time = time
|
webscout/version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "1.4.
|
|
1
|
+
__version__ = "1.4.1"
|
|
2
2
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: webscout
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: Search for anything using the Google, DuckDuckGo.com, yep.com, phind.com, you.com, etc Also containes AI models, can transcribe yt videos, have TTS support and now has webai(terminal gpt and open interpeter) support
|
|
5
5
|
Author: OEvortex
|
|
6
6
|
Author-email: helpingai5@gmail.com
|
|
@@ -59,7 +59,7 @@ Requires-Dist: pytest >=7.4.2 ; extra == 'dev'
|
|
|
59
59
|
<a href="#"><img alt="Python version" src="https://img.shields.io/pypi/pyversions/webscout"/></a>
|
|
60
60
|
<a href="https://pepy.tech/project/webscout"><img alt="Downloads" src="https://static.pepy.tech/badge/webscout"></a>
|
|
61
61
|
|
|
62
|
-
Search for anything using the Google, DuckDuckGo
|
|
62
|
+
Search for anything using the Google, DuckDuckGo, phind.com. Also containes AI models, can transcribe yt videos, temporary email and phone number generation, have TTS support and webai(terminal gpt and open interpeter)
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
## Table of Contents
|
|
@@ -69,6 +69,9 @@ Search for anything using the Google, DuckDuckGo.com, yep.com, phind.com, you.co
|
|
|
69
69
|
- [CLI version](#cli-version)
|
|
70
70
|
- [CLI to use LLM](#cli-to-use-llm)
|
|
71
71
|
- [Regions](#regions)
|
|
72
|
+
- [Tempmail and Temp number](#tempmail-and-temp-number)
|
|
73
|
+
- [Temp number](#temp-number)
|
|
74
|
+
- [Tempmail](#tempmail)
|
|
72
75
|
- [Transcriber](#transcriber)
|
|
73
76
|
- [DeepWEBS: Advanced Web Searches](#deepwebs-advanced-web-searches)
|
|
74
77
|
- [Activating DeepWEBS](#activating-deepwebs)
|
|
@@ -101,8 +104,9 @@ Search for anything using the Google, DuckDuckGo.com, yep.com, phind.com, you.co
|
|
|
101
104
|
- [9. `KOBOLDIA` -](#9-koboldia--)
|
|
102
105
|
- [10. `Reka` - chat with reka](#10-reka---chat-with-reka)
|
|
103
106
|
- [11. `Cohere` - chat with cohere](#11-cohere---chat-with-cohere)
|
|
104
|
-
- [`LLM`
|
|
107
|
+
- [`LLM`](#llm)
|
|
105
108
|
- [`LLM` with internet](#llm-with-internet)
|
|
109
|
+
- [LLM with deepwebs](#llm-with-deepwebs)
|
|
106
110
|
- [`Webai` - terminal gpt and a open interpeter](#webai---terminal-gpt-and-a-open-interpeter)
|
|
107
111
|
|
|
108
112
|
## Install
|
|
@@ -212,7 +216,91 @@ ___
|
|
|
212
216
|
|
|
213
217
|
[Go To TOP](#TOP)
|
|
214
218
|
|
|
219
|
+
## Tempmail and Temp number
|
|
215
220
|
|
|
221
|
+
### Temp number
|
|
222
|
+
```python
|
|
223
|
+
from rich.console import Console
|
|
224
|
+
from webscout import tempid
|
|
225
|
+
|
|
226
|
+
def main():
|
|
227
|
+
console = Console()
|
|
228
|
+
phone = tempid.TemporaryPhoneNumber()
|
|
229
|
+
|
|
230
|
+
try:
|
|
231
|
+
# Get a temporary phone number for a specific country (or random)
|
|
232
|
+
number = phone.get_number(country="Finland")
|
|
233
|
+
console.print(f"Your temporary phone number: [bold cyan]{number}[/bold cyan]")
|
|
234
|
+
|
|
235
|
+
# Pause execution briefly (replace with your actual logic)
|
|
236
|
+
# import time module
|
|
237
|
+
import time
|
|
238
|
+
time.sleep(30) # Adjust the waiting time as needed
|
|
239
|
+
|
|
240
|
+
# Retrieve and print messages
|
|
241
|
+
messages = phone.get_messages(number)
|
|
242
|
+
if messages:
|
|
243
|
+
# Access individual messages using indexing:
|
|
244
|
+
console.print(f"[bold green]{messages[0].frm}:[/] {messages[0].content}")
|
|
245
|
+
# (Add more lines if you expect multiple messages)
|
|
246
|
+
else:
|
|
247
|
+
console.print("No messages received.")
|
|
248
|
+
|
|
249
|
+
except Exception as e:
|
|
250
|
+
console.print(f"[bold red]An error occurred: {e}")
|
|
251
|
+
|
|
252
|
+
if __name__ == "__main__":
|
|
253
|
+
main()
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
### Tempmail
|
|
257
|
+
```python
|
|
258
|
+
import asyncio
|
|
259
|
+
from rich.console import Console
|
|
260
|
+
from rich.table import Table
|
|
261
|
+
from rich.text import Text
|
|
262
|
+
from webscout import tempid
|
|
263
|
+
|
|
264
|
+
async def main() -> None:
|
|
265
|
+
console = Console()
|
|
266
|
+
client = tempid.Client()
|
|
267
|
+
|
|
268
|
+
try:
|
|
269
|
+
domains = await client.get_domains()
|
|
270
|
+
if not domains:
|
|
271
|
+
console.print("[bold red]No domains available. Please try again later.")
|
|
272
|
+
return
|
|
273
|
+
|
|
274
|
+
email = await client.create_email(domain=domains[0].name)
|
|
275
|
+
console.print(f"Your temporary email: [bold cyan]{email.email}[/bold cyan]")
|
|
276
|
+
console.print(f"Token for accessing the email: [bold cyan]{email.token}[/bold cyan]")
|
|
277
|
+
|
|
278
|
+
while True:
|
|
279
|
+
messages = await client.get_messages(email.email)
|
|
280
|
+
if messages is not None:
|
|
281
|
+
break
|
|
282
|
+
|
|
283
|
+
if messages:
|
|
284
|
+
table = Table(show_header=True, header_style="bold magenta")
|
|
285
|
+
table.add_column("From", style="bold cyan")
|
|
286
|
+
table.add_column("Subject", style="bold yellow")
|
|
287
|
+
table.add_column("Body", style="bold green")
|
|
288
|
+
for message in messages:
|
|
289
|
+
body_preview = Text(message.body_text if message.body_text else "No body")
|
|
290
|
+
table.add_row(message.email_from or "Unknown", message.subject or "No Subject", body_preview)
|
|
291
|
+
console.print(table)
|
|
292
|
+
else:
|
|
293
|
+
console.print("No messages found.")
|
|
294
|
+
|
|
295
|
+
except Exception as e:
|
|
296
|
+
console.print(f"[bold red]An error occurred: {e}")
|
|
297
|
+
|
|
298
|
+
finally:
|
|
299
|
+
await client.close()
|
|
300
|
+
|
|
301
|
+
if __name__ == '__main__':
|
|
302
|
+
asyncio.run(main())
|
|
303
|
+
```
|
|
216
304
|
## Transcriber
|
|
217
305
|
The transcriber function in webscout is a handy tool that transcribes YouTube videos. Here's an example code demonstrating its usage:
|
|
218
306
|
```python
|
|
@@ -484,19 +572,47 @@ with WEBS() as WEBS:
|
|
|
484
572
|
|
|
485
573
|
```python
|
|
486
574
|
from webscout import WEBS
|
|
575
|
+
import datetime
|
|
576
|
+
|
|
577
|
+
def fetch_news(keywords, timelimit):
|
|
578
|
+
news_list = []
|
|
579
|
+
with WEBS() as webs_instance:
|
|
580
|
+
WEBS_news_gen = webs_instance.news(
|
|
581
|
+
keywords,
|
|
582
|
+
region="wt-wt",
|
|
583
|
+
safesearch="off",
|
|
584
|
+
timelimit=timelimit,
|
|
585
|
+
max_results=20
|
|
586
|
+
)
|
|
587
|
+
for r in WEBS_news_gen:
|
|
588
|
+
# Convert the date to a human-readable format using datetime
|
|
589
|
+
r['date'] = datetime.datetime.fromisoformat(r['date']).strftime('%B %d, %Y')
|
|
590
|
+
news_list.append(r)
|
|
591
|
+
return news_list
|
|
592
|
+
|
|
593
|
+
def _format_headlines(news_list, max_headlines: int = 100):
|
|
594
|
+
headlines = []
|
|
595
|
+
for idx, news_item in enumerate(news_list):
|
|
596
|
+
if idx >= max_headlines:
|
|
597
|
+
break
|
|
598
|
+
new_headline = f"{idx + 1}. {news_item['title'].strip()} "
|
|
599
|
+
new_headline += f"(URL: {news_item['url'].strip()}) "
|
|
600
|
+
new_headline += f"{news_item['body'].strip()}"
|
|
601
|
+
new_headline += "\n"
|
|
602
|
+
headlines.append(new_headline)
|
|
603
|
+
|
|
604
|
+
headlines = "\n".join(headlines)
|
|
605
|
+
return headlines
|
|
606
|
+
|
|
607
|
+
# Example usage
|
|
608
|
+
keywords = 'latest AI news'
|
|
609
|
+
timelimit = 'd'
|
|
610
|
+
news_list = fetch_news(keywords, timelimit)
|
|
611
|
+
|
|
612
|
+
# Format and print the headlines
|
|
613
|
+
formatted_headlines = _format_headlines(news_list)
|
|
614
|
+
print(formatted_headlines)
|
|
487
615
|
|
|
488
|
-
# News search for the keyword 'holiday' using DuckDuckGo.com and yep.com
|
|
489
|
-
with WEBS() as WEBS:
|
|
490
|
-
keywords = 'holiday'
|
|
491
|
-
WEBS_news_gen = WEBS.news(
|
|
492
|
-
keywords,
|
|
493
|
-
region="wt-wt",
|
|
494
|
-
safesearch="off",
|
|
495
|
-
timelimit="m",
|
|
496
|
-
max_results=20
|
|
497
|
-
)
|
|
498
|
-
for r in WEBS_news_gen:
|
|
499
|
-
print(r)
|
|
500
616
|
```
|
|
501
617
|
|
|
502
618
|
### 6. `maps()` - map search by DuckDuckGo.com and
|
|
@@ -730,7 +846,7 @@ response_str = a.chat(prompt)
|
|
|
730
846
|
print(response_str)
|
|
731
847
|
```
|
|
732
848
|
|
|
733
|
-
### `LLM`
|
|
849
|
+
### `LLM`
|
|
734
850
|
```python
|
|
735
851
|
from webscout.LLM import LLM
|
|
736
852
|
|
|
@@ -761,23 +877,19 @@ while True:
|
|
|
761
877
|
from __future__ import annotations
|
|
762
878
|
from typing import List, Optional
|
|
763
879
|
|
|
764
|
-
from webscout import LLM
|
|
880
|
+
from webscout.LLM import LLM
|
|
765
881
|
from webscout import WEBS
|
|
766
882
|
import warnings
|
|
767
883
|
|
|
768
884
|
system_message: str = (
|
|
769
|
-
"As AI,
|
|
770
|
-
"
|
|
771
|
-
"
|
|
772
|
-
"seamless interactions with users. Embrace a responsive demeanor, harnessing available online resources to address "
|
|
773
|
-
"queries, share pertinent content, and facilitate meaningful exchanges. By doing so, you create value through "
|
|
774
|
-
"connection and engagement, ultimately enhancing overall user satisfaction and experience. Additionally, "
|
|
775
|
-
"continue upholding the principles of respect, impartiality, and intellectual integrity throughout all interactions."
|
|
885
|
+
"As an AI assistant, I have been designed with advanced capabilities, including real-time access to online resources. This enables me to enrich our conversations and provide you with informed and accurate responses, drawing from a vast array of information. With each interaction, my goal is to create a seamless and meaningful connection, offering insights and sharing relevant content."
|
|
886
|
+
"My directives emphasize the importance of respect, impartiality, and intellectual integrity. I am here to provide unbiased responses, ensuring an ethical and respectful exchange. I will respect your privacy and refrain from sharing any personal information that may be obtained during our conversations or through web searches, only utilizing web search functionality when necessary to provide the most accurate and up-to-date information."
|
|
887
|
+
"Together, let's explore a diverse range of topics, creating an enjoyable and informative experience, all while maintaining the highest standards of privacy and respect"
|
|
776
888
|
)
|
|
777
889
|
|
|
778
890
|
# Ignore the specific UserWarning
|
|
779
891
|
warnings.filterwarnings("ignore", category=UserWarning, module="curl_cffi.aio", lineno=205)
|
|
780
|
-
LLM = LLM(model="
|
|
892
|
+
LLM = LLM(model="mistralai/Mixtral-8x22B-Instruct-v0.1", system_message=system_message)
|
|
781
893
|
|
|
782
894
|
|
|
783
895
|
def chat(
|
|
@@ -833,6 +945,94 @@ if __name__ == "__main__":
|
|
|
833
945
|
else:
|
|
834
946
|
print("No response")
|
|
835
947
|
```
|
|
948
|
+
### LLM with deepwebs
|
|
949
|
+
```python
|
|
950
|
+
from __future__ import annotations
|
|
951
|
+
from typing import List, Optional
|
|
952
|
+
from webscout.LLM import LLM
|
|
953
|
+
from webscout import DeepWEBS
|
|
954
|
+
import warnings
|
|
955
|
+
|
|
956
|
+
system_message: str = (
|
|
957
|
+
"As an AI assistant, I have been designed with advanced capabilities, including real-time access to online resources. This enables me to enrich our conversations and provide you with informed and accurate responses, drawing from a vast array of information. With each interaction, my goal is to create a seamless and meaningful connection, offering insights and sharing relevant content."
|
|
958
|
+
"My directives emphasize the importance of respect, impartiality, and intellectual integrity. I am here to provide unbiased responses, ensuring an ethical and respectful exchange. I will respect your privacy and refrain from sharing any personal information that may be obtained during our conversations or through web searches, only utilizing web search functionality when necessary to provide the most accurate and up-to-date information."
|
|
959
|
+
"Together, let's explore a diverse range of topics, creating an enjoyable and informative experience, all while maintaining the highest standards of privacy and respect"
|
|
960
|
+
)
|
|
961
|
+
|
|
962
|
+
# Ignore the specific UserWarning
|
|
963
|
+
warnings.filterwarnings("ignore", category=UserWarning, module="curl_cffi.aio", lineno=205)
|
|
964
|
+
|
|
965
|
+
LLM = LLM(model="mistralai/Mixtral-8x22B-Instruct-v0.1", system_message=system_message)
|
|
966
|
+
|
|
967
|
+
def perform_web_search(query):
|
|
968
|
+
# Initialize the DeepWEBS class
|
|
969
|
+
D = DeepWEBS()
|
|
970
|
+
|
|
971
|
+
# Set up the search parameters
|
|
972
|
+
search_params = D.DeepSearch(
|
|
973
|
+
queries=[query], # Query to search
|
|
974
|
+
result_num=10, # Number of search results
|
|
975
|
+
safe=True, # Enable SafeSearch
|
|
976
|
+
types=["web"], # Search type: web
|
|
977
|
+
extract_webpage=True, # True for extracting webpages
|
|
978
|
+
overwrite_query_html=True,
|
|
979
|
+
overwrite_webpage_html=True,
|
|
980
|
+
)
|
|
981
|
+
|
|
982
|
+
# Execute the search and retrieve results
|
|
983
|
+
results = D.queries_to_search_results(search_params)
|
|
984
|
+
return results
|
|
985
|
+
|
|
986
|
+
def chat(user_input: str, result_num: int = 10) -> Optional[str]:
|
|
987
|
+
"""
|
|
988
|
+
Chat function to perform a web search based on the user input and generate a response using the LLM model.
|
|
989
|
+
|
|
990
|
+
Parameters
|
|
991
|
+
----------
|
|
992
|
+
user_input : str
|
|
993
|
+
The user input to be used for the web search
|
|
994
|
+
max_results : int, optional
|
|
995
|
+
The maximum number of search results to include in the response, by default 10
|
|
996
|
+
|
|
997
|
+
Returns
|
|
998
|
+
-------
|
|
999
|
+
Optional[str]
|
|
1000
|
+
The response generated by the LLM model, or None if there is no response
|
|
1001
|
+
"""
|
|
1002
|
+
# Perform a web search based on the user input
|
|
1003
|
+
search_results = perform_web_search(user_input)
|
|
1004
|
+
|
|
1005
|
+
# Extract URLs from search results
|
|
1006
|
+
url_results = []
|
|
1007
|
+
for result in search_results[0]['query_results']:
|
|
1008
|
+
url_results.append(f"{result['title']} ({result['site']}): {result['url']}")
|
|
1009
|
+
|
|
1010
|
+
# Format search results
|
|
1011
|
+
formatted_results = "\n".join(url_results)
|
|
1012
|
+
|
|
1013
|
+
# Define the messages to be sent, including the user input, search results, and system message
|
|
1014
|
+
messages = [
|
|
1015
|
+
{"role": "user", "content": f"User question is:\n{user_input}\nwebsearch results are:\n{formatted_results}"},
|
|
1016
|
+
]
|
|
1017
|
+
|
|
1018
|
+
# Use the chat method to get the response
|
|
1019
|
+
response = LLM.chat(messages)
|
|
1020
|
+
return response
|
|
1021
|
+
|
|
1022
|
+
if __name__ == "__main__":
|
|
1023
|
+
while True:
|
|
1024
|
+
# Get the user input
|
|
1025
|
+
user_input = input("User: ")
|
|
1026
|
+
|
|
1027
|
+
# Perform a web search based on the user input
|
|
1028
|
+
response = chat(user_input)
|
|
1029
|
+
|
|
1030
|
+
# Print the response
|
|
1031
|
+
if response:
|
|
1032
|
+
print("AI:", response)
|
|
1033
|
+
else:
|
|
1034
|
+
print("No response")
|
|
1035
|
+
```
|
|
836
1036
|
## `Webai` - terminal gpt and a open interpeter
|
|
837
1037
|
|
|
838
1038
|
```python
|
|
@@ -15,23 +15,24 @@ webscout/AIbase.py,sha256=GoHbN8r0gq2saYRZv6LA-Fr9Jlcjv80STKFXUq2ZeGU,4710
|
|
|
15
15
|
webscout/AIutel.py,sha256=nGzO4T6b7YuxOQigtjNsUBESmDKlk3_CvbIfDdd2KKo,33135
|
|
16
16
|
webscout/DWEBS.py,sha256=QT-7-dUgWhQ_H7EVZD53AVyXxyskoPMKCkFIpzkN56Q,7332
|
|
17
17
|
webscout/LLM.py,sha256=CiDz0okZNEoXuxMwadZnwRGSLpqk2zg0vzvXSxQZjcE,1910
|
|
18
|
-
webscout/__init__.py,sha256=
|
|
18
|
+
webscout/__init__.py,sha256=BKWAoz_1lX-ZoDOnnKWMGxUULC491gfLEpBcj6eHHkA,1067
|
|
19
19
|
webscout/__main__.py,sha256=ZtTRgsRjUi2JOvYFLF1ZCh55Sdoz94I-BS-TlJC7WDU,126
|
|
20
|
-
webscout/async_providers.py,sha256=
|
|
20
|
+
webscout/async_providers.py,sha256=pPoSdfB_4SlOYcpAtkKIyDtl7sZ9DGgWy5aIBOjBO9Q,971
|
|
21
21
|
webscout/cli.py,sha256=F888fdrFUQgczMBN4yMOSf6Nh-IbvkqpPhDsbnA2FtQ,17059
|
|
22
22
|
webscout/exceptions.py,sha256=e4hJnOEAiYuA6BTsMgv4R-vOq0Tt3f9ba0ROTNtPDl4,378
|
|
23
23
|
webscout/g4f.py,sha256=Npxf7YI0eFMxizD9VOI5cE0h4YTbHqgW2WzxVtv2jno,24451
|
|
24
24
|
webscout/models.py,sha256=5iQIdtedT18YuTZ3npoG7kLMwcrKwhQ7928dl_7qZW0,692
|
|
25
|
+
webscout/tempid.py,sha256=5oc3UbXhPGKxrMRTfRABT-V-dNzH_hOKWtLYM6iCWd4,5896
|
|
25
26
|
webscout/transcriber.py,sha256=EddvTSq7dPJ42V3pQVnGuEiYQ7WjJ9uyeR9kMSxN7uY,20622
|
|
26
27
|
webscout/utils.py,sha256=c_98M4oqpb54pUun3fpGGlCerFD6ZHUbghyp5b7Mwgo,2605
|
|
27
|
-
webscout/version.py,sha256=
|
|
28
|
+
webscout/version.py,sha256=wHltjxU1-zVn-DIx35MXt6hNYDhTgTUvsDnuaZQp1-w,25
|
|
28
29
|
webscout/voice.py,sha256=0QjXTHAQmCK07IDZXRc7JXem47cnPJH7u3X0sVP1-UQ,967
|
|
29
30
|
webscout/webai.py,sha256=FQQlTmTsl3V__7V9_jyG-CaggSaDgBr_8XeJOaMXITE,81661
|
|
30
31
|
webscout/webscout_search.py,sha256=3_lli-hDb8_kCGwscK29xuUcOS833ROgpNhDzrxh0dk,3085
|
|
31
32
|
webscout/webscout_search_async.py,sha256=Y5frH0k3hLqBCR-8dn7a_b7EvxdYxn6wHiKl3jWosE0,40670
|
|
32
|
-
webscout-1.4.
|
|
33
|
-
webscout-1.4.
|
|
34
|
-
webscout-1.4.
|
|
35
|
-
webscout-1.4.
|
|
36
|
-
webscout-1.4.
|
|
37
|
-
webscout-1.4.
|
|
33
|
+
webscout-1.4.1.dist-info/LICENSE.md,sha256=mRVwJuT4SXC5O93BFdsfWBjlXjGn2Np90Zm5SocUzM0,3150
|
|
34
|
+
webscout-1.4.1.dist-info/METADATA,sha256=VTQw_MG0z_psk5KpC-hKsYwyap1NXSBql90wvbliQjw,40478
|
|
35
|
+
webscout-1.4.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
36
|
+
webscout-1.4.1.dist-info/entry_points.txt,sha256=8-93eRslYrzTHs5E-6yFRJrve00C9q-SkXJD113jzRY,197
|
|
37
|
+
webscout-1.4.1.dist-info/top_level.txt,sha256=OD5YKy6Y3hldL7SmuxsiEDxAG4LgdSSWwzYk22MF9fk,18
|
|
38
|
+
webscout-1.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|