webscout 1.0.5__py3-none-any.whl → 1.0.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of webscout might be problematic. Click here for more details.

webscout/AI.py ADDED
@@ -0,0 +1,193 @@
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
+ class PhindSearch:
17
+ def __init__(self, query):
18
+ self.query = query
19
+ self.url = "https://www.phind.com/search?q=" + self.query
20
+ self.chrome_options = Options()
21
+ self.chrome_options.add_argument("--log-level=3") # Fatal errors only
22
+ self.chrome_options.add_argument("--headless")
23
+ self.chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
24
+ self.driver = webdriver.Chrome(options=self.chrome_options)
25
+
26
+ def search(self):
27
+ try:
28
+ spinner = Halo("Getting Answer from Phind...\n\n\n\n\n\n\n \n", spinner="dots")
29
+ spinner.start()
30
+
31
+ self.driver.get(self.url)
32
+
33
+ WebDriverWait(self.driver, timeout=50).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
34
+ time.sleep(15)
35
+ answer_elements = self.driver.find_elements(By.CSS_SELECTOR, "main div.fs-5")
36
+
37
+ paragraph_texts = [answer_element.text.strip() for answer_element in answer_elements]
38
+
39
+ for text in paragraph_texts:
40
+ spinner.stop()
41
+ print(text)
42
+
43
+ finally:
44
+ self.driver.quit()
45
+
46
+ def close(self):
47
+ self.driver.quit()
48
+
49
+ @staticmethod
50
+ def search_cli(query):
51
+ """Use webscout.AI."""
52
+ search_instance = PhindSearch(query)
53
+ search_instance.search()
54
+
55
+ class YepChat:
56
+ def __init__(self, message="hello"):
57
+ self.url = "https://api.yep.com/v1/chat/completions"
58
+ self.headers = {
59
+ "Accept": "*/*",
60
+ "Accept-Encoding": "gzip, deflate, br, zstd",
61
+ "Accept-Language": "en-US,en;q=0.9",
62
+ "Cache-Control": "max-age=0",
63
+ "Content-Type": "application/json; charset=utf-8",
64
+ "Origin": "https://yep.com",
65
+ "Referer": "https://yep.com/",
66
+ "Sec-Ch-Ua": '"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
67
+ "Sec-Ch-Ua-Mobile": "?0",
68
+ "Sec-Ch-Ua-Platform": '"Windows"',
69
+ "Sec-Fetch-Dest": "empty",
70
+ "Sec-Fetch-Mode": "cors",
71
+ "Sec-Fetch-Site": "same-site",
72
+ "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"
73
+ }
74
+ self.payload = {
75
+ "stream": True,
76
+ "max_tokens": 1280,
77
+ "top_p": 0.7,
78
+ "temperature": 0.6,
79
+ "messages": [{
80
+ "content": message,
81
+ "role": "user"
82
+ }],
83
+ "model": "Mixtral-8x7B-Instruct-v0.1"
84
+ }
85
+
86
+ def send_request(self):
87
+ response = requests.post(self.url, headers=self.headers, data=json.dumps(self.payload), stream=True)
88
+ print(response.status_code)
89
+ return response
90
+
91
+ def process_response(self, response):
92
+ myset = ""
93
+ for line in response.iter_lines():
94
+ if line:
95
+ myline = line.decode('utf-8').removeprefix("data: ").replace(" null", "False")
96
+ try:
97
+ myval = eval(myline)
98
+ if "choices" in myval and "delta" in myval["choices"][0] and "content" in myval["choices"][0]["delta"]:
99
+ print(myval["choices"][0]["delta"]["content"], flush=True, end="")
100
+ myset += myval["choices"][0]["delta"]["content"]
101
+ except:
102
+ continue
103
+ print(myset)
104
+ return myset
105
+
106
+ @staticmethod
107
+ def chat_cli(message):
108
+ """Sends a request to the Yep API and processes the response."""
109
+ yep_chat = YepChat(message=message)
110
+ response = yep_chat.send_request()
111
+ yep_chat.process_response(response)
112
+
113
+ class youChat:
114
+ """
115
+ This class provides methods for generating completions based on prompts.
116
+ """
117
+ def create(self, prompt):
118
+ """
119
+ Generate a completion based on the provided prompt.
120
+
121
+ Args:
122
+ prompt (str): The input prompt to generate a completion from.
123
+
124
+ Returns:
125
+ str: The generated completion as a text string.
126
+
127
+ Raises:
128
+ Exception: If the response does not contain the expected "youChatToken".
129
+ """
130
+ resp = get(
131
+ "https://you.com/api/streamingSearch",
132
+ headers={
133
+ "cache-control": "no-cache",
134
+ "referer": "https://you.com/search?q=gpt4&tbm=youchat",
135
+ "cookie": f"safesearch_guest=Off; uuid_guest={str(uuid4())}",
136
+ },
137
+ params={
138
+ "q": prompt,
139
+ "page": 1,
140
+ "count": 10,
141
+ "safeSearch": "Off",
142
+ "onShoppingPage": False,
143
+ "mkt": "",
144
+ "responseFilter": "WebPages,Translations,TimeZone,Computation,RelatedSearches",
145
+ "domain": "youchat",
146
+ "queryTraceId": str(uuid4()),
147
+ "chat": [],
148
+ },
149
+ impersonate="chrome107",
150
+ )
151
+ if "youChatToken" not in resp.text:
152
+ raise RequestsError("Unable to fetch the response.")
153
+ return (
154
+ "".join(
155
+ findall(
156
+ r"{\"youChatToken\": \"(.*?)\"}",
157
+ resp.content.decode("unicode-escape"),
158
+ )
159
+ )
160
+ .replace("\\n", "\n")
161
+ .replace("\\\\", "\\")
162
+ .replace('\\"', '"')
163
+ )
164
+
165
+ @staticmethod
166
+ def chat_cli(prompt):
167
+ """Generate completion based on the provided prompt"""
168
+ you_chat = youChat()
169
+ completion = you_chat.create(prompt)
170
+ print(completion)
171
+
172
+
173
+ @click.group()
174
+ def cli():
175
+ pass
176
+
177
+ @cli.command()
178
+ @click.option('--query', prompt='Enter your search query', help='The query to search for.')
179
+ def phindsearch(query):
180
+ PhindSearch.search_cli(query)
181
+
182
+ @cli.command()
183
+ @click.option('--message', prompt='Enter your message', help='The message to send.')
184
+ def yepchat(message):
185
+ YepChat.chat_cli(message)
186
+
187
+ @cli.command()
188
+ @click.option('--prompt', prompt='Enter your prompt', help='The prompt to generate a completion from.')
189
+ def youchat(prompt):
190
+ youChat.chat_cli(prompt)
191
+
192
+ if __name__ == '__main__':
193
+ cli()
webscout/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.0.5"
1
+ __version__ = "1.0.6"
@@ -0,0 +1,17 @@
1
+ 🌟 **HelpingAI Innovator's License 📜**
2
+
3
+ 📅 **Copyright: ©️ 2022 HelpingAI**
4
+
5
+ 📝 **License Terms & Guidelines:**
6
+
7
+ 1. **Empower Innovation:** Embrace the power to innovate, create, and push the boundaries of possibility with HelpingAI.
8
+
9
+ 2. **Recognition:** Honor and acknowledge HelpingAI for its original creation and any enhancements or modifications made to the software.
10
+
11
+ 3. **Unrestricted Use:** Enjoy the freedom of unrestricted use, modification, and distribution of the software without limitations.
12
+
13
+ 4. **Community Collaboration:** Foster a spirit of collaboration by sharing your advancements, insights, and contributions with the wider community.
14
+
15
+ 5. **Continuous Advancement:** Commit to the continuous advancement and improvement of AI technology through your dedicated efforts.
16
+
17
+ 🚀 **Unlock the Potential of Innovation with the HelpingAI Innovator's License! 🌌**
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webscout
3
- Version: 1.0.5
4
- Summary: Search for words, documents, images, news, maps, and text translation using the DuckDuckGo.com and yep.com periodically.
3
+ Version: 1.0.6
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, Zaid
6
6
  Author-email: helpingai5@gmail.com
7
7
  Classifier: Development Status :: 5 - Production/Stable
@@ -24,11 +24,16 @@ Requires-Dist: click >=8.1.7
24
24
  Requires-Dist: curl-cffi >=0.6.0b7
25
25
  Requires-Dist: lxml >=5.1.0
26
26
  Requires-Dist: nest-asyncio >=1.6.0
27
+ Requires-Dist: selenium >=4.1.3
28
+ Requires-Dist: tqdm >=4.64.0
29
+ Requires-Dist: webdriver-manager >=3.5.4
30
+ Requires-Dist: halo >=0.0.31
27
31
  Provides-Extra: dev
28
32
  Requires-Dist: ruff >=0.1.6 ; extra == 'dev'
29
33
  Requires-Dist: pytest >=7.4.2 ; extra == 'dev'
30
34
 
31
- Search for words, documents, images, videos, news, maps and text translation using the DuckDuckGo.com and yep.com
35
+ Search for words, documents, images, videos, news, maps and text translation using the DuckDuckGo.com, yep.com, phind.com and you.com
36
+ Also containes AI models that you can use
32
37
  **⚠️ Warning: use AsyncWEBS in asynchronous code**
33
38
 
34
39
  ## Table of Contents
@@ -37,6 +42,7 @@ Search for words, documents, images, videos, news, maps and text translation usi
37
42
  - [What is next](#what-is-next)
38
43
  - [Install](#install)
39
44
  - [CLI version](#cli-version)
45
+ - [CLI version of AI](#cli-version-of-ai)
40
46
  - [Regions](#regions)
41
47
  - [WEBS and AsyncWEBS classes](#webs-and-asyncwebs-classes)
42
48
  - [Exceptions](#exceptions)
@@ -48,13 +54,19 @@ Search for words, documents, images, videos, news, maps and text translation usi
48
54
  - [6. `maps()` - map search by DuckDuckGo.com and](#6-maps---map-search-by-duckduckgocom-and)
49
55
  - [7. `translate()` - translation by DuckDuckGo.com and Yep.com](#7-translate---translation-by-duckduckgocom-and-yepcom)
50
56
  - [8. `suggestions()` - suggestions by DuckDuckGo.com and Yep.com](#8-suggestions---suggestions-by-duckduckgocom-and-yepcom)
57
+ - [9. `PhindSearch` - Search using Phind.com](#9-phindsearch---search-using-phindcom)
58
+ - [10. `YepChat` - Chat with mistral 8x7b powered by yepchat](#10-yepchat---chat-with-mistral-8x7b-powered-by-yepchat)
59
+ - [11. `You.com` - search with you.com](#11-youcom---search-with-youcom)
51
60
 
52
61
  ## What is new
53
62
  - Added yep.com as search engine.
54
63
  - solved a error where translate was not working.
55
-
64
+ - Added Phind AI as webscout.AI
65
+ - Added YepChat as webscout.AI
66
+ - Added You.com as webscout.AI
56
67
  ## What is next
57
- - trying to add yepchat
68
+ - adding more AI models or fuctions
69
+ -
58
70
  ## Install
59
71
  ```python
60
72
  pip install -U webscout
@@ -65,7 +77,18 @@ pip install -U webscout
65
77
  ```python3
66
78
  python -m webscout --help
67
79
  ```
80
+ ## CLI version of AI
81
+
82
+ ``python3
83
+ python -m webscout.AI phindsearch --query "your_query_here"
84
+ ```
68
85
 
86
+ ```python
87
+ python -m webscout.AI yepchat --message "your_message_here"
88
+ ```
89
+ ```python
90
+ python -m webscout.AI youchat --prompt "your_prompt_here"
91
+ ```
69
92
  [Go To TOP](#TOP)
70
93
 
71
94
  ## Regions
@@ -334,8 +357,54 @@ with WEBS() as WEBS:
334
357
  ```python
335
358
  from webscout import WEBS
336
359
 
337
- # Suggestions for the keyword 'fly' using DuckDuckGo.com and Yep.com
360
+ # Suggestions for the keyword 'fly' using DuckDuckGo.com and Yep
361
+ #
362
+
363
+ .com
338
364
  with WEBS() as WEBS:
339
365
  for r in WEBS.suggestions("fly"):
340
366
  print(r)
341
367
  ```
368
+
369
+ ### 9. `PhindSearch` - Search using Phind.com
370
+ Thanks to Empyros for PhindSearch function
371
+ ```python
372
+ from webscout.AI import PhindSearch
373
+
374
+ query = 'Webscout pypi'
375
+
376
+ # Create an instance of WEBSAI with the query
377
+ WEBSAI = PhindSearch(query)
378
+
379
+ WEBSAI.search()
380
+ ```
381
+ ### 10. `YepChat` - Chat with mistral 8x7b powered by yepchat
382
+ Thanks To Divyansh Shukla for This code
383
+ ```python
384
+ from webscout.AI import YepChat
385
+ # Example usage of the chat_cli method
386
+ YepChat.chat_cli("Hello, how can I help you today?")
387
+ ```
388
+
389
+ ### 11. `You.com` - search with you.com
390
+ ```python
391
+ from webscout.AI import youChat
392
+
393
+ # Instantiate the youchat class
394
+ youChat = youChat()
395
+
396
+ while True:
397
+ # Ask the user for a prompt
398
+ prompt = input("💡 Enter a prompt (or type 'exit' to quit): ")
399
+
400
+ # Exit condition
401
+ if prompt.lower() == 'exit':
402
+ break
403
+
404
+ # Generate a completion based on the prompt
405
+ try:
406
+ completion = youChat.create(prompt)
407
+ print("💬:", completion)
408
+ except Exception as e:
409
+ print("⚠️ An error occurred:", e)
410
+ ```
@@ -1,15 +1,16 @@
1
+ webscout/AI.py,sha256=EsI1ldocPgCaAsOQAAlBZWaIlp-LkEpTnWkSLeVhx7E,6680
1
2
  webscout/__init__.py,sha256=vHJGZexYIaWDTHfMimqA7enct9b7zPDf6jLsS7NDBiA,536
2
3
  webscout/__main__.py,sha256=ZtTRgsRjUi2JOvYFLF1ZCh55Sdoz94I-BS-TlJC7WDU,126
3
4
  webscout/cli.py,sha256=9opO5KynQ3LA5gPW2czlmy7-ZdfUae6ccrny3vibqzQ,17757
4
5
  webscout/exceptions.py,sha256=7u52Mt5iyEUCZvaZuEYwQVV8HL8IdZBv1r5s5Ss_xU0,75
5
6
  webscout/models.py,sha256=5iQIdtedT18YuTZ3npoG7kLMwcrKwhQ7928dl_7qZW0,692
6
7
  webscout/utils.py,sha256=M2ocDpYOVd9lTZA3VGdK_p80Xsr-VPeAoUUCFaMWCqk,1610
7
- webscout/version.py,sha256=lfZikIZ2prlMV6RkxhMRZj5dAeD0TCswIWS46kSjXw0,23
8
+ webscout/version.py,sha256=1HqFYnow__4MUVRI_OMjvzTBzKkReNozOdA96kH53cA,23
8
9
  webscout/webscout_search.py,sha256=_kuNpRhbgge6MubxlsRe9kzBKlHoPEH6-93ILMpycfg,2351
9
10
  webscout/webscout_search_async.py,sha256=lNdR18-y8O9HqFsHvlzBYg18qeI12uLEXIzFMP3D_XU,35070
10
- webscout-1.0.5.dist-info/LICENSE.md,sha256=ple694nFBJxLq83VmOoXLaKHCuN6Zmx4BbcMMLjAWmc,1087
11
- webscout-1.0.5.dist-info/METADATA,sha256=4xfSlYmNlV5kG6OfoN4zksDFOPM52JzlSvA6027yVow,10383
12
- webscout-1.0.5.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
13
- webscout-1.0.5.dist-info/entry_points.txt,sha256=aRJf8ZQpdyIVFPxOHndOORY3pqJ3JfmUp8fQX95Ntf4,42
14
- webscout-1.0.5.dist-info/top_level.txt,sha256=nYIw7OKBQDr_Z33IzZUKidRD3zQEo8jOJYkMVMeN334,9
15
- webscout-1.0.5.dist-info/RECORD,,
11
+ webscout-1.0.6.dist-info/LICENSE.md,sha256=07ABCXFZBmAyzICIiQbglOYZGERK2umNJCYeOV54FP4,907
12
+ webscout-1.0.6.dist-info/METADATA,sha256=BqaiqbfkhBeu5e7GiwtW6z3IlH-NKrIa-0sHd7fYQMk,12404
13
+ webscout-1.0.6.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
14
+ webscout-1.0.6.dist-info/entry_points.txt,sha256=1naMz1lm0onX0Rn0RRBeGaQJIUKT8V6KASIcGJJHz0M,164
15
+ webscout-1.0.6.dist-info/top_level.txt,sha256=nYIw7OKBQDr_Z33IzZUKidRD3zQEo8jOJYkMVMeN334,9
16
+ webscout-1.0.6.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ [console_scripts]
2
+ WEBS = webscout.cli:cli
3
+ webscout-ai = webscout.AI:cli
4
+ webscout-ai-phindsearch = webscout.AI:phindsearch
5
+ webscout-ai-yepchat = webscout.AI:yepchat
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 HelpingAI
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- WEBS = webscout.cli:cli