webscout 3.3__py3-none-any.whl → 3.5__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/AIutel.py +1 -0
- webscout/DWEBS.py +772 -176
- webscout/Local/_version.py +1 -1
- webscout/Provider/Deepinfra.py +479 -0
- webscout/Provider/__init__.py +5 -0
- webscout/__init__.py +4 -2
- webscout/cli.py +17 -15
- webscout/exceptions.py +1 -1
- webscout/version.py +1 -1
- webscout/webai.py +15 -0
- webscout/webscout_search.py +48 -39
- webscout/webscout_search_async.py +11 -10
- webscout/websx_search.py +370 -0
- {webscout-3.3.dist-info → webscout-3.5.dist-info}/METADATA +149 -217
- {webscout-3.3.dist-info → webscout-3.5.dist-info}/RECORD +19 -29
- {webscout-3.3.dist-info → webscout-3.5.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.3.dist-info → webscout-3.5.dist-info}/LICENSE.md +0 -0
- {webscout-3.3.dist-info → webscout-3.5.dist-info}/WHEEL +0 -0
- {webscout-3.3.dist-info → webscout-3.5.dist-info}/entry_points.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: webscout
|
|
3
|
-
Version: 3.
|
|
4
|
-
Summary: Search for anything using Google, DuckDuckGo, phind.com, Contains AI models, can transcribe yt videos, temporary email and phone number generation, has TTS support, webai (terminal gpt and open interpreter) and offline LLMs
|
|
3
|
+
Version: 3.5
|
|
4
|
+
Summary: Search for anything using Google, DuckDuckGo, brave, qwant, phind.com, Contains AI models, can transcribe yt videos, temporary email and phone number generation, has TTS support, webai (terminal gpt and open interpreter) and offline LLMs
|
|
5
5
|
Author: OEvortex
|
|
6
6
|
Author-email: helpingai5@gmail.com
|
|
7
7
|
License: HelpingAI
|
|
@@ -104,14 +104,14 @@ Search for anything using Google, DuckDuckGo, phind.com, Contains AI models, can
|
|
|
104
104
|
- [Temp number](#temp-number)
|
|
105
105
|
- [Tempmail](#tempmail)
|
|
106
106
|
- [Transcriber](#transcriber)
|
|
107
|
-
- [
|
|
108
|
-
- [Activating
|
|
109
|
-
- [Point to remember before using `
|
|
107
|
+
- [DWEBS: Advanced Web Searches](#dwebs-advanced-web-searches)
|
|
108
|
+
- [Activating DWEBS](#activating-dwebs)
|
|
109
|
+
- [Point to remember before using `DWEBS`](#point-to-remember-before-using-dwebs)
|
|
110
110
|
- [Usage Example](#usage-example)
|
|
111
111
|
- [Text-to-Speech:](#text-to-speech)
|
|
112
112
|
- [Available TTS Voices:](#available-tts-voices)
|
|
113
113
|
- [Exceptions](#exceptions)
|
|
114
|
-
- [usage of
|
|
114
|
+
- [usage of WEBS](#usage-of-webs)
|
|
115
115
|
- [1. `text()` - text search by DuckDuckGo.com](#1-text---text-search-by-duckduckgocom)
|
|
116
116
|
- [2. `answers()` - instant answers by DuckDuckGo.com](#2-answers---instant-answers-by-duckduckgocom)
|
|
117
117
|
- [3. `images()` - image search by DuckDuckGo.com](#3-images---image-search-by-duckduckgocom)
|
|
@@ -120,6 +120,7 @@ Search for anything using Google, DuckDuckGo, phind.com, Contains AI models, can
|
|
|
120
120
|
- [6. `maps()` - map search by DuckDuckGo.com](#6-maps---map-search-by-duckduckgocom)
|
|
121
121
|
- [7. `translate()` - translation by DuckDuckGo.com](#7-translate---translation-by-duckduckgocom)
|
|
122
122
|
- [8. `suggestions()` - suggestions by DuckDuckGo.com](#8-suggestions---suggestions-by-duckduckgocom)
|
|
123
|
+
- [usage of WEBSX -- Another Websearch thing](#usage-of-websx----another-websearch-thing)
|
|
123
124
|
- [ALL acts](#all-acts)
|
|
124
125
|
- [Webscout Supported Acts:](#webscout-supported-acts)
|
|
125
126
|
- [usage of webscout AI](#usage-of-webscout-ai)
|
|
@@ -141,12 +142,12 @@ Search for anything using Google, DuckDuckGo, phind.com, Contains AI models, can
|
|
|
141
142
|
- [15. `poe`- chat with poe](#15-poe--chat-with-poe)
|
|
142
143
|
- [16. `BasedGPT` - chat with GPT](#16-basedgpt---chat-with-gpt)
|
|
143
144
|
- [17. `DeepSeek` -chat with deepseek](#17-deepseek--chat-with-deepseek)
|
|
145
|
+
- [18. Deepinfra](#18-deepinfra)
|
|
146
|
+
- [19. Deepinfra - VLM](#19-deepinfra---vlm)
|
|
144
147
|
- [`LLM`](#llm)
|
|
145
148
|
- [`Local-LLM` webscout can now run GGUF models](#local-llm-webscout-can-now-run-gguf-models)
|
|
146
|
-
- [`Function-calling-local-llm`](#function-calling-local-llm)
|
|
147
149
|
- [`Local-rawdog`](#local-rawdog)
|
|
148
150
|
- [`LLM` with internet](#llm-with-internet)
|
|
149
|
-
- [LLM with deepwebs](#llm-with-deepwebs)
|
|
150
151
|
- [`Webai` - terminal gpt and a open interpeter](#webai---terminal-gpt-and-a-open-interpeter)
|
|
151
152
|
|
|
152
153
|
## Install
|
|
@@ -392,68 +393,76 @@ def main():
|
|
|
392
393
|
if __name__ == "__main__":
|
|
393
394
|
main()
|
|
394
395
|
```
|
|
395
|
-
## DeepWEBS: Advanced Web Searches
|
|
396
396
|
|
|
397
|
-
|
|
397
|
+
## DWEBS: Advanced Web Searches
|
|
398
398
|
|
|
399
|
-
|
|
399
|
+
`DWEBS` is a standalone feature designed to perform advanced web searches with enhanced capabilities. It is particularly powerful in extracting relevant information directly from webpages and Search engine, focusing exclusively on text (web) searches. Unlike the `WEBS` , which provides a broader range of search functionalities, `DWEBS` is specifically tailored for in-depth web searches.
|
|
400
400
|
|
|
401
|
-
|
|
401
|
+
### Activating DWEBS
|
|
402
402
|
|
|
403
|
-
|
|
404
|
-
|
|
403
|
+
To utilize the `DWEBS` feature, you must first create an instance of the `DWEBS` . This is designed to be used independently of the `WEBS` , offering a focused approach to web searches.
|
|
404
|
+
|
|
405
|
+
### Point to remember before using `DWEBS`
|
|
406
|
+
As `DWEBS` is designed to extract relevant information directly from webpages and Search engine, It extracts html from webpages and saves them to folder named files
|
|
405
407
|
|
|
406
408
|
### Usage Example
|
|
407
409
|
|
|
408
|
-
Here's a basic example of how to use the `
|
|
410
|
+
Here's a basic example of how to use the `DWEBS` :
|
|
409
411
|
```python
|
|
410
|
-
from webscout import
|
|
411
|
-
|
|
412
|
-
def
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
types=["web"], # Search type: web
|
|
422
|
-
extract_webpage=True, # True for extracting webpages
|
|
423
|
-
overwrite_query_html=False,
|
|
424
|
-
overwrite_webpage_html=False,
|
|
412
|
+
from webscout import DWEBS
|
|
413
|
+
|
|
414
|
+
def finalextractor(extract_webpage=True):
|
|
415
|
+
print('---------------Here Running for GoogleSearch--------------------')
|
|
416
|
+
# 1. Google Search
|
|
417
|
+
google_searcher = DWEBS.GoogleSearcher()
|
|
418
|
+
query_html_path = google_searcher.search(
|
|
419
|
+
query='HelpingAI-9B',
|
|
420
|
+
result_num=10,
|
|
421
|
+
safe=False,
|
|
422
|
+
overwrite=False,
|
|
425
423
|
)
|
|
426
|
-
|
|
427
|
-
# Execute the search and retrieve results
|
|
428
|
-
results = D.queries_to_search_results(search_params)
|
|
429
|
-
|
|
430
|
-
return results
|
|
431
424
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
for
|
|
441
|
-
|
|
425
|
+
# 2. Search Result Extraction
|
|
426
|
+
query_results_extractor = DWEBS.QueryResultsExtractor()
|
|
427
|
+
query_search_results = query_results_extractor.extract(query_html_path)
|
|
428
|
+
|
|
429
|
+
if extract_webpage:
|
|
430
|
+
print('---------------Batch Webpage Fetcher--------------------')
|
|
431
|
+
# 3. Batch Webpage Fetching
|
|
432
|
+
batch_webpage_fetcher = DWEBS.BatchWebpageFetcher()
|
|
433
|
+
urls = [query_extracts['url'] for query_extracts in query_search_results['query_results']]
|
|
434
|
+
url_and_html_path_list = batch_webpage_fetcher.fetch(
|
|
435
|
+
urls,
|
|
436
|
+
overwrite=False,
|
|
437
|
+
output_parent=query_search_results["query"],
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
print('---------------Batch Webpage Extractor--------------------')
|
|
441
|
+
# 4. Batch Webpage Content Extraction
|
|
442
|
+
batch_webpage_content_extractor = DWEBS.BatchWebpageContentExtractor()
|
|
443
|
+
webpageurls = [url_and_html['html_path'] for url_and_html in url_and_html_path_list]
|
|
444
|
+
html_path_and_extracted_content_list = batch_webpage_content_extractor.extract(webpageurls)
|
|
445
|
+
|
|
446
|
+
# 5. Printing Extracted Content
|
|
447
|
+
for html_path_and_extracted_content in html_path_and_extracted_content_list:
|
|
448
|
+
print(html_path_and_extracted_content['extracted_content'])
|
|
442
449
|
else:
|
|
443
|
-
|
|
450
|
+
# Print only search results if extract_webpage is False
|
|
451
|
+
for result in query_search_results['query_results']:
|
|
452
|
+
DWEBS.logger.mesg(
|
|
453
|
+
f"{result['title']}\n"
|
|
454
|
+
f" - {result['site']}\n"
|
|
455
|
+
f" - {result['url']}\n"
|
|
456
|
+
f" - {result['abstract']}\n"
|
|
457
|
+
f"\n"
|
|
458
|
+
)
|
|
444
459
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
query = input("Enter your search query: ")
|
|
448
|
-
|
|
449
|
-
# Perform the web search
|
|
450
|
-
results = perform_web_search(query)
|
|
451
|
-
|
|
452
|
-
# Print the search results
|
|
453
|
-
print_search_results(results)
|
|
460
|
+
DWEBS.logger.success(f"- {len(query_search_results['query_results'])} query results")
|
|
461
|
+
DWEBS.logger.success(f"- {len(query_search_results['related_questions'])} related questions")
|
|
454
462
|
|
|
455
|
-
|
|
456
|
-
|
|
463
|
+
# Example usage:
|
|
464
|
+
finalextractor(extract_webpage=True) # Extract webpage content
|
|
465
|
+
finalextractor(extract_webpage=False) # Skip webpage extraction and print search results only
|
|
457
466
|
|
|
458
467
|
```
|
|
459
468
|
## Text-to-Speech:
|
|
@@ -532,7 +541,7 @@ This ensures proper resource management and cleanup, as the context manager will
|
|
|
532
541
|
Exceptions:
|
|
533
542
|
- `WebscoutE`: Raised when there is a generic exception during the API request.
|
|
534
543
|
|
|
535
|
-
## usage of
|
|
544
|
+
## usage of WEBS
|
|
536
545
|
|
|
537
546
|
### 1. `text()` - text search by DuckDuckGo.com
|
|
538
547
|
|
|
@@ -682,6 +691,36 @@ with WEBS() as WEBS:
|
|
|
682
691
|
for r in WEBS.suggestions("fly"):
|
|
683
692
|
print(r)
|
|
684
693
|
```
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
## usage of WEBSX -- Another Websearch thing
|
|
697
|
+
```python
|
|
698
|
+
from webscout import WEBSX
|
|
699
|
+
|
|
700
|
+
def main():
|
|
701
|
+
# Initialize the WEBSX client
|
|
702
|
+
search = WEBSX(
|
|
703
|
+
k=10,
|
|
704
|
+
)
|
|
705
|
+
|
|
706
|
+
# Example using `run` method - Get a summary
|
|
707
|
+
query = "What is the capital of France?"
|
|
708
|
+
answer = search.run(query)
|
|
709
|
+
print(f"Answer: {answer}\n")
|
|
710
|
+
|
|
711
|
+
# Example using `results` method - Get detailed results with metadata
|
|
712
|
+
query = "What is the capital of France?"
|
|
713
|
+
results = search.results(query, num_results=3)
|
|
714
|
+
print("Search Results:")
|
|
715
|
+
for result in results:
|
|
716
|
+
print(f"Title: {result['title']}")
|
|
717
|
+
print(f"Snippet: {result['snippet']}")
|
|
718
|
+
print(f"Link: {result['link']}\n")
|
|
719
|
+
print(f'Engines: {result["engines"]}')
|
|
720
|
+
|
|
721
|
+
if __name__ == "__main__":
|
|
722
|
+
main()
|
|
723
|
+
```
|
|
685
724
|
## ALL acts
|
|
686
725
|
<details>
|
|
687
726
|
<summary>expand</summary>
|
|
@@ -943,7 +982,7 @@ ___
|
|
|
943
982
|
### 0. `Duckchat` - chat with LLM
|
|
944
983
|
```python
|
|
945
984
|
from webscout import WEBS as w
|
|
946
|
-
R = w().chat("hello", model='claude-3-haiku') # GPT-3.5 Turbo
|
|
985
|
+
R = w().chat("hello", model='claude-3-haiku') # GPT-3.5 Turbo, mixtral-8x7b, llama-3-70b, claude-3-haiku
|
|
947
986
|
print(R)
|
|
948
987
|
```
|
|
949
988
|
### 1. `PhindSearch` - Search using Phind.com
|
|
@@ -1253,6 +1292,57 @@ while True:
|
|
|
1253
1292
|
r = ai.chat(prompt)
|
|
1254
1293
|
print(r)
|
|
1255
1294
|
```
|
|
1295
|
+
### 18. Deepinfra
|
|
1296
|
+
```python
|
|
1297
|
+
from webscout import DeepInfra
|
|
1298
|
+
|
|
1299
|
+
ai = DeepInfra(
|
|
1300
|
+
is_conversation=True,
|
|
1301
|
+
model= "Qwen/Qwen2-72B-Instruct",
|
|
1302
|
+
max_tokens=800,
|
|
1303
|
+
timeout=30,
|
|
1304
|
+
intro=None,
|
|
1305
|
+
filepath=None,
|
|
1306
|
+
update_file=True,
|
|
1307
|
+
proxies={},
|
|
1308
|
+
history_offset=10250,
|
|
1309
|
+
act=None,
|
|
1310
|
+
)
|
|
1311
|
+
|
|
1312
|
+
prompt = "what is meaning of life"
|
|
1313
|
+
|
|
1314
|
+
response = ai.ask(prompt)
|
|
1315
|
+
|
|
1316
|
+
# Extract and print the message from the response
|
|
1317
|
+
message = ai.get_message(response)
|
|
1318
|
+
print(message)
|
|
1319
|
+
```
|
|
1320
|
+
|
|
1321
|
+
### 19. Deepinfra - VLM
|
|
1322
|
+
```python
|
|
1323
|
+
from webscout import DeepInfra
|
|
1324
|
+
|
|
1325
|
+
ai = DeepInfra(
|
|
1326
|
+
is_conversation=True,
|
|
1327
|
+
model= "Qwen/Qwen2-72B-Instruct",
|
|
1328
|
+
max_tokens=800,
|
|
1329
|
+
timeout=30,
|
|
1330
|
+
intro=None,
|
|
1331
|
+
filepath=None,
|
|
1332
|
+
update_file=True,
|
|
1333
|
+
proxies={},
|
|
1334
|
+
history_offset=10250,
|
|
1335
|
+
act=None,
|
|
1336
|
+
)
|
|
1337
|
+
|
|
1338
|
+
prompt = "what is meaning of life"
|
|
1339
|
+
|
|
1340
|
+
response = ai.ask(prompt)
|
|
1341
|
+
|
|
1342
|
+
# Extract and print the message from the response
|
|
1343
|
+
message = ai.get_message(response)
|
|
1344
|
+
print(message)
|
|
1345
|
+
```
|
|
1256
1346
|
### `LLM`
|
|
1257
1347
|
```python
|
|
1258
1348
|
from webscout.LLM import LLM
|
|
@@ -1300,78 +1390,7 @@ thread = Thread(model, formats.phi3)
|
|
|
1300
1390
|
# 4. Start interacting with the model
|
|
1301
1391
|
thread.interact()
|
|
1302
1392
|
```
|
|
1303
|
-
### `Function-calling-local-llm`
|
|
1304
|
-
```python
|
|
1305
|
-
from webscout.Local import Model, Thread, formats
|
|
1306
|
-
from webscout import DeepWEBS
|
|
1307
|
-
from webscout.Local.utils import download_model
|
|
1308
|
-
from webscout.Local.model import Model
|
|
1309
|
-
from webscout.Local.thread import Thread
|
|
1310
|
-
from webscout.Local import formats
|
|
1311
|
-
from webscout.Local.samplers import SamplerSettings
|
|
1312
|
-
def deepwebs_search(query, max_results=5):
|
|
1313
|
-
"""Performs a web search using DeepWEBS and returns results as JSON."""
|
|
1314
|
-
deepwebs = DeepWEBS()
|
|
1315
|
-
search_config = DeepWEBS.DeepSearch(
|
|
1316
|
-
queries=[query],
|
|
1317
|
-
max_results=max_results,
|
|
1318
|
-
extract_webpage=False,
|
|
1319
|
-
safe=False,
|
|
1320
|
-
types=["web"],
|
|
1321
|
-
overwrite_query_html=True,
|
|
1322
|
-
overwrite_webpage_html=True,
|
|
1323
|
-
)
|
|
1324
|
-
search_results = deepwebs.queries_to_search_results(search_config)
|
|
1325
|
-
formatted_results = []
|
|
1326
|
-
for result in search_results[0]: # Assuming only one query
|
|
1327
|
-
formatted_results.append(f"Title: {result['title']}\nURL: {result['url']}\n")
|
|
1328
|
-
return "\n".join(formatted_results)
|
|
1329
|
-
|
|
1330
|
-
# Load your model
|
|
1331
|
-
repo_id = "OEvortex/HelpingAI-9B"
|
|
1332
|
-
filename = "helpingai-9b.Q4_0.gguf"
|
|
1333
|
-
model_path = download_model(repo_id, filename, token='')
|
|
1334
1393
|
|
|
1335
|
-
# 2. Load the model
|
|
1336
|
-
model = Model(model_path, n_gpu_layers=10)
|
|
1337
|
-
|
|
1338
|
-
# Create a Thread
|
|
1339
|
-
system_prompt = "You are a helpful AI assistant. Respond to user queries concisely. If a user asks for information that requires a web search, use the `deepwebs_search` tool. Do not call the tool if it is not necessary."
|
|
1340
|
-
sampler = SamplerSettings(temp=0.7, top_p=0.9) # Adjust these values as needed
|
|
1341
|
-
# 4. Create a custom chatml format with your system prompt
|
|
1342
|
-
custom_chatml = formats.chatml.copy()
|
|
1343
|
-
custom_chatml['system_content'] = system_prompt
|
|
1344
|
-
thread = Thread(model, custom_chatml, sampler=sampler)
|
|
1345
|
-
# Add the deepwebs_search tool
|
|
1346
|
-
thread.add_tool({
|
|
1347
|
-
"type": "function",
|
|
1348
|
-
"function": {
|
|
1349
|
-
"name": "deepwebs_search",
|
|
1350
|
-
"description": "Performs a web search using DeepWEBS and returns the title and URLs of the results.",
|
|
1351
|
-
"execute": deepwebs_search,
|
|
1352
|
-
"parameters": {
|
|
1353
|
-
"type": "object",
|
|
1354
|
-
"properties": {
|
|
1355
|
-
"query": {
|
|
1356
|
-
"type": "string",
|
|
1357
|
-
"description": "The query to search on the web",
|
|
1358
|
-
},
|
|
1359
|
-
"max_results": {
|
|
1360
|
-
"type": "integer",
|
|
1361
|
-
"description": "Maximum number of search results (default: 5)",
|
|
1362
|
-
},
|
|
1363
|
-
},
|
|
1364
|
-
"required": ["query"],
|
|
1365
|
-
},
|
|
1366
|
-
},
|
|
1367
|
-
})
|
|
1368
|
-
|
|
1369
|
-
# Start interacting with the model
|
|
1370
|
-
while True:
|
|
1371
|
-
user_input = input("You: ")
|
|
1372
|
-
response = thread.send(user_input)
|
|
1373
|
-
print("Bot: ", response)
|
|
1374
|
-
```
|
|
1375
1394
|
### `Local-rawdog`
|
|
1376
1395
|
```python
|
|
1377
1396
|
import webscout.Local as ws
|
|
@@ -1532,94 +1551,7 @@ if __name__ == "__main__":
|
|
|
1532
1551
|
else:
|
|
1533
1552
|
print("No response")
|
|
1534
1553
|
```
|
|
1535
|
-
### LLM with deepwebs
|
|
1536
|
-
```python
|
|
1537
|
-
from __future__ import annotations
|
|
1538
|
-
from typing import List, Optional
|
|
1539
|
-
from webscout.LLM import LLM
|
|
1540
|
-
from webscout import DeepWEBS
|
|
1541
|
-
import warnings
|
|
1542
|
-
|
|
1543
|
-
system_message: str = (
|
|
1544
|
-
"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."
|
|
1545
|
-
"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."
|
|
1546
|
-
"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"
|
|
1547
|
-
)
|
|
1548
|
-
|
|
1549
|
-
# Ignore the specific UserWarning
|
|
1550
|
-
warnings.filterwarnings("ignore", category=UserWarning, module="curl_cffio", lineno=205)
|
|
1551
|
-
|
|
1552
|
-
LLM = LLM(model="mistralai/Mixtral-8x22B-Instruct-v0.1", system_message=system_message)
|
|
1553
|
-
|
|
1554
|
-
def perform_web_search(query):
|
|
1555
|
-
# Initialize the DeepWEBS class
|
|
1556
|
-
D = DeepWEBS()
|
|
1557
|
-
|
|
1558
|
-
# Set up the search parameters
|
|
1559
|
-
search_params = D.DeepSearch(
|
|
1560
|
-
queries=[query], # Query to search
|
|
1561
|
-
result_num=10, # Number of search results
|
|
1562
|
-
safe=True, # Enable SafeSearch
|
|
1563
|
-
types=["web"], # Search type: web
|
|
1564
|
-
extract_webpage=True, # True for extracting webpages
|
|
1565
|
-
overwrite_query_html=True,
|
|
1566
|
-
overwrite_webpage_html=True,
|
|
1567
|
-
)
|
|
1568
1554
|
|
|
1569
|
-
# Execute the search and retrieve results
|
|
1570
|
-
results = D.queries_to_search_results(search_params)
|
|
1571
|
-
return results
|
|
1572
|
-
|
|
1573
|
-
def chat(user_input: str, result_num: int = 10) -> Optional[str]:
|
|
1574
|
-
"""
|
|
1575
|
-
Chat function to perform a web search based on the user input and generate a response using the LLM model.
|
|
1576
|
-
|
|
1577
|
-
Parameters
|
|
1578
|
-
----------
|
|
1579
|
-
user_input : str
|
|
1580
|
-
The user input to be used for the web search
|
|
1581
|
-
max_results : int, optional
|
|
1582
|
-
The maximum number of search results to include in the response, by default 10
|
|
1583
|
-
|
|
1584
|
-
Returns
|
|
1585
|
-
-------
|
|
1586
|
-
Optional[str]
|
|
1587
|
-
The response generated by the LLM model, or None if there is no response
|
|
1588
|
-
"""
|
|
1589
|
-
# Perform a web search based on the user input
|
|
1590
|
-
search_results = perform_web_search(user_input)
|
|
1591
|
-
|
|
1592
|
-
# Extract URLs from search results
|
|
1593
|
-
url_results = []
|
|
1594
|
-
for result in search_results[0]['query_results']:
|
|
1595
|
-
url_results.append(f"{result['title']} ({result['site']}): {result['url']}")
|
|
1596
|
-
|
|
1597
|
-
# Format search results
|
|
1598
|
-
formatted_results = "\n".join(url_results)
|
|
1599
|
-
|
|
1600
|
-
# Define the messages to be sent, including the user input, search results, and system message
|
|
1601
|
-
messages = [
|
|
1602
|
-
{"role": "user", "content": f"User question is:\n{user_input}\nwebsearch results are:\n{formatted_results}"},
|
|
1603
|
-
]
|
|
1604
|
-
|
|
1605
|
-
# Use the chat method to get the response
|
|
1606
|
-
response = LLM.chat(messages)
|
|
1607
|
-
return response
|
|
1608
|
-
|
|
1609
|
-
if __name__ == "__main__":
|
|
1610
|
-
while True:
|
|
1611
|
-
# Get the user input
|
|
1612
|
-
user_input = input("User: ")
|
|
1613
|
-
|
|
1614
|
-
# Perform a web search based on the user input
|
|
1615
|
-
response = chat(user_input)
|
|
1616
|
-
|
|
1617
|
-
# Print the response
|
|
1618
|
-
if response:
|
|
1619
|
-
print("AI:", response)
|
|
1620
|
-
else:
|
|
1621
|
-
print("No response")
|
|
1622
|
-
```
|
|
1623
1555
|
## `Webai` - terminal gpt and a open interpeter
|
|
1624
1556
|
|
|
1625
1557
|
```python
|
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
DeepWEBS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
DeepWEBS/documents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
DeepWEBS/documents/query_results_extractor.py,sha256=whd0NKLpcxW_6q3SkBOhMukr1K_c1PPYN92rf5EHRPM,4049
|
|
4
|
-
DeepWEBS/documents/webpage_content_extractor.py,sha256=P4yHCkPTiBvMbORd8SKVt64rQFPJuj3iixcQoRU34Lw,5272
|
|
5
|
-
DeepWEBS/networks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
DeepWEBS/networks/filepath_converter.py,sha256=JKMBew1TYe4TVoGTqgTWerq2Pam49_9u9TVUFCTDQyk,3183
|
|
7
|
-
DeepWEBS/networks/google_searcher.py,sha256=-AdIpVkRgemsARnOt8WPkF2Id1baVlqDHyqX2qz8Aew,1966
|
|
8
|
-
DeepWEBS/networks/network_configs.py,sha256=-Hb78_7SBx32h219FnU14qcHTvBdDUf_QAU6-RTL_e0,726
|
|
9
|
-
DeepWEBS/networks/webpage_fetcher.py,sha256=vRB9T3o-nMgrMkG2NPHTDctNeXaPSKCmBXqu189h2ZI,3590
|
|
10
|
-
DeepWEBS/utilsdw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
DeepWEBS/utilsdw/enver.py,sha256=vpI7s4_o_VL9govSryOv-z1zYK3pTEW3-H9QNN8JYtc,2472
|
|
12
|
-
DeepWEBS/utilsdw/logger.py,sha256=Z0nFUcEGyU8r28yKiIyvEtO26xxpmJgbvNToTfwZecc,8174
|
|
13
1
|
webscout/AIauto.py,sha256=xPGr_Z0h27XXNh4Wiufjn9TksDOqxqlaGcLUYKNP55w,18246
|
|
14
2
|
webscout/AIbase.py,sha256=GoHbN8r0gq2saYRZv6LA-Fr9Jlcjv80STKFXUq2ZeGU,4710
|
|
15
|
-
webscout/AIutel.py,sha256=
|
|
16
|
-
webscout/DWEBS.py,sha256=
|
|
3
|
+
webscout/AIutel.py,sha256=0SquAHyAa9zqEfcBdfnplM8hCuQ_7a8CyxK6b83_n5k,33471
|
|
4
|
+
webscout/DWEBS.py,sha256=QLuT1IKu0lnwdl7W6c-ctBAO7Jj0Zk3PYm6-13BC7rU,25740
|
|
17
5
|
webscout/LLM.py,sha256=LbGCZdJf8A5dwfoGS4tyy39tAh5BDdhMZP0ScKaaQfU,4184
|
|
18
|
-
webscout/__init__.py,sha256=
|
|
6
|
+
webscout/__init__.py,sha256=QX-26QQFOsL_JhUT4bGR7H7JGI58ClFcg4dF6XnlJUQ,1847
|
|
19
7
|
webscout/__main__.py,sha256=ZtTRgsRjUi2JOvYFLF1ZCh55Sdoz94I-BS-TlJC7WDU,126
|
|
20
8
|
webscout/async_providers.py,sha256=holBv5SxanxVXc_92CBBaXHlB2IakB_fHnhyZaFjYF8,684
|
|
21
|
-
webscout/cli.py,sha256=
|
|
22
|
-
webscout/exceptions.py,sha256=
|
|
9
|
+
webscout/cli.py,sha256=enw_dPTCG3sNC1TXt96XccnpRmF4Etr99nh-RbGYags,18784
|
|
10
|
+
webscout/exceptions.py,sha256=YtIs-vXBwcjbt9TZ_wB7yI0dO7ANYIZAmEEeLmoQ2fI,487
|
|
23
11
|
webscout/g4f.py,sha256=NNcnlOtIWV9R93UsBN4jBGBEJ9sJ-Np1WbgjkGVDcYc,24487
|
|
24
12
|
webscout/models.py,sha256=5iQIdtedT18YuTZ3npoG7kLMwcrKwhQ7928dl_7qZW0,692
|
|
25
13
|
webscout/tempid.py,sha256=5oc3UbXhPGKxrMRTfRABT-V-dNzH_hOKWtLYM6iCWd4,5896
|
|
26
14
|
webscout/transcriber.py,sha256=EddvTSq7dPJ42V3pQVnGuEiYQ7WjJ9uyeR9kMSxN7uY,20622
|
|
27
15
|
webscout/utils.py,sha256=CxeXvp0rWIulUrEaPZMaNfg_tSuQLRSV8uuHA2chyKE,2603
|
|
28
|
-
webscout/version.py,sha256=
|
|
16
|
+
webscout/version.py,sha256=pTj22SSXb7rieyMXdGyEFmljJmZMa6FL_DaETjfeLwA,23
|
|
29
17
|
webscout/voice.py,sha256=0QjXTHAQmCK07IDZXRc7JXem47cnPJH7u3X0sVP1-UQ,967
|
|
30
|
-
webscout/webai.py,sha256=
|
|
31
|
-
webscout/webscout_search.py,sha256=
|
|
32
|
-
webscout/webscout_search_async.py,sha256=
|
|
18
|
+
webscout/webai.py,sha256=qkvhYdyF5wNdmW4rNdH3RbfQxabEWlGvCyAk2SbH04k,86602
|
|
19
|
+
webscout/webscout_search.py,sha256=lFAot1-Qil_YfXieeLakDVDEX8Ckcima4ueXdOYwiMc,42804
|
|
20
|
+
webscout/webscout_search_async.py,sha256=dooKGwLm0cwTml55Vy6NHPPY-nymEqX2h8laX94Zg5A,14537
|
|
21
|
+
webscout/websx_search.py,sha256=Nz4FfdSiXHaWoUGIUH1x1FzYlm8Ns736MMXM3EKm9_Y,11724
|
|
33
22
|
webscout/Local/__init__.py,sha256=RN6klpbabPGNX2YzPm_hdeUcQvieUwvJt22uAO2RKSM,238
|
|
34
|
-
webscout/Local/_version.py,sha256=
|
|
23
|
+
webscout/Local/_version.py,sha256=hC_EHWR519ZOsyRw9i6gXEfU5IAIR_B9d3THLVmkWXw,83
|
|
35
24
|
webscout/Local/formats.py,sha256=BiZZSoN3e8S6-S-ykBL9ogSUs0vK11GaZ3ghc9U8GRk,18994
|
|
36
25
|
webscout/Local/model.py,sha256=T_bzNNrxEyOyLyhp6fKwiuVBBkXC2a37LzJVCxFIxOU,30710
|
|
37
26
|
webscout/Local/rawdog.py,sha256=LtA7bck2HyvWmovuaG86Iiquiz7XiMcxBlebo9IuGBY,35744
|
|
@@ -43,6 +32,7 @@ webscout/Provider/Berlin4h.py,sha256=zMpmWmdFCbcE3UWB-F9xbbTWZTfx4GnjnRf6sDoaiC0
|
|
|
43
32
|
webscout/Provider/Blackboxai.py,sha256=HUk0moEGsgGvidD1LF9tbfaKdx7bPnGU_SrYPdcfHU8,17182
|
|
44
33
|
webscout/Provider/ChatGPTUK.py,sha256=qmuCb_a71GNE5LelOb5AKJUBndvj7soebiNey4VdDvE,8570
|
|
45
34
|
webscout/Provider/Cohere.py,sha256=IXnRosYOaMAA65nvsKmN6ZkJGSdZFYQYBidzuNaCqX8,8711
|
|
35
|
+
webscout/Provider/Deepinfra.py,sha256=13H1h4FCon3GzjV9vCrLH_v9NcWHV6nl6i6NgnpXPGQ,18272
|
|
46
36
|
webscout/Provider/Deepseek.py,sha256=HKsC-ePLSPqcrQbafy-IzR0BNqId3LfiIEhk9j9oTs4,10285
|
|
47
37
|
webscout/Provider/Gemini.py,sha256=_4DHWvlWuNAmVHPwHB1RjmryjTZZCthLa6lvPEHLvkQ,8451
|
|
48
38
|
webscout/Provider/Groq.py,sha256=QfgP3hKUcqq5vUA4Pzuu3HAgpJkKwLWNjjsnxtkCYd8,21094
|
|
@@ -59,10 +49,10 @@ webscout/Provider/ThinkAnyAI.py,sha256=_qFjj0djxxrranyEY33w14oizyRjzlVwMv_hzvVtw
|
|
|
59
49
|
webscout/Provider/Xjai.py,sha256=BIlk2ouz9Kh_0Gg9hPvTqhI7XtcmWdg5vHSX_4uGrIs,9039
|
|
60
50
|
webscout/Provider/Yepchat.py,sha256=2Eit-A7w1ph1GQKNQuur_yaDzI64r0yBGxCIjDefJxQ,19875
|
|
61
51
|
webscout/Provider/Youchat.py,sha256=UVGBuGSjv4uRibn1xflmCjYcfrRTKnDvX3adhag6T98,7976
|
|
62
|
-
webscout/Provider/__init__.py,sha256=
|
|
63
|
-
webscout-3.
|
|
64
|
-
webscout-3.
|
|
65
|
-
webscout-3.
|
|
66
|
-
webscout-3.
|
|
67
|
-
webscout-3.
|
|
68
|
-
webscout-3.
|
|
52
|
+
webscout/Provider/__init__.py,sha256=j132gtLgDqUJl9GNNgO4k9GUmKdlYUG0dn4AjpS8fZA,1616
|
|
53
|
+
webscout-3.5.dist-info/LICENSE.md,sha256=9P0imsudI7MEvZe2pOcg8rKBn6E5FGHQ-riYozZI-Bk,2942
|
|
54
|
+
webscout-3.5.dist-info/METADATA,sha256=I_dj9LHVC_6WMkg0V4K2ilywFffLPElOdLTwgfI1dIQ,63504
|
|
55
|
+
webscout-3.5.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
56
|
+
webscout-3.5.dist-info/entry_points.txt,sha256=Hh4YIIjvkqB9SVxZ2ri4DZUkgEu_WF_5_r_nZDIvfG8,73
|
|
57
|
+
webscout-3.5.dist-info/top_level.txt,sha256=nYIw7OKBQDr_Z33IzZUKidRD3zQEo8jOJYkMVMeN334,9
|
|
58
|
+
webscout-3.5.dist-info/RECORD,,
|
DeepWEBS/__init__.py
DELETED
|
File without changes
|
DeepWEBS/documents/__init__.py
DELETED
|
File without changes
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
from bs4 import BeautifulSoup
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from DeepWEBS.utilsdw.logger import logger
|
|
4
|
-
|
|
5
|
-
class QueryResultsExtractor:
|
|
6
|
-
def __init__(self) -> None:
|
|
7
|
-
self.query_results = []
|
|
8
|
-
self.related_questions = []
|
|
9
|
-
|
|
10
|
-
def load_html(self, html_path):
|
|
11
|
-
try:
|
|
12
|
-
with open(html_path, "r", encoding="utf-8") as f:
|
|
13
|
-
html = f.read()
|
|
14
|
-
self.soup = BeautifulSoup(html, "html.parser")
|
|
15
|
-
except FileNotFoundError:
|
|
16
|
-
logger.error(f"File not found: {html_path}")
|
|
17
|
-
except Exception as e:
|
|
18
|
-
logger.error(f"Error loading HTML: {e}")
|
|
19
|
-
|
|
20
|
-
def extract_query_results(self):
|
|
21
|
-
try:
|
|
22
|
-
self.query = self.soup.find("textarea").text.strip()
|
|
23
|
-
query_result_elements = self.soup.find_all("div", class_="g")
|
|
24
|
-
for idx, result in enumerate(query_result_elements):
|
|
25
|
-
try:
|
|
26
|
-
site = result.find("cite").find_previous("span").text.strip()
|
|
27
|
-
url = result.find("a")["href"]
|
|
28
|
-
title = result.find("h3").text.strip()
|
|
29
|
-
abstract_element_conditions = [
|
|
30
|
-
{"data-sncf": "1"},
|
|
31
|
-
{"class_": "ITZIwc"},
|
|
32
|
-
]
|
|
33
|
-
for condition in abstract_element_conditions:
|
|
34
|
-
abstract_element = result.find("div", condition)
|
|
35
|
-
if abstract_element is not None:
|
|
36
|
-
abstract = abstract_element.text.strip()
|
|
37
|
-
break
|
|
38
|
-
else:
|
|
39
|
-
abstract = ""
|
|
40
|
-
logger.mesg(
|
|
41
|
-
f"{title}\n"
|
|
42
|
-
f" - {site}\n"
|
|
43
|
-
f" - {url}\n"
|
|
44
|
-
f" - {abstract}\n"
|
|
45
|
-
f"\n"
|
|
46
|
-
)
|
|
47
|
-
self.query_results.append(
|
|
48
|
-
{
|
|
49
|
-
"title": title,
|
|
50
|
-
"site": site,
|
|
51
|
-
"url": url,
|
|
52
|
-
"abstract": abstract,
|
|
53
|
-
"index": idx,
|
|
54
|
-
"type": "web",
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
except Exception as e:
|
|
58
|
-
logger.error(f"Error extracting query result: {e}")
|
|
59
|
-
logger.success(f"- {len(query_result_elements)} query results")
|
|
60
|
-
except Exception as e:
|
|
61
|
-
logger.error(f"Error extracting query results: {e}")
|
|
62
|
-
|
|
63
|
-
def extract_related_questions(self):
|
|
64
|
-
try:
|
|
65
|
-
related_question_elements = self.soup.find_all(
|
|
66
|
-
"div", class_="related-question-pair"
|
|
67
|
-
)
|
|
68
|
-
for question_element in related_question_elements:
|
|
69
|
-
try:
|
|
70
|
-
question = question_element.find("span").text.strip()
|
|
71
|
-
print(question)
|
|
72
|
-
self.related_questions.append(question)
|
|
73
|
-
except Exception as e:
|
|
74
|
-
logger.error(f"Error extracting related question: {e}")
|
|
75
|
-
logger.success(f"- {len(self.related_questions)} related questions")
|
|
76
|
-
except Exception as e:
|
|
77
|
-
logger.error(f"Error extracting related questions: {e}")
|
|
78
|
-
|
|
79
|
-
def extract(self, html_path):
|
|
80
|
-
self.load_html(html_path)
|
|
81
|
-
self.extract_query_results()
|
|
82
|
-
self.extract_related_questions()
|
|
83
|
-
self.search_results = {
|
|
84
|
-
"query": self.query,
|
|
85
|
-
"query_results": self.query_results,
|
|
86
|
-
"related_questions": self.related_questions,
|
|
87
|
-
}
|
|
88
|
-
return self.search_results
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if __name__ == "__main__":
|
|
92
|
-
html_path_root = Path(__file__).parents[1] / "files"
|
|
93
|
-
html_filename = "python_tutorials"
|
|
94
|
-
html_path = html_path_root / f"{html_filename}.html"
|
|
95
|
-
extractor = QueryResultsExtractor()
|
|
96
|
-
try:
|
|
97
|
-
extractor.extract(html_path)
|
|
98
|
-
except Exception as e:
|
|
99
|
-
logger.error(f"Error in main function: {e}")
|