webscout 6.6__py3-none-any.whl → 6.7__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/Extra/weather.py CHANGED
@@ -16,7 +16,7 @@ from rich.columns import Columns
16
16
  # Initialize Rich console with force terminal
17
17
  console = Console(force_terminal=True)
18
18
 
19
- def get_weather_emoji(condition: str) -> str:
19
+ def get_emoji(condition: str) -> str:
20
20
  """Get appropriate emoji for weather condition"""
21
21
  conditions = {
22
22
  'sunny': '*', 'clear': '*',
@@ -61,7 +61,7 @@ def create_current_weather_panel(data):
61
61
  location_name = f"{location['areaName'][0]['value']}, {location['country'][0]['value']}"
62
62
 
63
63
  weather_desc = current['weatherDesc'][0]['value']
64
- symbol = get_weather_emoji(weather_desc)
64
+ symbol = get_emoji(weather_desc)
65
65
 
66
66
  # Create weather info table
67
67
  table = Table(show_header=False, box=box.ROUNDED, expand=True)
@@ -98,7 +98,7 @@ def create_forecast_panel(data):
98
98
  # Get mid-day conditions (noon)
99
99
  noon = day['hourly'][4]
100
100
  condition = noon['weatherDesc'][0]['value']
101
- symbol = get_weather_emoji(condition)
101
+ symbol = get_emoji(condition)
102
102
  temp_range = f"{day['mintempC']}° - {day['maxtempC']}°"
103
103
  rain_chance = f"v {noon['chanceofrain']}%"
104
104
  wind = f"> {noon['windspeedKmph']} km/h"
@@ -113,7 +113,7 @@ def create_forecast_panel(data):
113
113
 
114
114
  return Panel(table, title="[bold]3-Day Forecast[/]", border_style="blue")
115
115
 
116
- def get_weather(location: str):
116
+ def get(location: str):
117
117
  """Get weather data with progress indicator"""
118
118
  with Progress(
119
119
  SpinnerColumn(),
@@ -159,7 +159,7 @@ def main():
159
159
  console.print("\n[bold cyan]* Weather Information[/]\n")
160
160
  location = console.input("[cyan]Enter location: [/]")
161
161
 
162
- weather_data = get_weather(location)
162
+ weather_data = get(location)
163
163
  if weather_data:
164
164
  display_weather(weather_data)
165
165
 
@@ -1,235 +1,239 @@
1
- import time
2
- import uuid
3
- import requests
4
- import json
5
-
6
- from typing import Any, Dict, Optional, Generator, Union
7
- from dataclasses import dataclass, asdict
8
- from datetime import date
9
-
10
- from webscout.AIutel import Optimizers, Conversation, AwesomePrompts
11
- from webscout.AIbase import Provider
12
- from webscout import exceptions
13
- from webscout.Litlogger import LitLogger, LogFormat, ColorScheme
14
- from webscout.litagent import LitAgent
15
-
16
-
17
- class Netwrck(Provider):
18
- """
19
- A class to interact with the Netwrck.com API. Supports streaming.
20
- """
21
-
22
- AVAILABLE_MODELS = {
23
- "lumimaid": "neversleep/llama-3.1-lumimaid-8b",
24
- "grok": "x-ai/grok-2",
25
- "claude": "anthropic/claude-3.5-sonnet:beta",
26
- "euryale": "sao10k/l3-euryale-70b",
27
- "gpt4mini": "openai/gpt-4o-mini",
28
- "mythomax": "gryphe/mythomax-l2-13b",
29
- "gemini": "google/gemini-pro-1.5",
30
- "lumimaid70b": "neversleep/llama-3.1-lumimaid-70b",
31
- "nemotron": "nvidia/llama-3.1-nemotron-70b-instruct",
32
- }
33
-
34
- def __init__(
35
- self,
36
- model: str = "lumimaid",
37
- is_conversation: bool = True,
38
- max_tokens: int = 2048,
39
- timeout: int = 30,
40
- intro: Optional[str] = None,
41
- filepath: Optional[str] = None,
42
- update_file: bool = False,
43
- proxies: Optional[dict] = None,
44
- history_offset: int = 0,
45
- act: Optional[str] = None,
46
- system_prompt: str = "You are a helpful assistant.",
47
- temperature: float = 0.7,
48
- top_p: float = 0.8,
49
- logging: bool = False
50
- ):
51
- """Initializes the Netwrck API client."""
52
- if model not in self.AVAILABLE_MODELS:
53
- raise ValueError(f"Invalid model: {model}. Choose from: {list(self.AVAILABLE_MODELS.keys())}")
54
-
55
- self.model = model
56
- self.model_name = self.AVAILABLE_MODELS[model]
57
- self.system_prompt = system_prompt
58
- self.session = requests.Session()
59
- self.is_conversation = is_conversation
60
- self.max_tokens_to_sample = max_tokens
61
- self.timeout = timeout
62
- self.last_response: Dict[str, Any] = {}
63
- self.temperature = temperature
64
- self.top_p = top_p
65
-
66
- # Initialize LitAgent for user agent generation
67
- self.agent = LitAgent()
68
-
69
- self.headers = {
70
- 'authority': 'netwrck.com',
71
- 'accept': '*/*',
72
- 'accept-language': 'en-US,en;q=0.9',
73
- 'content-type': 'application/json',
74
- 'origin': 'https://netwrck.com',
75
- 'referer': 'https://netwrck.com/',
76
- 'user-agent': self.agent.random()
77
- }
78
- self.session.headers.update(self.headers)
79
- self.proxies = proxies or {}
80
-
81
- Conversation.intro = (
82
- AwesomePrompts().get_act(act, raise_not_found=True, default=None, case_insensitive=True)
83
- if act
84
- else intro or Conversation.intro
85
- )
86
- self.conversation = Conversation(is_conversation, max_tokens, filepath, update_file)
87
- self.conversation.history_offset = history_offset
88
- self.__available_optimizers = (
89
- method
90
- for method in dir(Optimizers)
91
- if callable(getattr(Optimizers, method)) and not method.startswith("__")
92
- )
93
-
94
- # Initialize logger
95
- self.logger = LitLogger(name="Netwrck", format=LogFormat.MODERN_EMOJI, color_scheme=ColorScheme.CYBERPUNK) if logging else None
96
-
97
-
98
- def ask(
99
- self,
100
- prompt: str,
101
- stream: bool = False,
102
- raw: bool = False,
103
- optimizer: Optional[str] = None,
104
- conversationally: bool = False,
105
- ) -> Union[Dict[str, Any], Generator]:
106
- """Sends a prompt to the Netwrck API and returns the response."""
107
-
108
- if self.logger:
109
- self.logger.debug(f"ask() called with prompt: {prompt}")
110
-
111
- conversation_prompt = self.conversation.gen_complete_prompt(prompt)
112
- if optimizer:
113
- if optimizer in self.__available_optimizers:
114
- conversation_prompt = getattr(Optimizers, optimizer)(
115
- conversation_prompt if conversationally else prompt
116
- )
117
- else:
118
- if self.logger:
119
- self.logger.error(f"Invalid optimizer: {optimizer}")
120
- raise exceptions.FailedToGenerateResponseError(
121
- f"Optimizer is not one of {self.__available_optimizers}"
122
- )
123
-
124
- payload = {
125
- "query": conversation_prompt,
126
- "context": self.system_prompt,
127
- "examples": [],
128
- "model_name": self.model_name,
129
- "temperature": self.temperature,
130
- "top_p": self.top_p,
131
- }
132
-
133
-
134
- def for_stream():
135
- try:
136
- response = self.session.post(
137
- "https://netwrck.com/api/chatpred_or",
138
- json=payload,
139
- headers=self.headers,
140
- proxies=self.proxies,
141
- timeout=self.timeout,
142
- stream=True,
143
- )
144
- response.raise_for_status()
145
-
146
- streaming_text = ""
147
- for line in response.iter_lines():
148
- if line:
149
- decoded_line = line.decode('utf-8').strip('"')
150
- streaming_text += decoded_line
151
- yield {"text": decoded_line} if not raw else decoded_line
152
-
153
- self.conversation.update_chat_history(prompt, streaming_text)
154
-
155
- except Exception as e:
156
- if self.logger:
157
- self.logger.error(f"Error communicating with Netwrck: {e}")
158
- raise exceptions.ProviderConnectionError(f"Error communicating with Netwrck: {e}") from e
159
-
160
- def for_non_stream():
161
- try:
162
- response = self.session.post(
163
- "https://netwrck.com/api/chatpred_or",
164
- json=payload,
165
- headers=self.headers,
166
- proxies=self.proxies,
167
- timeout=self.timeout,
168
- )
169
- response.raise_for_status()
170
- print(response.text)
171
- text = response.text.strip('"')
172
- self.last_response = {"text": text}
173
- self.conversation.update_chat_history(prompt, text)
174
-
175
- return self.last_response
176
- except Exception as e:
177
- if self.logger:
178
- self.logger.error(f"Error communicating with Netwrck: {e}")
179
- raise exceptions.ProviderConnectionError(f"Error communicating with Netwrck: {e}") from e
180
-
181
- return for_stream() if stream else for_non_stream()
182
-
183
- def chat(
184
- self,
185
- prompt: str,
186
- stream: bool = False,
187
- optimizer: Optional[str] = None,
188
- conversationally: bool = False,
189
- ) -> str:
190
- """Generates a response from the Netwrck API."""
191
- if self.logger:
192
- self.logger.debug(f"chat() called with prompt: {prompt}")
193
-
194
- def for_stream():
195
- for response in self.ask(
196
- prompt,
197
- stream=True,
198
- optimizer=optimizer,
199
- conversationally=conversationally
200
- ):
201
- yield self.get_message(response)
202
-
203
- def for_non_stream():
204
- return self.get_message(
205
- self.ask(
206
- prompt,
207
- stream=False,
208
- optimizer=optimizer,
209
- conversationally=conversationally,
210
- )
211
- )
212
-
213
- return for_stream() if stream else for_non_stream()
214
-
215
- def get_message(self, response: Dict[str, Any]) -> str:
216
- """Retrieves message only from response"""
217
- assert isinstance(response, dict), "Response should be of dict data-type only"
218
- return response["text"]
219
-
220
- # Example Usage:
221
- if __name__ == "__main__":
222
- from rich import print
223
-
224
- # Non-streaming example
225
- print("Non-Streaming Response:")
226
- netwrck = Netwrck(model="lumimaid", logging=True)
227
- response = netwrck.chat("What is the capital of France?")
228
- print(response)
229
-
230
- # Streaming example
231
- print("\nStreaming Response:")
232
- response = netwrck.chat("tell me about india", stream=True)
233
- for chunk in response:
234
- print(chunk, end="", flush=True)
1
+ import time
2
+ import uuid
3
+ import requests
4
+ import json
5
+
6
+ from typing import Any, Dict, Optional, Generator, Union
7
+ from dataclasses import dataclass, asdict
8
+ from datetime import date
9
+
10
+ from webscout.AIutel import Optimizers, Conversation, AwesomePrompts
11
+ from webscout.AIbase import Provider
12
+ from webscout import exceptions
13
+ from webscout.Litlogger import LitLogger, LogFormat, ColorScheme
14
+ from webscout.litagent import LitAgent
15
+
16
+
17
+ class Netwrck(Provider):
18
+ """
19
+ A class to interact with the Netwrck.com API. Supports streaming.
20
+ """
21
+ greeting = """An unknown multiverse phenomenon occurred, and you found yourself in a dark space. You looked around and found a source of light in a distance. You approached the light and *whoosh*....\nChoose your origin:\na) As a baby who just got birthed, your fate unknown\nb) As an amnesic stranded on an uninhabited island with mysterious ruins\nc) As an abandoned product of a forbidden experiment\nd) As a slave being sold at an auction\ne) Extremely Chaotic Randomizer\nOr, dive into your own fantasy."""
22
+
23
+ AVAILABLE_MODELS = {
24
+ "lumimaid": "neversleep/llama-3.1-lumimaid-8b",
25
+ "grok": "x-ai/grok-2",
26
+ "claude": "anthropic/claude-3.5-sonnet:beta",
27
+ "euryale": "sao10k/l3-euryale-70b",
28
+ "gpt4mini": "openai/gpt-4o-mini",
29
+ "mythomax": "gryphe/mythomax-l2-13b",
30
+ "gemini": "google/gemini-pro-1.5",
31
+ "lumimaid70b": "neversleep/llama-3.1-lumimaid-70b",
32
+ "nemotron": "nvidia/llama-3.1-nemotron-70b-instruct",
33
+ }
34
+
35
+ def __init__(
36
+ self,
37
+ model: str = "claude",
38
+ is_conversation: bool = True,
39
+ max_tokens: int = 2048,
40
+ timeout: int = 30,
41
+ intro: Optional[str] = None,
42
+ filepath: Optional[str] = None,
43
+ update_file: bool = False,
44
+ proxies: Optional[dict] = None,
45
+ history_offset: int = 0,
46
+ act: Optional[str] = None,
47
+ system_prompt: str = "You are a helpful assistant.",
48
+ temperature: float = 0.7,
49
+ top_p: float = 0.8,
50
+ logging: bool = False
51
+ ):
52
+ """Initializes the Netwrck API client."""
53
+ if model not in self.AVAILABLE_MODELS:
54
+ raise ValueError(f"Invalid model: {model}. Choose from: {list(self.AVAILABLE_MODELS.keys())}")
55
+
56
+ self.model = model
57
+ self.model_name = self.AVAILABLE_MODELS[model]
58
+ self.system_prompt = system_prompt
59
+ self.session = requests.Session()
60
+ self.is_conversation = is_conversation
61
+ self.max_tokens_to_sample = max_tokens
62
+ self.timeout = timeout
63
+ self.last_response: Dict[str, Any] = {}
64
+ self.temperature = temperature
65
+ self.top_p = top_p
66
+
67
+ # Initialize LitAgent for user agent generation
68
+ self.agent = LitAgent()
69
+
70
+ self.headers = {
71
+ 'authority': 'netwrck.com',
72
+ 'accept': '*/*',
73
+ 'accept-language': 'en-US,en;q=0.9',
74
+ 'content-type': 'application/json',
75
+ 'origin': 'https://netwrck.com',
76
+ 'referer': 'https://netwrck.com/',
77
+ 'user-agent': self.agent.random()
78
+ }
79
+ self.session.headers.update(self.headers)
80
+ self.proxies = proxies or {}
81
+
82
+ Conversation.intro = (
83
+ AwesomePrompts().get_act(act, raise_not_found=True, default=None, case_insensitive=True)
84
+ if act
85
+ else intro or Conversation.intro
86
+ )
87
+ self.conversation = Conversation(is_conversation, max_tokens, filepath, update_file)
88
+ self.conversation.history_offset = history_offset
89
+ self.__available_optimizers = (
90
+ method
91
+ for method in dir(Optimizers)
92
+ if callable(getattr(Optimizers, method)) and not method.startswith("__")
93
+ )
94
+
95
+ # Initialize logger
96
+ self.logger = LitLogger(name="Netwrck", format=LogFormat.MODERN_EMOJI, color_scheme=ColorScheme.CYBERPUNK) if logging else None
97
+
98
+ def ask(
99
+ self,
100
+ prompt: str,
101
+ stream: bool = False,
102
+ raw: bool = False,
103
+ optimizer: Optional[str] = None,
104
+ conversationally: bool = False,
105
+ ) -> Union[Dict[str, Any], Generator]:
106
+ """Sends a prompt to the Netwrck API and returns the response."""
107
+
108
+ if self.logger:
109
+ self.logger.debug(f"ask() called with prompt: {prompt}")
110
+
111
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
112
+ if optimizer:
113
+ if optimizer in self.__available_optimizers:
114
+ conversation_prompt = getattr(Optimizers, optimizer)(
115
+ conversation_prompt if conversationally else prompt
116
+ )
117
+ else:
118
+ if self.logger:
119
+ self.logger.error(f"Invalid optimizer: {optimizer}")
120
+ raise exceptions.FailedToGenerateResponseError(
121
+ f"Optimizer is not one of {self.__available_optimizers}"
122
+ )
123
+ payload = {
124
+ "query": prompt,
125
+ "context": self.system_prompt,
126
+ "examples": [],
127
+ "model_name": self.model_name,
128
+ "greeting": self.greeting
129
+ }
130
+
131
+ def for_stream():
132
+ try:
133
+ response = self.session.post(
134
+ "https://netwrck.com/api/chatpred_or",
135
+ json=payload,
136
+ headers=self.headers,
137
+ proxies=self.proxies,
138
+ timeout=self.timeout,
139
+ stream=True,
140
+ )
141
+ response.raise_for_status()
142
+
143
+ # Initialize an empty string to accumulate the streaming text
144
+ streaming_text = ""
145
+ for line in response.iter_lines():
146
+ if line:
147
+ decoded_line = line.decode('utf-8').strip('"')
148
+ streaming_text += decoded_line # Accumulate the text
149
+ yield {"text": decoded_line} # Yield each chunk
150
+
151
+ # Optionally, you can update the conversation history with the full streaming text
152
+ self.conversation.update_chat_history(payload["query"], streaming_text)
153
+
154
+ except Exception as e:
155
+ if self.logger:
156
+ self.logger.error(f"Error communicating with Netwrck: {e}")
157
+ raise exceptions.ProviderConnectionError(f"Error communicating with Netwrck: {e}") from e
158
+
159
+ except Exception as e:
160
+ if self.logger:
161
+ self.logger.error(f"Error communicating with Netwrck: {e}")
162
+ raise exceptions.ProviderConnectionError(f"Error communicating with Netwrck: {e}") from e
163
+
164
+ def for_non_stream():
165
+ try:
166
+ response = self.session.post(
167
+ "https://netwrck.com/api/chatpred_or",
168
+ json=payload,
169
+ headers=self.headers,
170
+ proxies=self.proxies,
171
+ timeout=self.timeout,
172
+ )
173
+ response.raise_for_status()
174
+ # print(response.text)
175
+ text = response.text.strip('"')
176
+ self.last_response = {"text": text}
177
+ self.conversation.update_chat_history(prompt, text)
178
+
179
+ return self.last_response
180
+ except Exception as e:
181
+ if self.logger:
182
+ self.logger.error(f"Error communicating with Netwrck: {e}")
183
+ raise exceptions.ProviderConnectionError(f"Error communicating with Netwrck: {e}") from e
184
+
185
+ return for_stream() if stream else for_non_stream()
186
+
187
+ def chat(
188
+ self,
189
+ prompt: str,
190
+ stream: bool = False,
191
+ optimizer: Optional[str] = None,
192
+ conversationally: bool = False,
193
+ ) -> str:
194
+ """Generates a response from the Netwrck API."""
195
+ if self.logger:
196
+ self.logger.debug(f"chat() called with prompt: {prompt}")
197
+
198
+ def for_stream():
199
+ for response in self.ask(
200
+ prompt,
201
+ stream=True,
202
+ optimizer=optimizer,
203
+ conversationally=conversationally
204
+ ):
205
+ yield self.get_message(response)
206
+
207
+ def for_non_stream():
208
+ return self.get_message(
209
+ self.ask(
210
+ prompt,
211
+ stream=False,
212
+ optimizer=optimizer,
213
+ conversationally=conversationally,
214
+ )
215
+ )
216
+
217
+ return for_stream() if stream else for_non_stream()
218
+
219
+ def get_message(self, response: Dict[str, Any]) -> str:
220
+ """Retrieves message only from response"""
221
+ assert isinstance(response, dict), "Response should be of dict data-type only"
222
+ return response["text"]
223
+
224
+ # Example Usage:
225
+ if __name__ == "__main__":
226
+ from rich import print
227
+
228
+ # Non-streaming example
229
+ print("Non-Streaming Response:")
230
+ netwrck = Netwrck(model="claude", logging=True)
231
+ response = netwrck.chat("tell me about Russia")
232
+ print(response)
233
+
234
+ # Streaming example
235
+ print("\nStreaming Response:")
236
+ response = netwrck.chat("tell me about India", stream=True)
237
+ for chunk in response:
238
+ print(chunk, end="", flush=True)
235
239
  print() # Add a newline at the end
webscout/Provider/meta.py CHANGED
@@ -248,7 +248,7 @@ def get_fb_session(email, password, proxies=None):
248
248
  return cookies
249
249
 
250
250
 
251
- def get_cookies() -> dict:
251
+ def get_cookies(self) -> dict:
252
252
  """
253
253
  Extracts necessary cookies from the Meta AI main page.
254
254
 
webscout/cli.py CHANGED
@@ -54,7 +54,7 @@ def _print_data(data):
54
54
  console = Console()
55
55
  if data:
56
56
  for i, e in enumerate(data, start=1):
57
- table = Table(show_header=False, show_lines=True, expand=True, box=None) # Removed duplicate title
57
+ table = Table(show_header=False, show_lines=True, expand=True, box=None)
58
58
  table.add_column("Key", style="cyan", no_wrap=True, width=15)
59
59
  table.add_column("Value", style="white")
60
60
 
@@ -62,15 +62,14 @@ def _print_data(data):
62
62
  if v:
63
63
  width = 300 if k in ("content", "href", "image", "source", "thumbnail", "url") else 78
64
64
  k = "language" if k == "detected_language" else k
65
- text = Text(f"{v}", style="white")
66
- text = text.wrap(width=width, initial_indent="", subsequent_indent=" " * 18, preserve_paragraphs=True)
65
+ text = Text(str(v), style="white")
66
+ text = text.wrap(width=width, console=console)
67
67
  else:
68
- text = Text(v, style="white")
68
+ text = Text(str(v), style="white")
69
69
  table.add_row(k, text)
70
70
 
71
- # Only the Panel has the title now
72
71
  console.print(Panel(table, title=f"Result {i}", expand=False, style="green on black"))
73
- console.print("\n")
72
+ console.print("\n")
74
73
 
75
74
  # Initialize CLI app
76
75
  app = CLI(name="webscout", help="Search the web with a rich UI", version=__version__)
@@ -117,7 +116,7 @@ def chat(proxy: str = None, model: str = "gpt-4o-mini"):
117
116
  console.print("\n[cyan]Chat session ended. Goodbye![/]")
118
117
 
119
118
  @app.command()
120
- @option("--keywords", "-k", help="Search keywords")
119
+ @option("--keywords", "-k", help="Search keywords", required=True)
121
120
  @option("--region", "-r", help="Region for search results", default="wt-wt")
122
121
  @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
123
122
  @option("--timelimit", "-t", help="Time limit for results", default=None)
@@ -128,29 +127,27 @@ def text(keywords: str, region: str, safesearch: str, timelimit: str, backend: s
128
127
  """Perform a text search using DuckDuckGo API."""
129
128
  webs = WEBS(proxy=proxy)
130
129
  try:
131
- webs.text(keywords, region, safesearch, timelimit, backend, max_results)
130
+ results = webs.text(keywords, region, safesearch, timelimit, backend, max_results)
131
+ _print_data(results)
132
132
  except Exception as e:
133
133
  logger.error(f"Error in text search: {e}")
134
134
  raise e
135
135
 
136
136
  @app.command()
137
- @option("--keywords", "-k", help="Search keywords")
138
- @option("--region", "-r", help="Region for search results", default="wt-wt")
139
- @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
140
- @option("--timelimit", "-t", help="Time limit for results", default=None)
141
- @option("--max-results", "-m", help="Maximum number of results", type=int, default=25)
137
+ @option("--keywords", "-k", help="Search keywords", required=True)
142
138
  @option("--proxy", "-p", help="Proxy URL to use for requests")
143
- def answers(keywords: str, region: str, safesearch: str, timelimit: str, max_results: int, proxy: str = None):
139
+ def answers(keywords: str, proxy: str = None):
144
140
  """Perform an answers search using DuckDuckGo API."""
145
141
  webs = WEBS(proxy=proxy)
146
142
  try:
147
- webs.answers(keywords, region, safesearch, timelimit, max_results)
143
+ results = webs.answers(keywords)
144
+ _print_data(results)
148
145
  except Exception as e:
149
146
  logger.error(f"Error in answers search: {e}")
150
147
  raise e
151
148
 
152
149
  @app.command()
153
- @option("--keywords", "-k", help="Search keywords")
150
+ @option("--keywords", "-k", help="Search keywords", required=True)
154
151
  @option("--region", "-r", help="Region for search results", default="wt-wt")
155
152
  @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
156
153
  @option("--timelimit", "-t", help="Time limit for results", default=None)
@@ -177,13 +174,14 @@ def images(
177
174
  """Perform an images search using DuckDuckGo API."""
178
175
  webs = WEBS(proxy=proxy)
179
176
  try:
180
- webs.images(keywords, region, safesearch, timelimit, size, color, type, layout, license, max_results)
177
+ results = webs.images(keywords, region, safesearch, timelimit, size, color, type, layout, license, max_results)
178
+ _print_data(results)
181
179
  except Exception as e:
182
180
  logger.error(f"Error in images search: {e}")
183
181
  raise e
184
182
 
185
183
  @app.command()
186
- @option("--keywords", "-k", help="Search keywords")
184
+ @option("--keywords", "-k", help="Search keywords", required=True)
187
185
  @option("--region", "-r", help="Region for search results", default="wt-wt")
188
186
  @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
189
187
  @option("--timelimit", "-t", help="Time limit for results", default=None)
@@ -206,13 +204,14 @@ def videos(
206
204
  """Perform a videos search using DuckDuckGo API."""
207
205
  webs = WEBS(proxy=proxy)
208
206
  try:
209
- webs.videos(keywords, region, safesearch, timelimit, resolution, duration, license, max_results)
207
+ results = webs.videos(keywords, region, safesearch, timelimit, resolution, duration, license, max_results)
208
+ _print_data(results)
210
209
  except Exception as e:
211
210
  logger.error(f"Error in videos search: {e}")
212
211
  raise e
213
212
 
214
213
  @app.command()
215
- @option("--keywords", "-k", help="Search keywords")
214
+ @option("--keywords", "-k", help="Search keywords", required=True)
216
215
  @option("--region", "-r", help="Region for search results", default="wt-wt")
217
216
  @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
218
217
  @option("--timelimit", "-t", help="Time limit for results", default=None)
@@ -222,13 +221,14 @@ def news(keywords: str, region: str, safesearch: str, timelimit: str, max_result
222
221
  """Perform a news search using DuckDuckGo API."""
223
222
  webs = WEBS(proxy=proxy)
224
223
  try:
225
- webs.news(keywords, region, safesearch, timelimit, max_results)
224
+ results = webs.news(keywords, region, safesearch, timelimit, max_results)
225
+ _print_data(results)
226
226
  except Exception as e:
227
227
  logger.error(f"Error in news search: {e}")
228
228
  raise e
229
229
 
230
230
  @app.command()
231
- @option("--keywords", "-k", help="Search keywords")
231
+ @option("--keywords", "-k", help="Search keywords", required=True)
232
232
  @option("--place", "-p", help="Simplified search - if set, the other parameters are not used")
233
233
  @option("--street", "-s", help="House number/street")
234
234
  @option("--city", "-c", help="City of search")
@@ -259,7 +259,7 @@ def maps(
259
259
  """Perform a maps search using DuckDuckGo API."""
260
260
  webs = WEBS(proxy=proxy)
261
261
  try:
262
- webs.maps(
262
+ results = webs.maps(
263
263
  keywords,
264
264
  place,
265
265
  street,
@@ -273,12 +273,13 @@ def maps(
273
273
  radius,
274
274
  max_results,
275
275
  )
276
+ _print_data(results)
276
277
  except Exception as e:
277
278
  logger.error(f"Error in maps search: {e}")
278
279
  raise e
279
280
 
280
281
  @app.command()
281
- @option("--keywords", "-k", help="Text for translation")
282
+ @option("--keywords", "-k", help="Text for translation", required=True)
282
283
  @option("--from", "-f", help="Language to translate from (defaults automatically)")
283
284
  @option("--to", "-t", help="Language to translate to (default: 'en')", default="en")
284
285
  @option("--proxy", "-p", help="Proxy URL to use for requests")
@@ -286,35 +287,26 @@ def translate(keywords: str, from_: str, to: str, proxy: str = None):
286
287
  """Perform translation using DuckDuckGo API."""
287
288
  webs = WEBS(proxy=proxy)
288
289
  try:
289
- webs.translate(keywords, from_, to)
290
+ results = webs.translate(keywords, from_, to)
291
+ _print_data(results)
290
292
  except Exception as e:
291
293
  logger.error(f"Error in translation: {e}")
292
294
  raise e
293
295
 
294
296
  @app.command()
295
- @option("--keywords", "-k", help="Search keywords")
297
+ @option("--keywords", "-k", help="Search keywords", required=True)
296
298
  @option("--region", "-r", help="Region for search results", default="wt-wt")
297
299
  @option("--proxy", "-p", help="Proxy URL to use for requests")
298
300
  def suggestions(keywords: str, region: str, proxy: str = None):
299
301
  """Perform a suggestions search using DuckDuckGo API."""
300
302
  webs = WEBS(proxy=proxy)
301
303
  try:
302
- webs.suggestions(keywords, region)
304
+ results = webs.suggestions(keywords, region)
305
+ _print_data(results)
303
306
  except Exception as e:
304
307
  logger.error(f"Error in suggestions search: {e}")
305
308
  raise e
306
309
 
307
- @app.command()
308
- @option("--proxy", help="Proxy URL to use for requests")
309
- def interactive(proxy: str = None):
310
- """Start an interactive search session with AI-powered responses."""
311
- webs = WEBS(proxy=proxy)
312
- try:
313
- webs.interactive()
314
- except Exception as e:
315
- logger.error(f"Error in interactive mode: {e}")
316
- raise e
317
-
318
310
  def main():
319
311
  """Main entry point for the CLI."""
320
312
  try:
@@ -324,4 +316,4 @@ def main():
324
316
  sys.exit(1)
325
317
 
326
318
  if __name__ == "__main__":
327
- main()
319
+ main()
@@ -69,25 +69,36 @@ from collections import defaultdict
69
69
  import shutil
70
70
  import inspect
71
71
  from .colors import Colors
72
+ import ctypes
72
73
 
74
+ # Checking Pygments availability
73
75
  try:
74
76
  from pygments import highlight
75
77
  from pygments.lexers import get_lexer_by_name
76
78
  from pygments.formatters import Terminal256Formatter
79
+
77
80
  PYGMENTS_AVAILABLE = True
78
81
  except ImportError:
79
82
  PYGMENTS_AVAILABLE = False
80
83
 
81
- # Enable UTF-8 output on Windows
84
+ # Enabling UTF-8 output on Windows
82
85
  if sys.platform == 'win32':
83
86
  import ctypes
87
+
84
88
  kernel32 = ctypes.windll.kernel32
85
89
  kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
86
- sys.stdout.reconfigure(encoding='utf-8')
87
90
 
88
- # Enable ANSI escape sequences for Windows
91
+ # Checking and overriding sys.stdout
92
+ try:
93
+ if sys.stdout is not None:
94
+ sys.stdout.reconfigure(encoding='utf-8')
95
+ else:
96
+ print("sys.stdout is not available.")
97
+ except AttributeError:
98
+ print("Failed to redefine sys.stdout.")
99
+
100
+ # Enabling ANSI escape sequences for Windows
89
101
  if os.name == 'nt':
90
- import ctypes
91
102
  kernel32 = ctypes.windll.kernel32
92
103
  kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
93
104
 
@@ -714,6 +725,4 @@ class LitPrinter:
714
725
 
715
726
  def _clear_line(self):
716
727
  """Clear the current line."""
717
- print('\r' + ' ' * self._get_terminal_width(), end='\r', file=self.file, flush=True)
718
-
719
-
728
+ print('\r' + ' ' * self._get_terminal_width(), end='\r', file=self.file, flush=True)
webscout/version.py CHANGED
@@ -1,2 +1,2 @@
1
- __version__ = "6.6"
1
+ __version__ = "6.7"
2
2
  __prog__ = "webscout"
@@ -180,7 +180,7 @@ class WEBS:
180
180
  )
181
181
  self._chat_vqd = resp.headers.get("x-vqd-4", "")
182
182
 
183
- data = ",".join(x for line in resp.text.rstrip("[DONE]LIMT_CVRSA\n").split("data:") if (x := line.strip()))
183
+ data = ",".join(line.strip() for line in resp.text.rstrip("[DONE]LIMT_CVRSA\n").split("data:") if line.strip())
184
184
  data = json_loads("[" + data + "]")
185
185
 
186
186
  results = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webscout
3
- Version: 6.6
3
+ Version: 6.7
4
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 and more
5
5
  Author: OEvortex
6
6
  Author-email: helpingai5@gmail.com
@@ -232,7 +232,7 @@ python -m webscout --help
232
232
  ```python
233
233
  from webscout import weather as w
234
234
  weather = w.get("Qazigund")
235
- w.print_weather(weather)
235
+ print(weather)
236
236
  ```
237
237
 
238
238
  ### 2. Weather ASCII
@@ -1321,12 +1321,6 @@ autollama.main(model_path, gguf_file)
1321
1321
  * The `model_path` in `autollama` is the Hugging Face model ID, and `gguf_file` is the GGUF file ID.
1322
1322
 
1323
1323
 
1324
- ## 🌐 `Webai` - Terminal GPT and an Open Interpreter
1325
-
1326
- ```bash
1327
- python -m webscout.webai webai --provider "phind" --rawdog
1328
- ```
1329
-
1330
1324
  <div align="center">
1331
1325
  <!-- Replace `#` with your actual links -->
1332
1326
  <a href="https://t.me/official_helpingai"><img alt="Telegram" src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white"></a>
@@ -6,7 +6,7 @@ webscout/DWEBS.py,sha256=GsKbaVgcxDC5eHtNjxr6r5uk3_8NhtxVG2dqJJVGqaI,18543
6
6
  webscout/LLM.py,sha256=essCz1nakJfmoKLJFguyJnba0HR4AfY6BVU0CEGDCcQ,16336
7
7
  webscout/__init__.py,sha256=eMlqim4Cnc-BLcegMaTtDb2NGt3n48E331IqLx125Mk,864
8
8
  webscout/__main__.py,sha256=pBm2E3ZZiMcCH37b1YCz7qKdKdX_i_S5En6fZDeJKFw,103
9
- webscout/cli.py,sha256=bLaSGs24wxfZlK37_WPPr1jjfbv50nfbxkeSkED0jX0,12456
9
+ webscout/cli.py,sha256=3AG2adVRirqKQMvXX312nswNBtRpmW9-2C16eAhfRd4,11994
10
10
  webscout/conversation.py,sha256=LMZWJVnyc1P5GLAzCLKvw6UU07nD3wA44l9sKh3nu8k,8763
11
11
  webscout/exceptions.py,sha256=10OLw5gFpfyGSSfAMRWT2OYCkdiEJR2byRv74kftAhc,11383
12
12
  webscout/optimizers.py,sha256=ALT4SeO_s_JV6yWG7XJJ3aZIoEiTN1PIaCZJtnGdxXs,10749
@@ -14,13 +14,13 @@ webscout/prompt_manager.py,sha256=Jc0demWN6M6QcwRp14aHZR05r_PVPOaG8PnQkO7pDZ4,98
14
14
  webscout/tempid.py,sha256=7ZTN2eAYqUO2deSdzzhZfgDRxE65OOhGuTBD7f8bTCM,5004
15
15
  webscout/update_checker.py,sha256=mLFD_OYjtEdUvXUiNt8wSbspmkFRmNlULf5sVyVZi60,5129
16
16
  webscout/utils.py,sha256=LVW7U0XcGYqigqxV6D5YXeGMrc_mt7PnNG_YnKf9bBM,3059
17
- webscout/version.py,sha256=cYDAQcJwn2Q6cNtta_6aXODo9AolQGHfZ9rNVaAiFzA,44
18
- webscout/webscout_search.py,sha256=HHdO9XLToC_9nIMM_SaTOKKfzdhrKjb7o8Zi3ZD1O7Y,44744
17
+ webscout/version.py,sha256=2LxYXNP6zbhOX47Xl9v4Dpp05K2LUel-8-Ayyzbaw-c,44
18
+ webscout/webscout_search.py,sha256=kFdcr3-2LaksTbFy9Pmrs_Gfi9XwtfxKKk5_H0hBa80,44748
19
19
  webscout/webscout_search_async.py,sha256=2-RCa9Deahhw3Bti78kXfVaX8y3Aygy4L7HeCaITk9M,14519
20
20
  webscout/Extra/__init__.py,sha256=FbDnwI3zZdoQFosA5Q2bIYpJlHUKFWiFmFKvnk9xWKY,153
21
21
  webscout/Extra/autollama.py,sha256=Mcj7YT8mYL5J7Rg_Wmi3Ppcfh1WK6UWcrbUZySetwuU,8198
22
22
  webscout/Extra/gguf.py,sha256=u_HQ00hiKCcF4GiVabUnFTXEPTmUpa2ADjBNHxtR7bw,16053
23
- webscout/Extra/weather.py,sha256=q-h5UXL2XEBEgoqvEeLRut-ThieNzH_GNfOEIeghKLM,6000
23
+ webscout/Extra/weather.py,sha256=XVi9fb7KZdUNaZjGzCHo8UIkK4v8-rWVfYuDiFbN8WY,5960
24
24
  webscout/Extra/weather_ascii.py,sha256=AsSJT6OCpg9vxzW5h7h0s0PEMq_m_ixvcc7VDtNERdw,793
25
25
  webscout/Extra/YTToolkit/YTdownloader.py,sha256=NfbukCKdyWycl9RzJBXzqSPKW6FwWe7EQxhfLf_dJj8,34793
26
26
  webscout/Extra/YTToolkit/__init__.py,sha256=Wn1K-f6OjZ4GuWvL3FTM4zlTaF3xdb4v_K60YDxKdXg,75
@@ -74,7 +74,7 @@ webscout/Provider/Koboldai.py,sha256=gpRgyDe4OQWwNqT7MWnNrJx4dnFmCW23KUx0Ezjgchk
74
74
  webscout/Provider/Llama.py,sha256=N01p3ZVD1HgRnNNxhjRhBVD4m_qiextdyF1KDfJlqbE,7703
75
75
  webscout/Provider/Llama3.py,sha256=fU1iyKflFHDeSqa32M6UE2JtADZB0B7rcG5HYj5MWSQ,7581
76
76
  webscout/Provider/Marcus.py,sha256=6LvBYnAcbwVYiXoQ8ZrprefJ6zS2KdveiEZauClNtSE,5045
77
- webscout/Provider/Netwrck.py,sha256=qRA8maK76zcTq3Lb3rstuBgKY0lWOk7KIwG4fXTHLPU,8364
77
+ webscout/Provider/Netwrck.py,sha256=TtW-W4oSGwf8JiMBXN6EBttQMA0tMaYvuYnRs0YNI68,9482
78
78
  webscout/Provider/NinjaChat.py,sha256=tMja5xItus6WoKJm_fhILLoGyPdplikqr-nxtuUziNU,8617
79
79
  webscout/Provider/OLLAMA.py,sha256=RQXJt-PJYnA15_IXhUy4mM9qwm4PcBMfINaZm2KG6zE,7018
80
80
  webscout/Provider/Openai.py,sha256=mpJ9VgIyvW6uo0-jIcx5Qcz4PIUAj3xVLOgKrB1z9pU,20074
@@ -103,7 +103,7 @@ webscout/Provider/lepton.py,sha256=4RiQ4YNJljX558yhSUqws6pf1Yhf7pWIesa4SRQCry8,7
103
103
  webscout/Provider/llama3mitril.py,sha256=3Ur3GMkmSSTmyxJh1u9fF0xlZ7ssFF6Jxuoi587N1lw,6501
104
104
  webscout/Provider/llamatutor.py,sha256=DijA4Y1CVDz-Ks8pACTSb6hnOxdQD2IHw-_ztRqhyPQ,8871
105
105
  webscout/Provider/llmchat.py,sha256=gr7ewEPWWIfjhmpQXTOZJxQffol8MA1yWAIXdG3VZZo,7944
106
- webscout/Provider/meta.py,sha256=N1Ia1iDADfk1QJUHb10Vq5UvObiybQsi5QlUoNVaY-M,30456
106
+ webscout/Provider/meta.py,sha256=3LkGoiGtorc28aURqIpdbMdrDt7QfdARpl1Fp7XNSIg,30460
107
107
  webscout/Provider/mhystical.py,sha256=W3j28XOnVGlRPCSYrjA5N7okYEdTVeOw41HdocfvzqE,6555
108
108
  webscout/Provider/multichat.py,sha256=c1TFCGv3Ds06mO5eYl_6YmUjGkg_dkqh2weQpYYsc08,8415
109
109
  webscout/Provider/promptrefine.py,sha256=W0Ka59yRRKCOBXfF_hF-iF30F0AR45OPxgCCZ6mZzuA,7722
@@ -154,7 +154,7 @@ webscout/Provider/TTS/streamElements.py,sha256=0cfayE1eQYQj4ILF9tmHdodIcw9WknTKs
154
154
  webscout/Provider/TTS/utils.py,sha256=-2sXcGG1lDBIr32fssI1Tf9yxl7gMWZRM0xzUFebeko,10599
155
155
  webscout/Provider/TTS/voicepod.py,sha256=cMF7k88cP-RMqkqcoT8cu1o-eehxd2tqiq8laJeuMJw,4227
156
156
  webscout/litagent/__init__.py,sha256=V-hXEmMp3UH1qKmJDtL0j6_mazmbyyRrIqKqt__oIRw,6091
157
- webscout/litprinter/__init__.py,sha256=PGGakKwKXoKbt-hziQkeRXNfmBlpqZrO0evvFa643i8,28548
157
+ webscout/litprinter/__init__.py,sha256=3Hdtj0-YSdwNqxc_Uc_yZIv7gnsap4e4dvqni4CA9oY,28821
158
158
  webscout/litprinter/colors.py,sha256=5L_WmYFcp2JoX1rCS4GvFCNCOlj2EhEJRGWvqvs8M54,1247
159
159
  webscout/scout/__init__.py,sha256=C-uYGqVR7iiScetSxUTHc76i0OLQnWJO7WFTfhgafW4,325
160
160
  webscout/scout/core.py,sha256=Joiw1RTPse2VQOjF5y6Uksa_ixsUSIO58RLWnyx6gbU,28761
@@ -189,9 +189,9 @@ webstoken/stemmer.py,sha256=AYg1frOaS2CWF-KvFwh3_s-VMZUa0olM7CN1UaEpc-8,2551
189
189
  webstoken/t.py,sha256=jrgacr0xK8Xbc9BZNtMknZv2xQagg9eMO3MXwCvIIFE,2558
190
190
  webstoken/tagger.py,sha256=RgDxPw0E6VgeXTrAFnnOb4X2J2Hu3snafr-MJeWtHlc,2246
191
191
  webstoken/tokenizer.py,sha256=RAaihP3Yq4OFHcXrTNUGBDLbq1-ti_lVUEw0CIPPCww,5858
192
- webscout-6.6.dist-info/LICENSE.md,sha256=5mkWS6cgjGxJClmN7n--h0beF3uFAOV_Ngr1YTK33Tk,9203
193
- webscout-6.6.dist-info/METADATA,sha256=Z2rc2q-RPXJgG3-EbRKWRIMoxjoomQkH78SFl6rsa-A,40862
194
- webscout-6.6.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
195
- webscout-6.6.dist-info/entry_points.txt,sha256=Hh4YIIjvkqB9SVxZ2ri4DZUkgEu_WF_5_r_nZDIvfG8,73
196
- webscout-6.6.dist-info/top_level.txt,sha256=KQtbgkA3gxcsADB0hIIx-heydmEYXpAY7xn3LjwDx0E,19
197
- webscout-6.6.dist-info/RECORD,,
192
+ webscout-6.7.dist-info/LICENSE.md,sha256=5mkWS6cgjGxJClmN7n--h0beF3uFAOV_Ngr1YTK33Tk,9203
193
+ webscout-6.7.dist-info/METADATA,sha256=NaQoy4zNP_3FPsgqqCkP1FzMoy5KsUS9vb5TjSP38Sc,40718
194
+ webscout-6.7.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
195
+ webscout-6.7.dist-info/entry_points.txt,sha256=7thMsVUoHiXGoIH1NeoocKpxlszWflNsNyrnDqGzvO0,70
196
+ webscout-6.7.dist-info/top_level.txt,sha256=KQtbgkA3gxcsADB0hIIx-heydmEYXpAY7xn3LjwDx0E,19
197
+ webscout-6.7.dist-info/RECORD,,
@@ -1,3 +1,3 @@
1
1
  [console_scripts]
2
2
  WEBS = webscout.cli:cli
3
- webscout = webscout.webai:main
3
+ webscout = webscout.cli:cli
File without changes