webscout 6.5__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/autocoder/autocoder_utiles.py +119 -101
- webscout/Extra/weather.py +5 -5
- webscout/Provider/AISEARCH/__init__.py +2 -0
- webscout/Provider/AISEARCH/ooai.py +155 -0
- webscout/Provider/Amigo.py +70 -85
- webscout/Provider/{prefind.py → Jadve.py} +72 -70
- webscout/Provider/Netwrck.py +239 -0
- webscout/Provider/Openai.py +4 -3
- webscout/Provider/PI.py +2 -2
- webscout/Provider/PizzaGPT.py +3 -3
- webscout/Provider/TeachAnything.py +15 -2
- webscout/Provider/Youchat.py +42 -8
- webscout/Provider/__init__.py +134 -147
- webscout/Provider/meta.py +1 -1
- webscout/Provider/multichat.py +230 -0
- webscout/Provider/promptrefine.py +2 -2
- webscout/Provider/talkai.py +10 -13
- webscout/Provider/turboseek.py +5 -4
- webscout/Provider/tutorai.py +8 -112
- webscout/Provider/typegpt.py +4 -5
- webscout/Provider/x0gpt.py +81 -9
- webscout/Provider/yep.py +123 -361
- webscout/__init__.py +10 -1
- webscout/cli.py +31 -39
- webscout/conversation.py +24 -9
- webscout/exceptions.py +188 -20
- webscout/litprinter/__init__.py +19 -123
- webscout/litprinter/colors.py +54 -0
- webscout/optimizers.py +335 -185
- webscout/scout/__init__.py +2 -5
- webscout/scout/core/__init__.py +7 -0
- webscout/scout/core/crawler.py +140 -0
- webscout/scout/core/scout.py +571 -0
- webscout/scout/core/search_result.py +96 -0
- webscout/scout/core/text_analyzer.py +63 -0
- webscout/scout/core/text_utils.py +277 -0
- webscout/scout/core/web_analyzer.py +52 -0
- webscout/scout/element.py +6 -5
- webscout/update_checker.py +117 -58
- webscout/version.py +1 -1
- webscout/webscout_search.py +1 -1
- webscout/zeroart/base.py +15 -16
- webscout/zeroart/effects.py +1 -1
- webscout/zeroart/fonts.py +1 -1
- {webscout-6.5.dist-info → webscout-6.7.dist-info}/METADATA +9 -172
- {webscout-6.5.dist-info → webscout-6.7.dist-info}/RECORD +63 -45
- {webscout-6.5.dist-info → webscout-6.7.dist-info}/entry_points.txt +1 -1
- webscout-6.7.dist-info/top_level.txt +2 -0
- webstoken/__init__.py +30 -0
- webstoken/classifier.py +189 -0
- webstoken/keywords.py +216 -0
- webstoken/language.py +128 -0
- webstoken/ner.py +164 -0
- webstoken/normalizer.py +35 -0
- webstoken/processor.py +77 -0
- webstoken/sentiment.py +206 -0
- webstoken/stemmer.py +73 -0
- webstoken/t.py +75 -0
- webstoken/tagger.py +60 -0
- webstoken/tokenizer.py +158 -0
- webscout/Provider/Perplexity.py +0 -591
- webscout/Provider/RoboCoders.py +0 -206
- webscout/Provider/genspark.py +0 -225
- webscout/Provider/perplexitylabs.py +0 -265
- webscout/Provider/twitterclone.py +0 -251
- webscout/Provider/upstage.py +0 -230
- webscout-6.5.dist-info/top_level.txt +0 -1
- /webscout/Provider/{felo_search.py → AISEARCH/felo_search.py} +0 -0
- {webscout-6.5.dist-info → webscout-6.7.dist-info}/LICENSE.md +0 -0
- {webscout-6.5.dist-info → webscout-6.7.dist-info}/WHEEL +0 -0
|
@@ -0,0 +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
|
+
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)
|
|
239
|
+
print() # Add a newline at the end
|
webscout/Provider/Openai.py
CHANGED
|
@@ -6,7 +6,7 @@ from ..AIbase import Provider, AsyncProvider
|
|
|
6
6
|
|
|
7
7
|
from webscout import exceptions
|
|
8
8
|
from typing import Any, AsyncGenerator, Dict
|
|
9
|
-
|
|
9
|
+
import requests
|
|
10
10
|
import httpx
|
|
11
11
|
#----------------------------------------------------------OpenAI-----------------------------------
|
|
12
12
|
class OPENAI(Provider):
|
|
@@ -27,6 +27,7 @@ class OPENAI(Provider):
|
|
|
27
27
|
proxies: dict = {},
|
|
28
28
|
history_offset: int = 10250,
|
|
29
29
|
act: str = None,
|
|
30
|
+
base_url: str = "https://api.openai.com/v1/chat/completions",
|
|
30
31
|
):
|
|
31
32
|
"""Instantiates OPENAI
|
|
32
33
|
|
|
@@ -55,7 +56,7 @@ class OPENAI(Provider):
|
|
|
55
56
|
self.presence_penalty = presence_penalty
|
|
56
57
|
self.frequency_penalty = frequency_penalty
|
|
57
58
|
self.top_p = top_p
|
|
58
|
-
self.chat_endpoint =
|
|
59
|
+
self.chat_endpoint = base_url
|
|
59
60
|
self.stream_chunk_size = 64
|
|
60
61
|
self.timeout = timeout
|
|
61
62
|
self.last_response = {}
|
|
@@ -63,7 +64,7 @@ class OPENAI(Provider):
|
|
|
63
64
|
"Content-Type": "application/json",
|
|
64
65
|
"Authorization": f"Bearer {self.api_key}",
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
+
self.session = requests.session()
|
|
67
68
|
self.__available_optimizers = (
|
|
68
69
|
method
|
|
69
70
|
for method in dir(Optimizers)
|
webscout/Provider/PI.py
CHANGED
|
@@ -8,7 +8,7 @@ from webscout.AIutel import Conversation
|
|
|
8
8
|
from webscout.AIutel import AwesomePrompts
|
|
9
9
|
from webscout.AIbase import Provider
|
|
10
10
|
from typing import Dict
|
|
11
|
-
|
|
11
|
+
from webscout import LitAgent
|
|
12
12
|
class PiAI(Provider):
|
|
13
13
|
"""PiAI class for interacting with the Pi.ai chat API, extending the Provider class.
|
|
14
14
|
|
|
@@ -71,7 +71,7 @@ class PiAI(Provider):
|
|
|
71
71
|
'Sec-Fetch-Dest': 'empty',
|
|
72
72
|
'Sec-Fetch-Mode': 'cors',
|
|
73
73
|
'Sec-Fetch-Site': 'same-origin',
|
|
74
|
-
'User-Agent':
|
|
74
|
+
'User-Agent': LitAgent().random(),
|
|
75
75
|
'X-Api-Version': '3'
|
|
76
76
|
}
|
|
77
77
|
self.cookies = {
|
webscout/Provider/PizzaGPT.py
CHANGED
|
@@ -7,7 +7,7 @@ from webscout.AIutel import Conversation
|
|
|
7
7
|
from webscout.AIutel import AwesomePrompts, sanitize_stream
|
|
8
8
|
from webscout.AIbase import Provider, AsyncProvider
|
|
9
9
|
from webscout import exceptions
|
|
10
|
-
|
|
10
|
+
from webscout import LitAgent as Lit
|
|
11
11
|
|
|
12
12
|
class PIZZAGPT(Provider):
|
|
13
13
|
"""
|
|
@@ -63,7 +63,7 @@ class PIZZAGPT(Provider):
|
|
|
63
63
|
"sec-fetch-dest": "empty",
|
|
64
64
|
"sec-fetch-mode": "cors",
|
|
65
65
|
"sec-fetch-site": "same-origin",
|
|
66
|
-
"user-agent":
|
|
66
|
+
"user-agent": Lit().random(),
|
|
67
67
|
"x-secret": "Marinara"
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -133,7 +133,7 @@ class PIZZAGPT(Provider):
|
|
|
133
133
|
)
|
|
134
134
|
|
|
135
135
|
resp = response.json()
|
|
136
|
-
self.last_response.update(dict(text=resp['
|
|
136
|
+
self.last_response.update(dict(text=resp['content']))
|
|
137
137
|
self.conversation.update_chat_history(
|
|
138
138
|
prompt, self.get_message(self.last_response)
|
|
139
139
|
)
|
|
@@ -2,6 +2,8 @@ import requests
|
|
|
2
2
|
from requests.exceptions import RequestException
|
|
3
3
|
from typing import Any, Dict
|
|
4
4
|
from webscout.AIutel import Conversation, Optimizers
|
|
5
|
+
from webscout.litagent import LitAgent
|
|
6
|
+
from webscout.prompt_manager import AwesomePrompts
|
|
5
7
|
|
|
6
8
|
class TeachAnything:
|
|
7
9
|
"""
|
|
@@ -54,15 +56,26 @@ class TeachAnything:
|
|
|
54
56
|
"content-type": "application/json",
|
|
55
57
|
"origin": "https://www.teach-anything.com",
|
|
56
58
|
"referer": "https://www.teach-anything.com/",
|
|
57
|
-
"user-agent":
|
|
59
|
+
"user-agent": LitAgent().random(),
|
|
58
60
|
}
|
|
61
|
+
self.__available_optimizers = (
|
|
62
|
+
method
|
|
63
|
+
for method in dir(Optimizers)
|
|
64
|
+
if callable(getattr(Optimizers, method)) and not method.startswith("__")
|
|
65
|
+
)
|
|
59
66
|
self.session.headers.update(self.headers)
|
|
67
|
+
Conversation.intro = (
|
|
68
|
+
AwesomePrompts().get_act(
|
|
69
|
+
act, raise_not_found=True, default=None, case_insensitive=True
|
|
70
|
+
)
|
|
71
|
+
if act
|
|
72
|
+
else intro or Conversation.intro
|
|
73
|
+
)
|
|
60
74
|
self.conversation = Conversation(
|
|
61
75
|
is_conversation, self.max_tokens_to_sample, filepath, update_file
|
|
62
76
|
)
|
|
63
77
|
self.conversation.history_offset = history_offset
|
|
64
78
|
self.session.proxies = proxies
|
|
65
|
-
|
|
66
79
|
def ask(
|
|
67
80
|
self,
|
|
68
81
|
prompt: str,
|
webscout/Provider/Youchat.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
from uuid import uuid4
|
|
3
2
|
from re import findall
|
|
4
3
|
import json
|
|
@@ -12,12 +11,41 @@ from typing import Any, AsyncGenerator, Dict
|
|
|
12
11
|
|
|
13
12
|
import cloudscraper
|
|
14
13
|
|
|
15
|
-
|
|
16
14
|
class YouChat(Provider):
|
|
17
15
|
"""
|
|
18
16
|
This class provides methods for interacting with the You.com chat API in a consistent provider structure.
|
|
19
17
|
"""
|
|
20
18
|
|
|
19
|
+
AVAILABLE_MODELS = [
|
|
20
|
+
"openai_o1",
|
|
21
|
+
"openai_o1_mini",
|
|
22
|
+
"gpt_4o_mini",
|
|
23
|
+
"gpt_4o",
|
|
24
|
+
"gpt_4_turbo",
|
|
25
|
+
"gpt_4",
|
|
26
|
+
"claude_3_5_sonnet",
|
|
27
|
+
"claude_3_opus",
|
|
28
|
+
"claude_3_sonnet",
|
|
29
|
+
"claude_3_5_haiku",
|
|
30
|
+
"claude_3_haiku",
|
|
31
|
+
"llama3_3_70b",
|
|
32
|
+
"llama3_2_90b",
|
|
33
|
+
"llama3_2_11b",
|
|
34
|
+
"llama3_1_405b",
|
|
35
|
+
"llama3_1_70b",
|
|
36
|
+
"llama3",
|
|
37
|
+
"mistral_large_2",
|
|
38
|
+
"gemini_1_5_flash",
|
|
39
|
+
"gemini_1_5_pro",
|
|
40
|
+
"databricks_dbrx_instruct",
|
|
41
|
+
"qwen2p5_72b",
|
|
42
|
+
"qwen2p5_coder_32b",
|
|
43
|
+
"command_r",
|
|
44
|
+
"command_r_plus",
|
|
45
|
+
"solar_1_mini",
|
|
46
|
+
"dolphin_2_5"
|
|
47
|
+
]
|
|
48
|
+
|
|
21
49
|
def __init__(
|
|
22
50
|
self,
|
|
23
51
|
is_conversation: bool = True,
|
|
@@ -29,6 +57,7 @@ class YouChat(Provider):
|
|
|
29
57
|
proxies: dict = {},
|
|
30
58
|
history_offset: int = 10250,
|
|
31
59
|
act: str = None,
|
|
60
|
+
model: str = "claude_3_5_haiku", # Default model set to claude_3_5_haiku
|
|
32
61
|
):
|
|
33
62
|
"""Instantiates YouChat
|
|
34
63
|
|
|
@@ -42,7 +71,11 @@ class YouChat(Provider):
|
|
|
42
71
|
proxies (dict, optional): Http request proxies. Defaults to {}.
|
|
43
72
|
history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
|
|
44
73
|
act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
|
|
74
|
+
model (str, optional): Model to use. Defaults to "claude_3_5_haiku".
|
|
45
75
|
"""
|
|
76
|
+
if model not in self.AVAILABLE_MODELS:
|
|
77
|
+
raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
|
|
78
|
+
|
|
46
79
|
self.session = cloudscraper.create_scraper() # Create a Cloudscraper session
|
|
47
80
|
self.is_conversation = is_conversation
|
|
48
81
|
self.max_tokens_to_sample = max_tokens
|
|
@@ -50,6 +83,7 @@ class YouChat(Provider):
|
|
|
50
83
|
self.stream_chunk_size = 64
|
|
51
84
|
self.timeout = timeout
|
|
52
85
|
self.last_response = {}
|
|
86
|
+
self.model = model
|
|
53
87
|
self.headers = {
|
|
54
88
|
"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",
|
|
55
89
|
"Accept": "text/event-stream",
|
|
@@ -123,18 +157,18 @@ class YouChat(Provider):
|
|
|
123
157
|
|
|
124
158
|
payload = {
|
|
125
159
|
"q": conversation_prompt,
|
|
126
|
-
"page":
|
|
127
|
-
"count":
|
|
160
|
+
"page": 2,
|
|
161
|
+
"count": 20,
|
|
128
162
|
"safeSearch": "Moderate",
|
|
129
163
|
"mkt": "en-IN",
|
|
130
164
|
"domain": "youchat",
|
|
131
|
-
"use_personalization_extraction": "
|
|
165
|
+
"use_personalization_extraction": "false",
|
|
132
166
|
"queryTraceId": str(uuid4()),
|
|
133
167
|
"chatId": str(uuid4()),
|
|
134
168
|
"conversationTurnId": str(uuid4()),
|
|
135
169
|
"pastChatLength": 0,
|
|
136
170
|
"isSmallMediumDevice": "true",
|
|
137
|
-
"selectedChatMode":
|
|
171
|
+
"selectedChatMode": self.model, # Use the selected model
|
|
138
172
|
"traceId": str(uuid4()),
|
|
139
173
|
"chat": "[]"
|
|
140
174
|
}
|
|
@@ -224,6 +258,6 @@ class YouChat(Provider):
|
|
|
224
258
|
if __name__ == '__main__':
|
|
225
259
|
from rich import print
|
|
226
260
|
ai = YouChat(timeout=5000)
|
|
227
|
-
response = ai.chat("
|
|
261
|
+
response = ai.chat("hi", stream=True)
|
|
228
262
|
for chunk in response:
|
|
229
|
-
print(chunk, end="", flush=True)
|
|
263
|
+
print(chunk, end="", flush=True)
|