webscout 6.7__py3-none-any.whl → 6.9__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.

Files changed (43) hide show
  1. webscout/Extra/YTToolkit/YTdownloader.py +7 -2
  2. webscout/Extra/YTToolkit/ytapi/channel.py +1 -1
  3. webscout/Extra/YTToolkit/ytapi/query.py +3 -0
  4. webscout/Extra/YTToolkit/ytapi/stream.py +3 -0
  5. webscout/Extra/YTToolkit/ytapi/video.py +3 -1
  6. webscout/Provider/Cloudflare.py +2 -1
  7. webscout/Provider/DARKAI.py +2 -2
  8. webscout/Provider/Free2GPT.py +5 -5
  9. webscout/Provider/Marcus.py +3 -3
  10. webscout/Provider/PI.py +113 -47
  11. webscout/Provider/Phind.py +6 -0
  12. webscout/Provider/PizzaGPT.py +62 -53
  13. webscout/Provider/RUBIKSAI.py +93 -38
  14. webscout/Provider/__init__.py +0 -8
  15. webscout/Provider/cerebras.py +3 -3
  16. webscout/Provider/cleeai.py +2 -2
  17. webscout/Provider/elmo.py +2 -2
  18. webscout/Provider/gaurish.py +2 -2
  19. webscout/Provider/geminiprorealtime.py +2 -2
  20. webscout/Provider/lepton.py +2 -2
  21. webscout/Provider/llama3mitril.py +3 -3
  22. webscout/Provider/llamatutor.py +2 -2
  23. webscout/Provider/llmchat.py +3 -2
  24. webscout/Provider/meta.py +2 -2
  25. webscout/Provider/tutorai.py +1 -1
  26. webscout/__init__.py +0 -1
  27. webscout/swiftcli/__init__.py +1 -0
  28. webscout/version.py +1 -1
  29. webscout/webscout_search.py +1140 -1104
  30. webscout/webscout_search_async.py +635 -361
  31. {webscout-6.7.dist-info → webscout-6.9.dist-info}/METADATA +4 -32
  32. {webscout-6.7.dist-info → webscout-6.9.dist-info}/RECORD +36 -43
  33. webscout/Extra/markdownlite/__init__.py +0 -862
  34. webscout/Provider/Deepseek.py +0 -227
  35. webscout/Provider/Farfalle.py +0 -227
  36. webscout/Provider/NinjaChat.py +0 -200
  37. webscout/Provider/mhystical.py +0 -176
  38. webscout/zerodir/__init__.py +0 -225
  39. webstoken/t.py +0 -75
  40. {webscout-6.7.dist-info → webscout-6.9.dist-info}/LICENSE.md +0 -0
  41. {webscout-6.7.dist-info → webscout-6.9.dist-info}/WHEEL +0 -0
  42. {webscout-6.7.dist-info → webscout-6.9.dist-info}/entry_points.txt +0 -0
  43. {webscout-6.7.dist-info → webscout-6.9.dist-info}/top_level.txt +0 -0
@@ -1,176 +0,0 @@
1
- import requests
2
- import json
3
- from typing import Any, Dict, Optional, Generator, List
4
-
5
- from webscout.AIutel import Optimizers
6
- from webscout.AIutel import Conversation
7
- from webscout.AIutel import AwesomePrompts
8
- from webscout.AIbase import Provider
9
- from webscout import exceptions
10
-
11
-
12
- class Mhystical(Provider):
13
- """
14
- A class to interact with the Mhystical API. Improved to meet webscout provider standards.
15
- """
16
-
17
- AVAILABLE_MODELS = ["gpt-4", "gpt-3.5-turbo"] # Add available models
18
-
19
- def __init__(
20
- self,
21
- is_conversation: bool = True,
22
- max_tokens: int = 2048,
23
- timeout: int = 30,
24
- intro: str = None,
25
- filepath: str = None,
26
- update_file: bool = True,
27
- proxies: dict = {},
28
- history_offset: int = 10250,
29
- act: str = None,
30
- model: str = "gpt-4", # Default model
31
- system_prompt: str = "You are a helpful AI assistant." # Default system prompt
32
- ):
33
- """Initializes the Mhystical API."""
34
- if model not in self.AVAILABLE_MODELS:
35
- raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
36
-
37
- self.session = requests.Session()
38
- self.is_conversation = is_conversation
39
- self.max_tokens_to_sample = max_tokens
40
- self.api_endpoint = "https://api.mhystical.cc/v1/completions"
41
- self.timeout = timeout
42
- self.last_response = {}
43
- self.model = model
44
- self.system_prompt = system_prompt # Store system prompt
45
- self.headers = {
46
- "x-api-key": "mhystical", # Set API key in header (or better, in __init__ from parameter)
47
- "Content-Type": "application/json",
48
- "accept": "*/*",
49
- "user-agent": "Mozilla/5.0"
50
- }
51
- self.__available_optimizers = (
52
- method
53
- for method in dir(Optimizers)
54
- if callable(getattr(Optimizers, method)) and not method.startswith("__")
55
- )
56
- Conversation.intro = (
57
- AwesomePrompts().get_act(
58
- act, raise_not_found=True, default=None, case_insensitive=True
59
- )
60
- if act
61
- else intro or Conversation.intro
62
- )
63
- self.conversation = Conversation(
64
- is_conversation, self.max_tokens_to_sample, filepath, update_file
65
- )
66
- self.conversation.history_offset = history_offset
67
- self.session.proxies = proxies
68
-
69
-
70
- def ask(
71
- self,
72
- prompt: str,
73
- stream: bool = False,
74
- raw: bool = False,
75
- optimizer: str = None,
76
- conversationally: bool = False,
77
- ) -> Dict[str, Any] | Generator[Dict[str, Any], None, None]:
78
-
79
- conversation_prompt = self.conversation.gen_complete_prompt(prompt)
80
- if optimizer:
81
- if optimizer in self.__available_optimizers:
82
- conversation_prompt = getattr(Optimizers, optimizer)(
83
- conversation_prompt if conversationally else prompt
84
- )
85
- else:
86
- raise exceptions.FailedToGenerateResponseError(
87
- f"Optimizer is not one of {self.__available_optimizers}"
88
- )
89
-
90
- messages = [
91
- {"role": "system", "content": self.system_prompt}, # Include system prompt
92
- {"role": "user", "content": conversation_prompt},
93
- ]
94
-
95
- data = {
96
- "model": self.model, # Now using self.model
97
- "messages": messages # Pass messages to API
98
- }
99
-
100
- def for_stream():
101
- try:
102
- with requests.post(self.api_endpoint, headers=self.headers, json=data, stream=True, timeout=self.timeout) as response:
103
- response.raise_for_status() # Raise exceptions for HTTP errors
104
-
105
- # Emulate streaming for this API
106
- full_response = "" # Accumulate the full response
107
- for chunk in response.iter_content(decode_unicode=True, chunk_size=self.stream_chunk_size):
108
- if chunk:
109
- full_response += chunk
110
- yield chunk if raw else {"text": chunk}
111
-
112
- self.last_response.update({"text": full_response})
113
- self.conversation.update_chat_history(prompt, full_response)
114
- except requests.exceptions.RequestException as e:
115
- raise exceptions.ProviderConnectionError(f"Network error: {str(e)}")
116
-
117
- def for_non_stream():
118
- try:
119
- response = self.session.post(self.api_endpoint, headers=self.headers, json=data, timeout=self.timeout)
120
- response.raise_for_status()
121
-
122
- full_response = self._parse_response(response.text)
123
- self.last_response.update({"text": full_response})
124
-
125
- # Yield the entire response as a single chunk
126
- yield {"text": full_response}
127
-
128
- except requests.exceptions.RequestException as e:
129
- raise exceptions.ProviderConnectionError(f"Network error: {str(e)}")
130
-
131
- return for_stream() if stream else for_non_stream()
132
-
133
-
134
-
135
- def chat(
136
- self,
137
- prompt: str,
138
- stream: bool = False,
139
- optimizer: str = None,
140
- conversationally: bool = False,
141
- ) -> str | Generator[str, None, None]:
142
-
143
- def for_stream():
144
- for response in self.ask(
145
- prompt, stream=True, optimizer=optimizer, conversationally=conversationally
146
- ):
147
- yield self.get_message(response)
148
-
149
- def for_non_stream():
150
- response = next(self.ask(
151
- prompt, stream=False, optimizer=optimizer, conversationally=conversationally
152
- ))
153
- return self.get_message(response)
154
- return for_stream() if stream else for_non_stream()
155
-
156
-
157
-
158
- def get_message(self, response: dict) -> str:
159
- assert isinstance(response, dict), "Response should be of dict data-type only"
160
- return response["text"]
161
-
162
- @staticmethod
163
- def _parse_response(response_text: str) -> str:
164
- """Parse and validate API response."""
165
- try:
166
- data = json.loads(response_text)
167
- return data["choices"][0]["message"]["content"].strip()
168
- except (json.JSONDecodeError, KeyError, IndexError) as e:
169
- raise exceptions.InvalidResponseError(f"Failed to parse response: {str(e)}")
170
-
171
- if __name__ == "__main__":
172
- from rich import print
173
- ai = Mhystical()
174
- response = ai.chat(input(">>> "))
175
- for chunk in response:
176
- print(chunk, end="", flush=True)
@@ -1,225 +0,0 @@
1
- """
2
- ZeroDir: A zero-dependency app directories management library
3
-
4
- Provides cross-platform directory management for application data,
5
- configuration, and cache without external dependencies.
6
- """
7
-
8
- import os
9
- import sys
10
- import json
11
- import platform
12
- import tempfile
13
- import shutil
14
- import hashlib
15
- import time
16
- import datetime
17
-
18
- class ZeroDirs:
19
- def __init__(self, app_name, app_author=None):
20
- """
21
- Initialize ZeroDirs with application details
22
-
23
- :param app_name: Name of the application
24
- :param app_author: Author/Company name (optional)
25
- """
26
- self.app_name = app_name
27
- self.app_author = app_author or os.getlogin()
28
- self._init_dirs()
29
-
30
- def _init_dirs(self):
31
- """Initialize application directories"""
32
- self.user_data_dir = self._get_user_data_dir()
33
- self.user_config_dir = self._get_user_config_dir()
34
- self.user_cache_dir = self._get_user_cache_dir()
35
- self.user_log_dir = self._get_user_log_dir()
36
- self.temp_dir = self._get_temp_dir()
37
-
38
- # Create directories if they don't exist
39
- for directory in [
40
- self.user_data_dir,
41
- self.user_config_dir,
42
- self.user_cache_dir,
43
- self.user_log_dir,
44
- self.temp_dir
45
- ]:
46
- os.makedirs(directory, exist_ok=True)
47
-
48
- def _get_user_data_dir(self):
49
- """Get user data directory"""
50
- system = platform.system().lower()
51
- if system == 'windows':
52
- base = os.path.expandvars('%LOCALAPPDATA%')
53
- return os.path.join(base, self.app_author, self.app_name)
54
- elif system == 'darwin': # macOS
55
- return os.path.expanduser(f'~/Library/Application Support/{self.app_name}')
56
- else: # Linux and other Unix-like
57
- xdg_data_home = os.environ.get('XDG_DATA_HOME') or os.path.expanduser('~/.local/share')
58
- return os.path.join(xdg_data_home, self.app_name)
59
-
60
- def _get_user_config_dir(self):
61
- """Get user configuration directory"""
62
- system = platform.system().lower()
63
- if system == 'windows':
64
- base = os.path.expandvars('%APPDATA%')
65
- return os.path.join(base, self.app_author, self.app_name)
66
- elif system == 'darwin': # macOS
67
- return os.path.expanduser(f'~/Library/Preferences/{self.app_name}')
68
- else: # Linux and other Unix-like
69
- xdg_config_home = os.environ.get('XDG_CONFIG_HOME') or os.path.expanduser('~/.config')
70
- return os.path.join(xdg_config_home, self.app_name)
71
-
72
- def _get_user_cache_dir(self):
73
- """Get user cache directory"""
74
- system = platform.system().lower()
75
- if system == 'windows':
76
- base = os.path.expandvars('%LOCALAPPDATA%')
77
- return os.path.join(base, self.app_author, self.app_name, 'Cache')
78
- elif system == 'darwin': # macOS
79
- return os.path.expanduser(f'~/Library/Caches/{self.app_name}')
80
- else: # Linux and other Unix-like
81
- xdg_cache_home = os.environ.get('XDG_CACHE_HOME') or os.path.expanduser('~/.cache')
82
- return os.path.join(xdg_cache_home, self.app_name)
83
-
84
- def _get_user_log_dir(self):
85
- """Get user log directory"""
86
- system = platform.system().lower()
87
- if system == 'windows':
88
- base = os.path.expandvars('%LOCALAPPDATA%')
89
- return os.path.join(base, self.app_author, self.app_name, 'Logs')
90
- elif system == 'darwin': # macOS
91
- return os.path.expanduser(f'~/Library/Logs/{self.app_name}')
92
- else: # Linux and other Unix-like
93
- xdg_data_home = os.environ.get('XDG_DATA_HOME') or os.path.expanduser('~/.local/share')
94
- return os.path.join(xdg_data_home, self.app_name, 'logs')
95
-
96
- def _get_temp_dir(self):
97
- """Get temporary directory for the application"""
98
- return os.path.join(tempfile.gettempdir(), f'{self.app_name}_temp')
99
-
100
- def save_config(self, config_data, filename='config.json'):
101
- """
102
- Save configuration data to config directory
103
-
104
- :param config_data: Dictionary of configuration data
105
- :param filename: Name of the config file (default: config.json)
106
- :return: Path to saved config file
107
- """
108
- config_path = os.path.join(self.user_config_dir, filename)
109
- with open(config_path, 'w') as f:
110
- json.dump(config_data, f, indent=4)
111
- return config_path
112
-
113
- def load_config(self, filename='config.json'):
114
- """
115
- Load configuration data from config directory
116
-
117
- :param filename: Name of the config file (default: config.json)
118
- :return: Dictionary of configuration data or None if file doesn't exist
119
- """
120
- config_path = os.path.join(self.user_config_dir, filename)
121
- if os.path.exists(config_path):
122
- with open(config_path, 'r') as f:
123
- return json.load(f)
124
- return None
125
-
126
- def cache_file(self, content, filename=None, extension=None):
127
- """
128
- Cache a file with optional naming and extension
129
-
130
- :param content: File content or bytes
131
- :param filename: Optional custom filename
132
- :param extension: Optional file extension
133
- :return: Path to cached file
134
- """
135
- if not filename:
136
- # Generate a hash-based filename if not provided
137
- content_hash = hashlib.md5(str(content).encode()).hexdigest()
138
- filename = f'{content_hash}{extension or ""}'
139
-
140
- cache_path = os.path.join(self.user_cache_dir, filename)
141
-
142
- # Write content to file
143
- with open(cache_path, 'wb' if isinstance(content, bytes) else 'w') as f:
144
- f.write(content)
145
-
146
- return cache_path
147
-
148
- def clear_cache(self, max_age_days=30):
149
- """
150
- Clear cache directory, optionally removing files older than max_age_days
151
-
152
- :param max_age_days: Maximum age of files to keep (default: 30 days)
153
- :return: Number of files deleted
154
- """
155
- current_time = time.time()
156
-
157
- deleted_count = 0
158
- for filename in os.listdir(self.user_cache_dir):
159
- filepath = os.path.join(self.user_cache_dir, filename)
160
-
161
- # Check file age
162
- file_age_days = (current_time - os.path.getctime(filepath)) / (24 * 3600)
163
-
164
- if file_age_days > max_age_days:
165
- try:
166
- os.remove(filepath)
167
- deleted_count += 1
168
- except Exception:
169
- pass
170
-
171
- return deleted_count
172
-
173
- def log(self, message, filename='app.log', level='INFO'):
174
- """
175
- Log a message to the log directory
176
-
177
- :param message: Log message
178
- :param filename: Log filename (default: app.log)
179
- :param level: Log level (default: INFO)
180
- """
181
- log_path = os.path.join(self.user_log_dir, filename)
182
-
183
- with open(log_path, 'a') as log_file:
184
- timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
185
- log_file.write(f'[{level}] {timestamp}: {message}\n')
186
-
187
- def user_data_dir(app_name, app_author=None):
188
- """
189
- Quick function to get user data directory
190
-
191
- :param app_name: Name of the application
192
- :param app_author: Author/Company name (optional)
193
- :return: Path to user data directory
194
- """
195
- return ZeroDirs(app_name, app_author).user_data_dir
196
-
197
- def user_config_dir(app_name, app_author=None):
198
- """
199
- Quick function to get user config directory
200
-
201
- :param app_name: Name of the application
202
- :param app_author: Author/Company name (optional)
203
- :return: Path to user config directory
204
- """
205
- return ZeroDirs(app_name, app_author).user_config_dir
206
-
207
- def user_cache_dir(app_name, app_author=None):
208
- """
209
- Quick function to get user cache directory
210
-
211
- :param app_name: Name of the application
212
- :param app_author: Author/Company name (optional)
213
- :return: Path to user cache directory
214
- """
215
- return ZeroDirs(app_name, app_author).user_cache_dir
216
-
217
- def user_log_dir(app_name, app_author=None):
218
- """
219
- Quick function to get user log directory
220
-
221
- :param app_name: Name of the application
222
- :param app_author: Author/Company name (optional)
223
- :return: Path to user log directory
224
- """
225
- return ZeroDirs(app_name, app_author).user_log_dir
webstoken/t.py DELETED
@@ -1,75 +0,0 @@
1
- from webstoken import (
2
- process_text, NamedEntityRecognizer, TextClassifier,
3
- TopicClassifier, LanguageDetector, SentimentAnalyzer,
4
- KeywordExtractor
5
- )
6
- from rich import print
7
- # Example text
8
- text = """
9
- Dr. John Smith from Microsoft Corporation visited New York City on January 15th, 2024.
10
- He presented an excellent paper about artificial intelligence and machine learning at
11
- the International Technology Conference. The research was incredibly well-received,
12
- and many attendees were excited about its potential applications in healthcare.
13
- """
14
-
15
- print("1. Basic Text Processing")
16
- print("-" * 50)
17
- result = process_text(text)
18
- for sentence_data in result['sentences']:
19
- print("Original:", sentence_data['original'])
20
- print("Tokens:", sentence_data['tokens'])
21
- print("POS Tags:", sentence_data['pos_tags'])
22
- print("Stems:", sentence_data['stems'])
23
- print()
24
-
25
- print("\n2. Named Entity Recognition")
26
- print("-" * 50)
27
- ner = NamedEntityRecognizer()
28
- entities = ner.extract_entities(text)
29
- for entity_type, entity_list in entities.items():
30
- if entity_list:
31
- print(f"{entity_type}:", entity_list)
32
-
33
- print("\n3. Topic Classification")
34
- print("-" * 50)
35
- topic_classifier = TopicClassifier()
36
- topics = topic_classifier.classify(text)
37
- print("Topics (with confidence):")
38
- for topic, confidence in topics[:3]: # Top 3 topics
39
- print(f"{topic}: {confidence:.2f}")
40
-
41
- print("\n4. Language Detection")
42
- print("-" * 50)
43
- lang_detector = LanguageDetector()
44
- languages = lang_detector.detect(text)
45
- print("Detected Languages (with confidence):")
46
- for lang, confidence in languages:
47
- print(f"{lang}: {confidence:.2f}")
48
-
49
- print("\n5. Sentiment Analysis")
50
- print("-" * 50)
51
- sentiment_analyzer = SentimentAnalyzer()
52
- sentiment = sentiment_analyzer.analyze_sentiment(text)
53
- print("Sentiment Scores:")
54
- print(f"Polarity: {sentiment['polarity']:.2f}")
55
- print(f"Subjectivity: {sentiment['subjectivity']:.2f}")
56
- print(f"Confidence: {sentiment['confidence']:.2f}")
57
-
58
- print("\nEmotions:")
59
- emotions = sentiment_analyzer.analyze_emotions(text)
60
- for emotion, score in emotions:
61
- if score > 0.1: # Only show significant emotions
62
- print(f"{emotion}: {score:.2f}")
63
-
64
- print("\n6. Keyword Extraction")
65
- print("-" * 50)
66
- keyword_extractor = KeywordExtractor()
67
- print("Keywords:")
68
- keywords = keyword_extractor.extract_keywords(text, num_keywords=5)
69
- for keyword, score in keywords:
70
- print(f"{keyword}: {score:.2f}")
71
-
72
- print("\nKey Phrases:")
73
- keyphrases = keyword_extractor.extract_keyphrases(text, num_phrases=3)
74
- for phrase, score in keyphrases:
75
- print(f"{phrase}: {score:.2f}")
File without changes