webscout 6.1__py3-none-any.whl → 6.2__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 (48) hide show
  1. webscout/AIauto.py +77 -259
  2. webscout/Agents/functioncall.py +2 -2
  3. webscout/Extra/autollama.py +37 -20
  4. webscout/Local/formats.py +4 -2
  5. webscout/Local/utils.py +37 -12
  6. webscout/Provider/Amigo.py +50 -37
  7. webscout/Provider/Deepseek.py +7 -6
  8. webscout/Provider/EDITEE.py +2 -2
  9. webscout/Provider/GPTWeb.py +1 -1
  10. webscout/Provider/Llama3.py +1 -1
  11. webscout/Provider/NinjaChat.py +2 -2
  12. webscout/Provider/OLLAMA.py +1 -1
  13. webscout/Provider/Perplexity.py +1 -1
  14. webscout/Provider/Reka.py +12 -5
  15. webscout/Provider/TTI/AIuncensored.py +103 -0
  16. webscout/Provider/TTI/__init__.py +3 -2
  17. webscout/Provider/TTI/talkai.py +116 -0
  18. webscout/Provider/TeachAnything.py +0 -3
  19. webscout/Provider/__init__.py +8 -11
  20. webscout/Provider/cerebras.py +143 -123
  21. webscout/Provider/cleeai.py +1 -1
  22. webscout/Provider/felo_search.py +1 -1
  23. webscout/Provider/gaurish.py +41 -2
  24. webscout/Provider/geminiprorealtime.py +1 -1
  25. webscout/Provider/genspark.py +1 -1
  26. webscout/Provider/julius.py +4 -3
  27. webscout/Provider/learnfastai.py +1 -1
  28. webscout/Provider/{aigames.py → llmchat.py} +74 -84
  29. webscout/Provider/promptrefine.py +3 -1
  30. webscout/Provider/talkai.py +196 -0
  31. webscout/Provider/turboseek.py +3 -8
  32. webscout/Provider/tutorai.py +1 -1
  33. webscout/__init__.py +2 -43
  34. webscout/tempid.py +4 -73
  35. webscout/version.py +1 -1
  36. webscout/webai.py +1 -1
  37. {webscout-6.1.dist-info → webscout-6.2.dist-info}/METADATA +44 -128
  38. {webscout-6.1.dist-info → webscout-6.2.dist-info}/RECORD +42 -45
  39. webscout/Provider/BasedGPT.py +0 -214
  40. webscout/Provider/ChatHub.py +0 -209
  41. webscout/Provider/TTI/amigo.py +0 -148
  42. webscout/Provider/bixin.py +0 -264
  43. webscout/Provider/xdash.py +0 -182
  44. webscout/websx_search.py +0 -19
  45. {webscout-6.1.dist-info → webscout-6.2.dist-info}/LICENSE.md +0 -0
  46. {webscout-6.1.dist-info → webscout-6.2.dist-info}/WHEEL +0 -0
  47. {webscout-6.1.dist-info → webscout-6.2.dist-info}/entry_points.txt +0 -0
  48. {webscout-6.1.dist-info → webscout-6.2.dist-info}/top_level.txt +0 -0
@@ -1,214 +0,0 @@
1
- import requests
2
- import json
3
- from webscout.AIutel import Optimizers
4
- from webscout.AIutel import Conversation
5
- from webscout.AIutel import AwesomePrompts, sanitize_stream
6
- from webscout.AIbase import Provider, AsyncProvider
7
- from webscout import exceptions
8
- from typing import Any, AsyncGenerator, Dict
9
-
10
-
11
- class BasedGPT(Provider):
12
- def __init__(
13
- self,
14
- is_conversation: bool = True,
15
- max_tokens: int = 600,
16
- timeout: int = 30,
17
- intro: str = None,
18
- filepath: str = None,
19
- update_file: bool = True,
20
- proxies: dict = {},
21
- history_offset: int = 10250,
22
- act: str = None,
23
- model: str = "gpt-3.5-turbo"
24
- ):
25
- """Instantiates BasedGPT
26
-
27
- Args:
28
- is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
29
- max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
30
- timeout (int, optional): Http request timeout. Defaults to 30.
31
- intro (str, optional): Conversation introductory prompt. Defaults to None.
32
- filepath (str, optional): Path to file containing conversation history. Defaults to None.
33
- update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
34
- proxies (dict, optional): Http request proxies. Defaults to {}.
35
- history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
36
- act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
37
- model (str, optional): Model to use for generating text. Defaults to "gpt-3.5-turbo".
38
- """
39
- self.session = requests.Session()
40
- self.is_conversation = is_conversation
41
- self.max_tokens_to_sample = max_tokens
42
- self.chat_endpoint = "https://www.basedgpt.chat/api/chat"
43
- self.timeout = timeout
44
- self.last_response = {}
45
- self.model = model
46
- self.headers = {
47
- "accept": "*/*",
48
- "accept-encoding": "gzip, deflate, br, zstd",
49
- "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
50
- "content-length": "109",
51
- "content-type": "application/json",
52
- "dnt": "1",
53
- "origin": "https://www.basedgpt.chat",
54
- "priority": "u=1, i",
55
- "referer": "https://www.basedgpt.chat/",
56
- "sec-ch-ua": '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
57
- "sec-ch-ua-mobile": "?0",
58
- "sec-ch-ua-platform": '"Windows"',
59
- "sec-fetch-dest": "empty",
60
- "sec-fetch-mode": "cors",
61
- "sec-fetch-site": "same-origin",
62
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0"
63
- }
64
-
65
- self.__available_optimizers = (
66
- method
67
- for method in dir(Optimizers)
68
- if callable(getattr(Optimizers, method)) and not method.startswith("__")
69
- )
70
- self.session.headers.update(self.headers)
71
- Conversation.intro = (
72
- AwesomePrompts().get_act(
73
- act, raise_not_found=True, default=None, case_insensitive=True
74
- )
75
- if act
76
- else intro or Conversation.intro
77
- )
78
- self.conversation = Conversation(
79
- is_conversation, self.max_tokens_to_sample, filepath, update_file
80
- )
81
- self.conversation.history_offset = history_offset
82
- self.session.proxies = proxies
83
-
84
- def ask(
85
- self,
86
- prompt: str,
87
- stream: bool = False,
88
- raw: bool = False,
89
- optimizer: str = None,
90
- conversationally: bool = False,
91
- ) -> dict:
92
- """Chat with AI
93
-
94
- Args:
95
- prompt (str): Prompt to be send.
96
- stream (bool, optional): Flag for streaming response. Defaults to False.
97
- raw (bool, optional): Stream back raw response as received. Defaults to False.
98
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
99
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
100
- Returns:
101
- dict : {}
102
- ```json
103
- {
104
- "text" : "How may I assist you today?"
105
- }
106
- ```
107
- """
108
- conversation_prompt = self.conversation.gen_complete_prompt(prompt)
109
- if optimizer:
110
- if optimizer in self.__available_optimizers:
111
- conversation_prompt = getattr(Optimizers, optimizer)(
112
- conversation_prompt if conversationally else prompt
113
- )
114
- else:
115
- raise Exception(
116
- f"Optimizer is not one of {self.__available_optimizers}"
117
- )
118
-
119
- self.session.headers.update(self.headers)
120
- payload = {
121
- "messages": [
122
- {
123
- "role": "user",
124
- "content": conversation_prompt
125
- }
126
- ]
127
- }
128
-
129
- def for_stream():
130
- response = self.session.post(
131
- self.chat_endpoint, json=payload, stream=True, timeout=self.timeout
132
- )
133
- if not response.ok:
134
- raise Exception(
135
- f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
136
- )
137
-
138
- streaming_text = ""
139
- for value in response.iter_lines(
140
- decode_unicode=True,
141
- chunk_size=64,
142
- delimiter="\n",
143
- ):
144
- try:
145
- if bool(value):
146
- streaming_text += value + ("\n" if stream else "")
147
- resp = dict(text=streaming_text)
148
- self.last_response.update(resp)
149
- yield value if raw else resp
150
- except json.decoder.JSONDecodeError:
151
- pass
152
- self.conversation.update_chat_history(
153
- prompt, self.get_message(self.last_response)
154
- )
155
-
156
- def for_non_stream():
157
- for _ in for_stream():
158
- pass
159
- return self.last_response
160
-
161
- return for_stream() if stream else for_non_stream()
162
-
163
- def chat(
164
- self,
165
- prompt: str,
166
- stream: bool = False,
167
- optimizer: str = None,
168
- conversationally: bool = False,
169
- ) -> str:
170
- """Generate response `str`
171
- Args:
172
- prompt (str): Prompt to be send.
173
- stream (bool, optional): Flag for streaming response. Defaults to False.
174
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
175
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
176
- Returns:
177
- str: Response generated
178
- """
179
-
180
- def for_stream():
181
- for response in self.ask(
182
- prompt, True, optimizer=optimizer, conversationally=conversationally
183
- ):
184
- yield self.get_message(response)
185
-
186
- def for_non_stream():
187
- return self.get_message(
188
- self.ask(
189
- prompt,
190
- False,
191
- optimizer=optimizer,
192
- conversationally=conversationally,
193
- )
194
- )
195
-
196
- return for_stream() if stream else for_non_stream()
197
-
198
- def get_message(self, response: dict) -> str:
199
- """Retrieves message only from response
200
-
201
- Args:
202
- response (dict): Response generated by `self.ask`
203
-
204
- Returns:
205
- str: Message extracted
206
- """
207
- assert isinstance(response, dict), "Response should be of dict data-type only"
208
- return response["text"]
209
- if __name__ == '__main__':
210
- from rich import print
211
- ai = BasedGPT()
212
- response = ai.chat("tell me about india")
213
- for chunk in response:
214
- print(chunk, end="", flush=True)
@@ -1,209 +0,0 @@
1
- import requests
2
- import json
3
- import os
4
- from typing import Any, Dict, Optional, Generator, List, Union
5
-
6
- from webscout.AIutel import Optimizers
7
- from webscout.AIutel import Conversation
8
- from webscout.AIutel import AwesomePrompts, sanitize_stream
9
- from webscout.AIbase import Provider, AsyncProvider
10
- from webscout import exceptions
11
-
12
- class ChatHub(Provider):
13
- """
14
- A class to interact with the ChatHub API.
15
- """
16
-
17
- AVAILABLE_MODELS = [
18
- 'meta/llama3.1-8b',
19
- 'mistral/mixtral-8x7b',
20
- 'google/gemma-2',
21
- 'perplexity/sonar-online',
22
- ]
23
- model_aliases = { # Aliases for shorter model names
24
- "llama3.1-8b": 'meta/llama3.1-8b',
25
- "mixtral-8x7b": 'mistral/mixtral-8x7b',
26
- "gemma-2": 'google/gemma-2',
27
- "sonar-online": 'perplexity/sonar-online',
28
- }
29
-
30
-
31
- def __init__(
32
- self,
33
- is_conversation: bool = True,
34
- max_tokens: int = 2049,
35
- timeout: int = 30,
36
- intro: str = None,
37
- filepath: str = None,
38
- update_file: bool = True,
39
- proxies: dict = {},
40
- history_offset: int = 10250,
41
- act: str = None,
42
- model: str = "sonar-online",
43
- ):
44
- """Initializes the ChatHub API client."""
45
- self.url = "https://app.chathub.gg"
46
- self.api_endpoint = "https://app.chathub.gg/api/v3/chat/completions"
47
- self.headers = {
48
- 'Accept': '*/*',
49
- 'Accept-Language': 'en-US,en;q=0.9',
50
- 'Content-Type': 'application/json',
51
- 'Origin': self.url,
52
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36',
53
- 'X-App-Id': 'web'
54
- }
55
- self.session = requests.Session()
56
- self.session.headers.update(self.headers)
57
- self.session.proxies.update(proxies)
58
- self.timeout = timeout
59
- self.last_response = {}
60
-
61
- self.is_conversation = is_conversation
62
- self.max_tokens_to_sample = max_tokens
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
-
76
- self.conversation = Conversation(
77
- is_conversation, self.max_tokens_to_sample, filepath, update_file
78
- )
79
- self.conversation.history_offset = history_offset
80
-
81
- #Resolve the model
82
- self.model = self.get_model(model)
83
-
84
-
85
- def get_model(self, model: str) -> str:
86
- """
87
- Resolves the model name using aliases or defaults.
88
- """
89
-
90
- if model in self.AVAILABLE_MODELS:
91
- return model
92
- elif model in self.model_aliases:
93
- return self.model_aliases[model]
94
- else:
95
- print(f"Model '{model}' not found. Using default model '{self.default_model}'.")
96
- return self.default_model # Use class-level default
97
-
98
- def ask(
99
- self,
100
- prompt: str,
101
- stream: bool = False,
102
- raw: bool = False,
103
- optimizer: str = None,
104
- conversationally: bool = False,
105
- ) -> Union[Dict[str, Any], Generator]:
106
-
107
- conversation_prompt = self.conversation.gen_complete_prompt(prompt)
108
- if optimizer:
109
- if optimizer in self.__available_optimizers:
110
- conversation_prompt = getattr(Optimizers, optimizer)(
111
- conversation_prompt if conversationally else prompt
112
- )
113
- else:
114
- raise Exception(f"Optimizer is not one of {self.__available_optimizers}")
115
-
116
-
117
- data = {
118
- "model": self.model,
119
- "messages": [{"role": "user", "content": conversation_prompt}],
120
- "tools": []
121
- }
122
-
123
- # Set the Referer header dynamically based on the resolved model
124
- self.headers['Referer'] = f"{self.url}/chat/{self.model}"
125
-
126
-
127
- def for_stream():
128
- try:
129
- with requests.post(self.api_endpoint, headers=self.headers, json=data, stream=True, timeout=self.timeout) as response:
130
- response.raise_for_status()
131
- streaming_text = ""
132
-
133
- for line in response.iter_lines(decode_unicode=True):
134
- if line:
135
- decoded_line = line.strip()
136
- if decoded_line.startswith('data:'):
137
- data_str = decoded_line[5:].strip()
138
- if data_str == '[DONE]':
139
- break
140
- try:
141
- data_json = json.loads(data_str)
142
- text_delta = data_json.get('textDelta')
143
- if text_delta:
144
- streaming_text += text_delta
145
- resp = dict(text=text_delta)
146
- yield resp if raw else resp
147
-
148
- except json.JSONDecodeError:
149
- continue
150
- self.conversation.update_chat_history(prompt, streaming_text)
151
- self.last_response.update({"text": streaming_text})
152
- except requests.exceptions.RequestException as e:
153
- raise exceptions.FailedToGenerateResponseError(f"Request error: {e}")
154
-
155
-
156
- def for_non_stream():
157
- for _ in for_stream():
158
- pass
159
- return self.last_response
160
-
161
- return for_stream() if stream else for_non_stream()
162
-
163
-
164
-
165
-
166
- def chat(
167
- self,
168
- prompt: str,
169
- stream: bool = False,
170
- optimizer: str = None,
171
- conversationally: bool = False,
172
- ) -> Union[str, Generator]:
173
- """Generate response `str`"""
174
-
175
- def for_stream():
176
- for response in self.ask(
177
- prompt, stream=True, optimizer=optimizer, conversationally=conversationally
178
- ):
179
- yield self.get_message(response)
180
-
181
- def for_non_stream():
182
- return self.get_message(
183
- self.ask(
184
- prompt,
185
- stream=False, # Pass stream=False
186
- optimizer=optimizer,
187
- conversationally=conversationally,
188
- )
189
- )
190
-
191
- return for_stream() if stream else for_non_stream()
192
-
193
-
194
-
195
- def get_message(self, response: dict) -> str:
196
- """Retrieves message only from response"""
197
- assert isinstance(response, dict), "Response should be of dict data-type only"
198
- return response.get("text", "")
199
-
200
-
201
- if __name__ == "__main__":
202
- from rich import print
203
- bot = ChatHub()
204
- try:
205
- response = bot.chat("who is Abhay koul in AI", stream=True)
206
- for chunk in response:
207
- print(chunk, end="", flush=True)
208
- except Exception as e:
209
- print(f"An error occurred: {e}")
@@ -1,148 +0,0 @@
1
- import requests
2
- import json
3
- import uuid
4
- import os
5
- from typing import List
6
-
7
- from webscout.AIbase import ImageProvider
8
-
9
- class AmigoImager(ImageProvider):
10
- """
11
- Image provider for AmigoChat.io.
12
- """
13
- AVAILABLE_MODELS = ["dalle-e-3", "flux-pro", "flux-realism"]
14
- def __init__(self, timeout: int = 60, proxies: dict = {}):
15
- """Initializes the AmigoImager class.
16
-
17
- Args:
18
- timeout (int, optional): HTTP request timeout in seconds. Defaults to 60.
19
- proxies (dict, optional): HTTP request proxies. Defaults to {}.
20
- """
21
- self.url = "https://api.amigochat.io/v1/images/generations"
22
- self.headers = {
23
- "Accept": "*/*",
24
- "Accept-Encoding": "gzip, deflate, br, zstd",
25
- "Accept-Language": "en-US,en;q=0.9,en-IN;q=0.8",
26
- "Authorization": "Bearer ", # Empty
27
- "Content-Type": "application/json; charset=utf-8",
28
- "DNT": "1",
29
- "Origin": "https://amigochat.io",
30
- "Referer": "https://amigochat.io/",
31
- "Sec-CH-UA": '"Microsoft Edge";v="129", "Not=A?Brand";v="8", "Chromium";v="129"',
32
- "Sec-CH-UA-Mobile": "?0",
33
- "Sec-CH-UA-Platform": '"Windows"',
34
- "Sec-Fetch-Dest": "empty",
35
- "Sec-Fetch-Mode": "cors",
36
- "Sec-Fetch-Site": "same-site",
37
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0",
38
- "X-Device-Language": "en-US",
39
- "X-Device-Platform": "web",
40
- "X-Device-UUID": str(uuid.uuid4()),
41
- "X-Device-Version": "1.0.22"
42
- }
43
- self.session = requests.Session()
44
- self.session.headers.update(self.headers)
45
- self.session.proxies.update(proxies)
46
- self.timeout = timeout
47
- self.prompt: str = "AI-generated image - webscout"
48
- self.image_extension: str = "png"
49
-
50
- def generate(self, prompt: str, amount: int = 1, model: str = "flux-pro") -> List[str]:
51
- """Generate image from prompt
52
-
53
- Args:
54
- prompt (str): Image description.
55
- amount (int, optional): Total images to be generated. Defaults to 1.
56
- model (str, optional): Model to use for generating images. Defaults to "flux-pro".
57
-
58
- Returns:
59
- List[str]: List of generated image URLs.
60
- """
61
- assert bool(prompt), "Prompt cannot be null"
62
- assert isinstance(amount, int), f"Amount should be an integer only not {type(amount)}"
63
- assert amount > 0, "Amount should be greater than 0"
64
- assert model in self.AVAILABLE_MODELS, f"Model should be one of {self.AVAILABLE_MODELS}"
65
-
66
- self.prompt = prompt
67
- response = []
68
-
69
- for _ in range(amount):
70
- # JSON payload for the request
71
- payload = {
72
- "prompt": prompt,
73
- "model": model,
74
- "personaId": "image-generator"
75
- }
76
-
77
- try:
78
- # Sending the POST request
79
- resp = requests.post(self.url, headers=self.headers, data=json.dumps(payload), timeout=self.timeout)
80
- resp.raise_for_status()
81
-
82
- # Process the response
83
- response_data = resp.json()
84
- image_url = response_data['data'][0]['url']
85
- response.append(image_url)
86
-
87
- except requests.exceptions.RequestException as e:
88
- print(f"An error occurred: {e}")
89
- raise
90
-
91
- return response
92
-
93
- def save(
94
- self,
95
- response: List[str], # List of image URLs
96
- name: str = None,
97
- dir: str = os.getcwd(),
98
- filenames_prefix: str = "",
99
- ) -> List[str]:
100
- """Save generated images
101
-
102
- Args:
103
- response (List[str]): List of generated image URLs.
104
- name (str): Filename for the images. Defaults to the last prompt.
105
- dir (str, optional): Directory for saving images. Defaults to os.getcwd().
106
- filenames_prefix (str, optional): String to be prefixed at each filename to be returned.
107
-
108
- Returns:
109
- List[str]: List of saved filenames.
110
- """
111
- assert isinstance(response, list), f"Response should be of {list} not {type(response)}"
112
- name = self.prompt if name is None else name
113
-
114
- filenames = []
115
- count = 0
116
- for img_url in response:
117
- def complete_path():
118
- count_value = "" if count == 0 else f"_{count}"
119
- return os.path.join(dir, name + count_value + "." + self.image_extension)
120
-
121
- while os.path.isfile(complete_path()):
122
- count += 1
123
-
124
- absolute_path_to_file = complete_path()
125
- filenames.append(filenames_prefix + os.path.split(absolute_path_to_file)[1])
126
-
127
- # Download and save the image
128
- try:
129
- img_response = requests.get(img_url, stream=True, timeout=self.timeout)
130
- img_response.raise_for_status()
131
-
132
- with open(absolute_path_to_file, "wb") as fh:
133
- for chunk in img_response.iter_content(chunk_size=8192):
134
- fh.write(chunk)
135
- except requests.exceptions.RequestException as e:
136
- print(f"An error occurred while downloading image from {img_url}: {e}")
137
- raise
138
-
139
- return filenames
140
-
141
- # Example usage
142
- if __name__ == "__main__":
143
- bot = AmigoImager()
144
- try:
145
- resp = bot.generate("A shiny red sports car speeding down a scenic mountain road", 1)
146
- print(bot.save(resp))
147
- except Exception as e:
148
- print(f"An error occurred: {e}")