webscout 4.7__py3-none-any.whl → 4.8__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/Agents/functioncall.py +97 -37
  2. webscout/Bard.py +365 -0
  3. webscout/Local/_version.py +1 -1
  4. webscout/Provider/Andi.py +7 -1
  5. webscout/Provider/BasedGPT.py +11 -5
  6. webscout/Provider/Berlin4h.py +11 -5
  7. webscout/Provider/Blackboxai.py +10 -4
  8. webscout/Provider/Cohere.py +11 -5
  9. webscout/Provider/DARKAI.py +25 -7
  10. webscout/Provider/Deepinfra.py +2 -1
  11. webscout/Provider/Deepseek.py +25 -9
  12. webscout/Provider/DiscordRocks.py +389 -0
  13. webscout/Provider/{ChatGPTUK.py → Farfalle.py} +80 -67
  14. webscout/Provider/Gemini.py +1 -1
  15. webscout/Provider/Groq.py +244 -110
  16. webscout/Provider/Llama.py +13 -5
  17. webscout/Provider/Llama3.py +15 -2
  18. webscout/Provider/OLLAMA.py +8 -7
  19. webscout/Provider/Perplexity.py +422 -52
  20. webscout/Provider/Phind.py +6 -5
  21. webscout/Provider/PizzaGPT.py +7 -1
  22. webscout/Provider/__init__.py +12 -31
  23. webscout/Provider/ai4chat.py +193 -0
  24. webscout/Provider/koala.py +11 -5
  25. webscout/Provider/{VTLchat.py → liaobots.py} +120 -104
  26. webscout/Provider/meta.py +2 -1
  27. webscout/version.py +1 -1
  28. webscout/webai.py +2 -64
  29. webscout/webscout_search.py +1 -1
  30. {webscout-4.7.dist-info → webscout-4.8.dist-info}/METADATA +227 -252
  31. {webscout-4.7.dist-info → webscout-4.8.dist-info}/RECORD +35 -40
  32. webscout/Provider/FreeGemini.py +0 -169
  33. webscout/Provider/Geminiflash.py +0 -152
  34. webscout/Provider/Geminipro.py +0 -152
  35. webscout/Provider/Leo.py +0 -469
  36. webscout/Provider/OpenGPT.py +0 -867
  37. webscout/Provider/Xjai.py +0 -230
  38. webscout/Provider/Yepchat.py +0 -478
  39. webscout/Provider/Youchat.py +0 -225
  40. {webscout-4.7.dist-info → webscout-4.8.dist-info}/LICENSE.md +0 -0
  41. {webscout-4.7.dist-info → webscout-4.8.dist-info}/WHEEL +0 -0
  42. {webscout-4.7.dist-info → webscout-4.8.dist-info}/entry_points.txt +0 -0
  43. {webscout-4.7.dist-info → webscout-4.8.dist-info}/top_level.txt +0 -0
webscout/Provider/Xjai.py DELETED
@@ -1,230 +0,0 @@
1
- import time
2
- import uuid
3
- from selenium import webdriver
4
- from selenium.webdriver.chrome.options import Options
5
- from selenium.webdriver.common.by import By
6
- from selenium.webdriver.support import expected_conditions as EC
7
- from selenium.webdriver.support.ui import WebDriverWait
8
- import click
9
- import requests
10
- from requests import get
11
- from uuid import uuid4
12
- from re import findall
13
- from requests.exceptions import RequestException
14
- from curl_cffi.requests import get, RequestsError
15
- import g4f
16
- from random import randint
17
- from PIL import Image
18
- import io
19
- import re
20
- import json
21
- import yaml
22
- from ..AIutel import Optimizers
23
- from ..AIutel import Conversation
24
- from ..AIutel import AwesomePrompts, sanitize_stream
25
- from ..AIbase import Provider, AsyncProvider
26
- from webscout import exceptions
27
- from typing import Any, AsyncGenerator, Dict
28
- import logging
29
- import httpx
30
- #-----------------------------------------------xjai-------------------------------------------
31
- class Xjai(Provider):
32
- def __init__(
33
- self,
34
- is_conversation: bool = True,
35
- max_tokens: int = 600,
36
- temperature: float = 0.8,
37
- top_p: float = 1,
38
- timeout: int = 30,
39
- intro: str = None,
40
- filepath: str = None,
41
- update_file: bool = True,
42
- proxies: dict = {},
43
- history_offset: int = 10250,
44
- act: str = None,
45
- ):
46
- """
47
- Initializes the Xjai class for interacting with the Xjai AI chat API.
48
-
49
- Args:
50
- is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
51
- max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
52
- temperature (float, optional): The creativity level of the AI's response. Defaults to 0.8.
53
- top_p (float, optional): The probability threshold for token selection. Defaults to 1.
54
- timeout (int, optional): Http request timeout. Defaults to 30.
55
- intro (str, optional): Conversation introductory prompt. Defaults to None.
56
- filepath (str, optional): Path to file containing conversation history. Defaults to None.
57
- update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
58
- proxies (dict, optional): Http request proxies. Defaults to {}.
59
- history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
60
- act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
61
- """
62
- self.session = requests.Session()
63
- self.is_conversation = is_conversation
64
- self.max_tokens_to_sample = max_tokens
65
- self.temperature = temperature
66
- self.top_p = top_p
67
- self.chat_endpoint = "https://p1api.xjai.pro/freeapi/chat-process"
68
- self.stream_chunk_size = 1 # Process response line by line
69
- self.timeout = timeout
70
- self.last_response = {}
71
-
72
- self.__available_optimizers = (
73
- method
74
- for method in dir(Optimizers)
75
- if callable(getattr(Optimizers, method)) and not method.startswith("__")
76
- )
77
- Conversation.intro = (
78
- AwesomePrompts().get_act(
79
- act, raise_not_found=True, default=None, case_insensitive=True
80
- )
81
- if act
82
- else intro or Conversation.intro
83
- )
84
- self.conversation = Conversation(
85
- is_conversation, self.max_tokens_to_sample, filepath, update_file
86
- )
87
- self.conversation.history_offset = history_offset
88
- self.session.proxies = proxies
89
-
90
- def ask(
91
- self,
92
- prompt: str,
93
- stream: bool = False,
94
- raw: bool = False,
95
- optimizer: str = None,
96
- conversationally: bool = False,
97
- ) -> Any:
98
- """
99
- Sends a chat request to the Xjai AI chat API and returns the response.
100
-
101
- Args:
102
- prompt (str): The query to send to the AI.
103
- stream (bool, optional): Flag for streaming response. Defaults to False.
104
- raw (bool, optional): Stream back raw response as received. Defaults to False.
105
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
106
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
107
-
108
- Returns:
109
- Any: The response from the AI, either as a dictionary or a generator
110
- depending on the `stream` and `raw` parameters.
111
- """
112
- conversation_prompt = self.conversation.gen_complete_prompt(prompt)
113
- if optimizer:
114
- if optimizer in self.__available_optimizers:
115
- conversation_prompt = getattr(Optimizers, optimizer)(
116
- conversation_prompt if conversationally else prompt
117
- )
118
- else:
119
- raise Exception(
120
- f"Optimizer is not one of {self.__available_optimizers}"
121
- )
122
-
123
- headers = {
124
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
125
- "(KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
126
- }
127
-
128
- payload = {
129
- "prompt": conversation_prompt + "\n\nReply in English Only",
130
- "systemMessage": "Reply in English Only",
131
- "temperature": self.temperature,
132
- "top_p": self.top_p
133
- }
134
-
135
- def generate_response():
136
- response = self.session.post(
137
- self.chat_endpoint, headers=headers, json=payload, stream=True, timeout=self.timeout
138
- )
139
- output = ""
140
- print_next = False
141
-
142
- for line in response.iter_lines(decode_unicode=True, chunk_size=self.stream_chunk_size):
143
- line_content = line.decode("utf-8")
144
- # Filter out irrelevant content
145
- if '[ChatAI](https://srv.aiflarepro.com/#/?cid=4111)' in line_content:
146
- continue
147
- if '&KFw6loC9Qvy&' in line_content:
148
- parts = line_content.split('&KFw6loC9Qvy&')
149
- if print_next:
150
- output += parts[0]
151
- print_next = False
152
- else:
153
- output += parts[1]
154
- print_next = True
155
- if len(parts) > 2:
156
- print_next = False
157
- elif print_next:
158
- output += line_content + '\n'
159
-
160
- # Update chat history
161
- self.conversation.update_chat_history(prompt, output)
162
-
163
- return output
164
-
165
- def for_stream():
166
- response = generate_response()
167
- for line in response.splitlines():
168
- yield line if raw else dict(text=line)
169
-
170
- def for_non_stream():
171
- response = generate_response()
172
- return response if raw else dict(text=response)
173
-
174
- return for_stream() if stream else for_non_stream()
175
-
176
- def chat(
177
- self,
178
- prompt: str,
179
- stream: bool = False,
180
- optimizer: str = None,
181
- conversationally: bool = False,
182
- ) -> Any:
183
- """
184
- Generates a response from the Xjai AI chat API.
185
-
186
- Args:
187
- prompt (str): The query to send to the AI.
188
- stream (bool, optional): Flag for streaming response. Defaults to False.
189
- optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
190
- conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
191
-
192
- Returns:
193
- Any: The response from the AI, either as a string or a generator
194
- depending on the `stream` parameter.
195
- """
196
-
197
- def for_stream():
198
- for response in self.ask(
199
- prompt, True, optimizer=optimizer, 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
- 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: Any) -> str:
216
- """
217
- Retrieves the message from the AI's response.
218
-
219
- Args:
220
- response (Any): The response from the AI, either a dictionary
221
- or a raw string.
222
-
223
- Returns:
224
- str: The extracted message from the AI's response.
225
- """
226
- if isinstance(response, dict):
227
- return response["text"]
228
- else: # Assume raw string
229
- return response
230
-