webscout 6.8__py3-none-any.whl → 7.0__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 (45) hide show
  1. webscout/AIbase.py +12 -2
  2. webscout/DWEBS.py +38 -22
  3. webscout/Extra/YTToolkit/YTdownloader.py +7 -2
  4. webscout/Extra/YTToolkit/ytapi/channel.py +1 -1
  5. webscout/Extra/YTToolkit/ytapi/query.py +3 -0
  6. webscout/Extra/YTToolkit/ytapi/stream.py +3 -0
  7. webscout/Extra/YTToolkit/ytapi/video.py +3 -1
  8. webscout/Extra/autocoder/autocoder_utiles.py +68 -7
  9. webscout/Extra/autollama.py +0 -16
  10. webscout/Extra/gguf.py +0 -13
  11. webscout/Provider/AISEARCH/DeepFind.py +251 -0
  12. webscout/Provider/AISEARCH/__init__.py +2 -2
  13. webscout/Provider/AISEARCH/felo_search.py +167 -118
  14. webscout/Provider/Blackboxai.py +1 -1
  15. webscout/Provider/Glider.py +207 -0
  16. webscout/Provider/HF_space/__init__.py +0 -0
  17. webscout/Provider/HF_space/qwen_qwen2.py +206 -0
  18. webscout/Provider/TextPollinationsAI.py +201 -0
  19. webscout/Provider/Youchat.py +28 -22
  20. webscout/Provider/__init__.py +11 -3
  21. webscout/Provider/askmyai.py +2 -2
  22. webscout/Provider/cerebras.py +3 -3
  23. webscout/Provider/chatglm.py +205 -0
  24. webscout/Provider/dgaf.py +186 -0
  25. webscout/Provider/hermes.py +219 -0
  26. webscout/Provider/llmchat.py +1 -0
  27. webscout/__init__.py +0 -1
  28. webscout/litagent/__init__.py +3 -146
  29. webscout/litagent/agent.py +120 -0
  30. webscout/litagent/constants.py +31 -0
  31. webscout/swiftcli/__init__.py +1 -0
  32. webscout/tempid.py +0 -4
  33. webscout/version.py +1 -1
  34. webscout/webscout_search.py +1140 -1104
  35. webscout/webscout_search_async.py +635 -361
  36. {webscout-6.8.dist-info → webscout-7.0.dist-info}/METADATA +23 -39
  37. {webscout-6.8.dist-info → webscout-7.0.dist-info}/RECORD +41 -35
  38. {webscout-6.8.dist-info → webscout-7.0.dist-info}/WHEEL +1 -1
  39. webscout/Extra/markdownlite/__init__.py +0 -862
  40. webscout/Provider/AISEARCH/ooai.py +0 -155
  41. webscout/Provider/Deepseek.py +0 -227
  42. webscout/zerodir/__init__.py +0 -225
  43. {webscout-6.8.dist-info → webscout-7.0.dist-info}/LICENSE.md +0 -0
  44. {webscout-6.8.dist-info → webscout-7.0.dist-info}/entry_points.txt +0 -0
  45. {webscout-6.8.dist-info → webscout-7.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,205 @@
1
+ import requests
2
+ import json
3
+ from typing import Any, Dict, Optional, Generator, List, Union
4
+ import uuid
5
+
6
+ from webscout.AIutel import Optimizers
7
+ from webscout.AIutel import Conversation
8
+ from webscout.AIutel import AwesomePrompts
9
+ from webscout.AIbase import Provider
10
+ from webscout import exceptions
11
+
12
+
13
+ class ChatGLM(Provider):
14
+ """
15
+ A class to interact with the ChatGLM API.
16
+ """
17
+
18
+ def __init__(
19
+ self,
20
+ is_conversation: bool = True,
21
+ max_tokens: int = 600,
22
+ timeout: int = 30,
23
+ intro: str = None,
24
+ filepath: str = None,
25
+ update_file: bool = True,
26
+ proxies: dict = {},
27
+ history_offset: int = 10250,
28
+ act: str = None,
29
+ model: str = "all-tools-230b",
30
+ ):
31
+ """Initializes the ChatGLM API client."""
32
+ self.session = requests.Session()
33
+ self.is_conversation = is_conversation
34
+ self.max_tokens_to_sample = max_tokens
35
+ self.api_endpoint = "https://chatglm.cn/chatglm/mainchat-api/guest/stream"
36
+ self.stream_chunk_size = 64
37
+ self.timeout = timeout
38
+ self.last_response = {}
39
+ self.model = model
40
+ self.headers = {
41
+ 'Accept-Language': 'en-US,en;q=0.9',
42
+ 'App-Name': 'chatglm',
43
+ 'Authorization': 'undefined',
44
+ 'Content-Type': 'application/json',
45
+ 'Origin': 'https://chatglm.cn',
46
+ 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
47
+ 'X-App-Platform': 'pc',
48
+ 'X-App-Version': '0.0.1',
49
+ 'X-Device-Id': '', #Will be generated each time
50
+ 'Accept': 'text/event-stream',
51
+ }
52
+ self.__available_optimizers = (
53
+ method
54
+ for method in dir(Optimizers)
55
+ if callable(getattr(Optimizers, method)) and not method.startswith("__")
56
+ )
57
+ self.session.headers.update(self.headers)
58
+ Conversation.intro = (
59
+ AwesomePrompts().get_act(
60
+ act, raise_not_found=True, default=None, case_insensitive=True
61
+ )
62
+ if act
63
+ else intro or Conversation.intro
64
+ )
65
+ self.conversation = Conversation(
66
+ is_conversation, self.max_tokens_to_sample, filepath, update_file
67
+ )
68
+ self.conversation.history_offset = history_offset
69
+ self.session.proxies = proxies
70
+
71
+ def ask(
72
+ self,
73
+ prompt: str,
74
+ stream: bool = False,
75
+ raw: bool = False,
76
+ optimizer: str = None,
77
+ conversationally: bool = False,
78
+ ) -> Dict[str, Any] | Generator[Dict[str, Any], None, None]:
79
+ """Chat with AI
80
+ Args:
81
+ prompt (str): Prompt to be sent.
82
+ stream (bool, optional): Flag for streaming response. Defaults to False.
83
+ raw (bool, optional): Stream back raw response as received. Defaults to False.
84
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
85
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
86
+ Returns:
87
+ Union[Dict, Generator[Dict, None, None]]: Response generated
88
+ """
89
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
90
+ if optimizer:
91
+ if optimizer in self.__available_optimizers:
92
+ conversation_prompt = getattr(Optimizers, optimizer)(
93
+ conversation_prompt if conversationally else prompt
94
+ )
95
+ else:
96
+ raise exceptions.FailedToGenerateResponseError(
97
+ f"Optimizer is not one of {self.__available_optimizers}"
98
+ )
99
+ device_id = str(uuid.uuid4()).replace('-', '')
100
+ self.session.headers.update({'X-Device-Id': device_id})
101
+ payload = {
102
+ "assistant_id": "65940acff94777010aa6b796",
103
+ "conversation_id": "",
104
+ "meta_data": {
105
+ "if_plus_model": False,
106
+ "is_test": False,
107
+ "input_question_type": "xxxx",
108
+ "channel": "",
109
+ "draft_id": "",
110
+ "quote_log_id": "",
111
+ "platform": "pc",
112
+ },
113
+ "messages": [
114
+ {
115
+ "role": "user",
116
+ "content": [{"type": "text", "text": conversation_prompt}],
117
+ }
118
+ ],
119
+ }
120
+
121
+ def for_stream():
122
+ try:
123
+ with self.session.post(
124
+ self.api_endpoint, json=payload, stream=True, timeout=self.timeout
125
+ ) as response:
126
+ response.raise_for_status()
127
+
128
+ streaming_text = ""
129
+ last_processed_content = "" # Track the last processed content
130
+ for chunk in response.iter_lines():
131
+ if chunk:
132
+ decoded_chunk = chunk.decode('utf-8')
133
+ if decoded_chunk.startswith('data: '):
134
+ try:
135
+ json_data = json.loads(decoded_chunk[6:])
136
+ parts = json_data.get('parts', [])
137
+ if parts:
138
+ content = parts[0].get('content', [])
139
+ if content:
140
+ text = content[0].get('text', '')
141
+ new_text = text[len(last_processed_content):]
142
+ if new_text: # Check for new content
143
+ streaming_text += new_text
144
+ last_processed_content = text
145
+ yield new_text if raw else dict(text=new_text)
146
+ except json.JSONDecodeError:
147
+ continue
148
+
149
+ self.last_response.update(dict(text=streaming_text))
150
+ self.conversation.update_chat_history(
151
+ prompt, self.get_message(self.last_response)
152
+ )
153
+
154
+ except requests.exceptions.RequestException as e:
155
+ raise exceptions.ProviderConnectionError(f"Request failed: {e}")
156
+ except json.JSONDecodeError as e:
157
+ raise exceptions.InvalidResponseError(f"Failed to decode JSON: {e}")
158
+ except Exception as e:
159
+ raise exceptions.FailedToGenerateResponseError(f"An unexpected error occurred: {e}")
160
+
161
+ def for_non_stream():
162
+ for _ in for_stream():
163
+ pass
164
+ return self.last_response
165
+ return for_stream() if stream else for_non_stream()
166
+
167
+ def chat(
168
+ self,
169
+ prompt: str,
170
+ stream: bool = False,
171
+ optimizer: str = None,
172
+ conversationally: bool = False,
173
+ ) -> str | Generator[str, None, None]:
174
+ """Generate response `str`"""
175
+
176
+ def for_stream():
177
+ for response in self.ask(
178
+ prompt, True, optimizer=optimizer, conversationally=conversationally
179
+ ):
180
+ yield self.get_message(response)
181
+
182
+ def for_non_stream():
183
+ return self.get_message(
184
+ self.ask(
185
+ prompt,
186
+ False,
187
+ optimizer=optimizer,
188
+ conversationally=conversationally,
189
+ )
190
+ )
191
+
192
+ return for_stream() if stream else for_non_stream()
193
+
194
+ def get_message(self, response: dict) -> str:
195
+ """Retrieves message only from response"""
196
+ assert isinstance(response, dict), "Response should be of dict data-type only"
197
+ return response["text"]
198
+
199
+
200
+ if __name__ == "__main__":
201
+ from rich import print
202
+ ai = ChatGLM()
203
+ response = ai.chat(input(">>> "), stream=True)
204
+ for chunk in response:
205
+ print(chunk, end="", flush=True)
@@ -0,0 +1,186 @@
1
+ import requests
2
+ import re
3
+ import json
4
+ from typing import Any, Dict, Generator, Optional
5
+
6
+ from webscout.AIutel import Optimizers
7
+ from webscout.AIutel import Conversation
8
+ from webscout.AIutel import AwesomePrompts
9
+ from webscout.AIbase import Provider
10
+ from webscout import exceptions
11
+
12
+ class DGAFAI(Provider):
13
+ """
14
+ A class to interact with the DGAF.ai API.
15
+ """
16
+
17
+ def __init__(
18
+ self,
19
+ is_conversation: bool = True,
20
+ max_tokens: int = 600,
21
+ timeout: int = 30,
22
+ intro: str = None,
23
+ filepath: str = None,
24
+ update_file: bool = True,
25
+ proxies: dict = {},
26
+ history_offset: int = 10250,
27
+ act: str = None,
28
+ system_prompt: str = "You are a helpful AI assistant.",
29
+
30
+ ):
31
+ """Initializes the DGAFAI API client."""
32
+ self.session = requests.Session()
33
+ self.is_conversation = is_conversation
34
+ self.max_tokens_to_sample = max_tokens
35
+ self.api_endpoint = "https://www.dgaf.ai/api/chat"
36
+ self.stream_chunk_size = 64
37
+ self.timeout = timeout
38
+ self.last_response = {}
39
+ self.system_prompt = system_prompt
40
+ self.headers = {
41
+ "accept": "*/*",
42
+ "accept-encoding": "gzip, deflate, br, zstd",
43
+ "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
44
+ "content-type": "application/json",
45
+ "cookie": "_ga=GA1.1.1717609725.1738729535; _ga_52CD0XKYNM=GS1.1.1738729535.1.0.1738729546.0.0.0",
46
+ "dnt": "1",
47
+ "origin": "https://www.dgaf.ai",
48
+ "referer": "https://www.dgaf.ai/?via=topaitools",
49
+ "sec-ch-ua": '"Not A(Brand";v="8", "Chromium";v="132", "Microsoft Edge";v="132"',
50
+ "sec-ch-ua-mobile": "?0",
51
+ "sec-ch-ua-platform": '"Windows"',
52
+ "sec-fetch-dest": "empty",
53
+ "sec-fetch-mode": "cors",
54
+ "sec-fetch-site": "same-origin",
55
+ "user-agent": (
56
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
57
+ "AppleWebKit/537.36 (KHTML, like Gecko) "
58
+ "Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0"
59
+ ),
60
+ }
61
+ self.session.headers.update(self.headers)
62
+ self.session.proxies = proxies
63
+ self.__available_optimizers = (
64
+ method
65
+ for method in dir(Optimizers)
66
+ if callable(getattr(Optimizers, method)) and not method.startswith("__")
67
+ )
68
+ Conversation.intro = (
69
+ AwesomePrompts().get_act(
70
+ act, raise_not_found=True, default=None, case_insensitive=True
71
+ )
72
+ if act
73
+ else intro or Conversation.intro
74
+ )
75
+ self.conversation = Conversation(
76
+ is_conversation, self.max_tokens_to_sample, filepath, update_file
77
+ )
78
+ self.conversation.history_offset = history_offset
79
+
80
+ def ask(
81
+ self,
82
+ prompt: str,
83
+ stream: bool = False,
84
+ raw: bool = False,
85
+ optimizer: str = None,
86
+ conversationally: bool = False,
87
+ ) -> Dict[str, Any] | Generator[str, None, None]:
88
+ """Chat with AI
89
+ Args:
90
+ prompt (str): Prompt to be send.
91
+ stream (bool, optional): Flag for streaming response. Defaults to False.
92
+ raw (bool, optional): Stream back raw response as received. Defaults to False.
93
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
94
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
95
+ Returns:
96
+ Union[Dict, Generator[Dict, None, None]]: Response generated
97
+ """
98
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
99
+ if optimizer:
100
+ if optimizer in self.__available_optimizers:
101
+ conversation_prompt = getattr(Optimizers, optimizer)(
102
+ conversation_prompt if conversationally else prompt
103
+ )
104
+ else:
105
+ raise Exception(
106
+ f"Optimizer is not one of {self.__available_optimizers}"
107
+ )
108
+
109
+ payload = {
110
+ "messages": [
111
+ {"role": "system", "content": self.system_prompt},
112
+ {"role": "user", "content": conversation_prompt}
113
+ ]
114
+ }
115
+
116
+ def for_stream():
117
+ try:
118
+ with self.session.post(self.api_endpoint, headers=self.headers, json=payload, stream=True, timeout=self.timeout) as response:
119
+ response.raise_for_status() # Check for HTTP errors
120
+
121
+ streaming_text = ""
122
+ for line in response.iter_lines(decode_unicode=True):
123
+ if line:
124
+ match = re.search(r'0:"(.*?)"', line)
125
+ if match:
126
+ content = match.group(1)
127
+ if content:
128
+ streaming_text += content
129
+ yield content if raw else dict(text=content)
130
+
131
+ self.last_response.update(dict(text=streaming_text))
132
+ self.conversation.update_chat_history(
133
+ prompt, self.get_message(self.last_response)
134
+ )
135
+
136
+ except requests.exceptions.RequestException as e:
137
+ raise exceptions.ProviderConnectionError(f"Request failed: {e}")
138
+
139
+ def for_non_stream():
140
+ full_response = ""
141
+ for chunk in for_stream():
142
+ full_response += chunk if raw else chunk['text']
143
+ return {"text": full_response}
144
+
145
+ return for_stream() if stream else for_non_stream()
146
+
147
+ def chat(
148
+ self,
149
+ prompt: str,
150
+ stream: bool = False,
151
+ optimizer: str = None,
152
+ conversationally: bool = False,
153
+ ) -> str | Generator[str, None, None]:
154
+ """Generate response `str`"""
155
+ def for_stream():
156
+ for response in self.ask(
157
+ prompt, True, optimizer=optimizer, conversationally=conversationally
158
+ ):
159
+ yield self.get_message(response)
160
+ def for_non_stream():
161
+ return self.get_message(
162
+ self.ask(
163
+ prompt,
164
+ False,
165
+ optimizer=optimizer,
166
+ conversationally=conversationally,
167
+ )
168
+ )
169
+ return for_stream() if stream else for_non_stream()
170
+
171
+ def get_message(self, response: dict) -> str:
172
+ """Retrieves message only from response"""
173
+ assert isinstance(response, dict), "Response should be of dict data-type only"
174
+ return response["text"].replace('\\n', '\n').replace('\\n\\n', '\n\n')
175
+
176
+ # @staticmethod
177
+ # def clean_content(text: str) -> str:
178
+ # cleaned_text = re.sub(r'\[REF\]\(https?://[^\s]*\)', '', text)
179
+ # return cleaned_text
180
+
181
+ if __name__ == "__main__":
182
+ from rich import print
183
+ ai = DGAFAI()
184
+ response = ai.chat("write a poem about AI", stream=True)
185
+ for chunk in response:
186
+ print(chunk, end="", flush=True)
@@ -0,0 +1,219 @@
1
+ import requests
2
+ import json
3
+ from typing import Any, Dict, Generator, Optional
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
+ class NousHermes(Provider):
12
+ """
13
+ A class to interact with the Hermes API.
14
+ """
15
+
16
+ AVAILABLE_MODELS = ["Hermes-3-Llama-3.1-70B", "Hermes-3-Llama-3.1-8B"]
17
+
18
+ def __init__(
19
+ self,
20
+ cookies_path: str,
21
+ is_conversation: bool = True,
22
+ max_tokens: int = 8000,
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 = "Hermes-3-Llama-3.1-70B",
31
+ system_prompt: str = "You are a helpful AI assistant.",
32
+ temperature: float = 0.7,
33
+ top_p: float = 0.9,
34
+ ):
35
+ """Initializes the Hermes API client."""
36
+ if model not in self.AVAILABLE_MODELS:
37
+ raise ValueError(
38
+ f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}"
39
+ )
40
+
41
+ self.session = requests.Session()
42
+ self.is_conversation = is_conversation
43
+ self.max_tokens_to_sample = max_tokens
44
+ self.timeout = timeout
45
+ self.last_response = {}
46
+ self.model = model
47
+ self.system_prompt = system_prompt
48
+ self.api_endpoint = "https://hermes.nousresearch.com/api/chat"
49
+ self.temperature = temperature
50
+ self.top_p = top_p
51
+ self.cookies_path = cookies_path
52
+ self.cookies = self._load_cookies()
53
+ self.headers = {
54
+ 'accept': '*/*',
55
+ 'accept-language': 'en-US,en;q=0.9',
56
+ 'content-type': 'application/json',
57
+ 'origin': 'https://hermes.nousresearch.com',
58
+ 'referer': 'https://hermes.nousresearch.com/',
59
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36',
60
+ 'cookie': self.cookies
61
+ }
62
+
63
+ self.__available_optimizers = (
64
+ method
65
+ for method in dir(Optimizers)
66
+ if callable(getattr(Optimizers, method)) and not method.startswith("__")
67
+ )
68
+ self.session.headers.update(self.headers)
69
+ Conversation.intro = (
70
+ AwesomePrompts().get_act(
71
+ act, raise_not_found=True, default=None, case_insensitive=True
72
+ )
73
+ if act
74
+ else intro or Conversation.intro
75
+ )
76
+ self.conversation = Conversation(
77
+ is_conversation, self.max_tokens_to_sample, filepath, update_file
78
+ )
79
+ self.conversation.history_offset = history_offset
80
+ self.session.proxies = proxies
81
+
82
+ def _load_cookies(self) -> Optional[str]:
83
+ """Load cookies from a JSON file and convert them to a string."""
84
+ try:
85
+ with open(self.cookies_path, 'r') as f:
86
+ cookies_data = json.load(f)
87
+ return '; '.join([f"{cookie['name']}={cookie['value']}" for cookie in cookies_data])
88
+ except FileNotFoundError:
89
+ print("Error: cookies.json file not found!")
90
+ return None
91
+ except json.JSONDecodeError:
92
+ print("Error: Invalid JSON format in cookies.json!")
93
+ return None
94
+
95
+ def ask(
96
+ self,
97
+ prompt: str,
98
+ stream: bool = False,
99
+ raw: bool = False,
100
+ optimizer: str = None,
101
+ conversationally: bool = False,
102
+ ) -> Dict[str, Any] | Generator[Dict[str, Any], None, None]:
103
+ """Chat with AI
104
+ Args:
105
+ prompt (str): Prompt to be send.
106
+ stream (bool, optional): Flag for streaming response. Defaults to False.
107
+ raw (bool, optional): Stream back raw response as received. Defaults to False.
108
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
109
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
110
+ Returns:
111
+ dict|AsyncGenerator : ai content
112
+ ```json
113
+ {
114
+ "text" : "How may I assist you today?"
115
+ }
116
+ ```
117
+ """
118
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
119
+ if optimizer:
120
+ if optimizer in self.__available_optimizers:
121
+ conversation_prompt = getattr(Optimizers, optimizer)(
122
+ conversation_prompt if conversationally else prompt
123
+ )
124
+ else:
125
+ raise exceptions.FailedToGenerateResponseError(
126
+ f"Optimizer is not one of {self.__available_optimizers}"
127
+ )
128
+
129
+ payload = {
130
+ "messages": [{"role": "system", "content": self.system_prompt}, {"role": "user", "content": conversation_prompt}],
131
+ "model": self.model,
132
+ "max_tokens": self.max_tokens_to_sample,
133
+ "temperature": self.temperature,
134
+ "top_p": self.top_p,
135
+ }
136
+ def for_stream():
137
+ response = self.session.post(self.api_endpoint, headers=self.headers, json=payload, stream=True, timeout=self.timeout)
138
+ if not response.ok:
139
+ raise exceptions.FailedToGenerateResponseError(
140
+ f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
141
+ )
142
+ full_response = ""
143
+ for line in response.iter_lines():
144
+ if line:
145
+ decoded_line = line.decode('utf-8').replace('data: ', '')
146
+ try:
147
+ data = json.loads(decoded_line)
148
+ if data['type'] == 'llm_response':
149
+ content = data['content']
150
+ full_response += content
151
+ yield content if raw else dict(text=content)
152
+ except json.JSONDecodeError:
153
+ continue
154
+ self.last_response.update(dict(text=full_response))
155
+ self.conversation.update_chat_history(
156
+ prompt, self.get_message(self.last_response)
157
+ )
158
+
159
+ def for_non_stream():
160
+ for _ in for_stream():
161
+ pass
162
+ return self.last_response
163
+
164
+ return for_stream() if stream else for_non_stream()
165
+
166
+ def chat(
167
+ self,
168
+ prompt: str,
169
+ stream: bool = False,
170
+ optimizer: str = None,
171
+ conversationally: bool = False,
172
+ ) -> str | Generator[str, None, None]:
173
+ """Generate response `str`
174
+ Args:
175
+ prompt (str): Prompt to be send.
176
+ stream (bool, optional): Flag for streaming response. Defaults to False.
177
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
178
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
179
+ Returns:
180
+ str: Response generated
181
+ """
182
+
183
+ def for_stream():
184
+ for response in self.ask(
185
+ prompt, True, optimizer=optimizer, conversationally=conversationally
186
+ ):
187
+ yield self.get_message(response)
188
+
189
+ def for_non_stream():
190
+ return self.get_message(
191
+ self.ask(
192
+ prompt,
193
+ False,
194
+ optimizer=optimizer,
195
+ conversationally=conversationally,
196
+ )
197
+ )
198
+
199
+ return for_stream() if stream else for_non_stream()
200
+
201
+ def get_message(self, response: dict) -> str:
202
+ """Retrieves message only from response
203
+
204
+ Args:
205
+ response (dict): Response generated by `self.ask`
206
+
207
+ Returns:
208
+ str: Message extracted
209
+ """
210
+ assert isinstance(response, dict), "Response should be of dict data-type only"
211
+ return response["text"]
212
+
213
+
214
+ if __name__ == "__main__":
215
+ from rich import print
216
+ ai = NousHermes(cookies_path="cookies.json")
217
+ response = ai.chat(input(">>> "), stream=True)
218
+ for chunk in response:
219
+ print(chunk, end="", flush=True)
@@ -19,6 +19,7 @@ class LLMChat(Provider):
19
19
  "@cf/meta/llama-3.2-3b-instruct",
20
20
  "@cf/meta/llama-3.2-1b-instruct"
21
21
  "@cf/meta/llama-3.3-70b-instruct-fp8-fast"
22
+ "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b"
22
23
  ]
23
24
 
24
25
  def __init__(
webscout/__init__.py CHANGED
@@ -17,7 +17,6 @@ from .swiftcli import *
17
17
  from .litagent import LitAgent
18
18
  from .scout import *
19
19
  from .zeroart import *
20
- from .zerodir import *
21
20
  agent = LitAgent()
22
21
 
23
22
  __repo__ = "https://github.com/OE-LUCIFER/Webscout"