webscout 8.2.9__py3-none-any.whl → 8.3__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/AIauto.py +2 -2
- webscout/Provider/Blackboxai.py +2 -0
- webscout/Provider/ChatSandbox.py +2 -1
- webscout/Provider/Deepinfra.py +1 -1
- webscout/Provider/HeckAI.py +1 -1
- webscout/Provider/LambdaChat.py +1 -0
- webscout/Provider/MCPCore.py +7 -3
- webscout/Provider/OPENAI/BLACKBOXAI.py +1017 -766
- webscout/Provider/OPENAI/Cloudflare.py +31 -14
- webscout/Provider/OPENAI/FalconH1.py +457 -0
- webscout/Provider/OPENAI/FreeGemini.py +29 -13
- webscout/Provider/OPENAI/NEMOTRON.py +26 -14
- webscout/Provider/OPENAI/PI.py +427 -0
- webscout/Provider/OPENAI/Qwen3.py +303 -282
- webscout/Provider/OPENAI/TwoAI.py +29 -12
- webscout/Provider/OPENAI/__init__.py +3 -1
- webscout/Provider/OPENAI/ai4chat.py +33 -23
- webscout/Provider/OPENAI/api.py +78 -12
- webscout/Provider/OPENAI/base.py +2 -0
- webscout/Provider/OPENAI/c4ai.py +31 -10
- webscout/Provider/OPENAI/chatgpt.py +41 -22
- webscout/Provider/OPENAI/chatgptclone.py +32 -13
- webscout/Provider/OPENAI/chatsandbox.py +7 -3
- webscout/Provider/OPENAI/copilot.py +26 -10
- webscout/Provider/OPENAI/deepinfra.py +327 -321
- webscout/Provider/OPENAI/e2b.py +77 -99
- webscout/Provider/OPENAI/exaai.py +13 -10
- webscout/Provider/OPENAI/exachat.py +10 -6
- webscout/Provider/OPENAI/flowith.py +7 -3
- webscout/Provider/OPENAI/freeaichat.py +10 -6
- webscout/Provider/OPENAI/glider.py +10 -6
- webscout/Provider/OPENAI/heckai.py +11 -8
- webscout/Provider/OPENAI/llmchatco.py +9 -7
- webscout/Provider/OPENAI/mcpcore.py +10 -7
- webscout/Provider/OPENAI/multichat.py +3 -1
- webscout/Provider/OPENAI/netwrck.py +10 -6
- webscout/Provider/OPENAI/oivscode.py +12 -9
- webscout/Provider/OPENAI/opkfc.py +14 -3
- webscout/Provider/OPENAI/scirachat.py +14 -8
- webscout/Provider/OPENAI/sonus.py +10 -6
- webscout/Provider/OPENAI/standardinput.py +18 -9
- webscout/Provider/OPENAI/textpollinations.py +14 -7
- webscout/Provider/OPENAI/toolbaz.py +16 -10
- webscout/Provider/OPENAI/typefully.py +14 -7
- webscout/Provider/OPENAI/typegpt.py +10 -6
- webscout/Provider/OPENAI/uncovrAI.py +22 -8
- webscout/Provider/OPENAI/venice.py +10 -6
- webscout/Provider/OPENAI/writecream.py +166 -163
- webscout/Provider/OPENAI/x0gpt.py +367 -365
- webscout/Provider/OPENAI/yep.py +384 -382
- webscout/Provider/PI.py +2 -1
- webscout/Provider/__init__.py +0 -2
- webscout/Provider/granite.py +41 -6
- webscout/Provider/oivscode.py +37 -37
- webscout/Provider/scnet.py +1 -0
- webscout/version.py +1 -1
- {webscout-8.2.9.dist-info → webscout-8.3.dist-info}/METADATA +2 -1
- {webscout-8.2.9.dist-info → webscout-8.3.dist-info}/RECORD +62 -61
- {webscout-8.2.9.dist-info → webscout-8.3.dist-info}/WHEEL +1 -1
- webscout/Provider/ChatGPTGratis.py +0 -194
- {webscout-8.2.9.dist-info → webscout-8.3.dist-info}/entry_points.txt +0 -0
- {webscout-8.2.9.dist-info → webscout-8.3.dist-info}/licenses/LICENSE.md +0 -0
- {webscout-8.2.9.dist-info → webscout-8.3.dist-info}/top_level.txt +0 -0
|
@@ -1,322 +1,328 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
import json
|
|
3
|
-
import time
|
|
4
|
-
import uuid
|
|
5
|
-
from typing import List, Dict, Optional, Union, Generator, Any
|
|
6
|
-
|
|
7
|
-
# Import base classes and utility structures
|
|
8
|
-
from .base import OpenAICompatibleProvider, BaseChat, BaseCompletions
|
|
9
|
-
from .utils import (
|
|
10
|
-
ChatCompletionChunk, ChatCompletion, Choice, ChoiceDelta,
|
|
11
|
-
ChatCompletionMessage, CompletionUsage
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
# Attempt to import LitAgent, fallback if not available
|
|
15
|
-
try:
|
|
16
|
-
from webscout.litagent import LitAgent
|
|
17
|
-
except ImportError:
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
# --- DeepInfra Client ---
|
|
21
|
-
|
|
22
|
-
class Completions(BaseCompletions):
|
|
23
|
-
def __init__(self, client: 'DeepInfra'):
|
|
24
|
-
self._client = client
|
|
25
|
-
|
|
26
|
-
def create(
|
|
27
|
-
self,
|
|
28
|
-
*,
|
|
29
|
-
model: str,
|
|
30
|
-
messages: List[Dict[str, str]],
|
|
31
|
-
max_tokens: Optional[int] = 2049,
|
|
32
|
-
stream: bool = False,
|
|
33
|
-
temperature: Optional[float] = None,
|
|
34
|
-
top_p: Optional[float] = None,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if
|
|
50
|
-
payload["
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return self.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
data
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
#
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
"
|
|
236
|
-
"deepseek-ai/DeepSeek-
|
|
237
|
-
"
|
|
238
|
-
"
|
|
239
|
-
"
|
|
240
|
-
"
|
|
241
|
-
"
|
|
242
|
-
"
|
|
243
|
-
"
|
|
244
|
-
"
|
|
245
|
-
"
|
|
246
|
-
"
|
|
247
|
-
"
|
|
248
|
-
"meta-llama/
|
|
249
|
-
"
|
|
250
|
-
"
|
|
251
|
-
"
|
|
252
|
-
"
|
|
253
|
-
"
|
|
254
|
-
"
|
|
255
|
-
"
|
|
256
|
-
"
|
|
257
|
-
"
|
|
258
|
-
"
|
|
259
|
-
"
|
|
260
|
-
"
|
|
261
|
-
"Qwen/
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
# "
|
|
269
|
-
# "
|
|
270
|
-
# "
|
|
271
|
-
|
|
272
|
-
# "
|
|
273
|
-
|
|
274
|
-
# "meta-llama/
|
|
275
|
-
# "meta-llama/
|
|
276
|
-
# "meta-llama/
|
|
277
|
-
# "
|
|
278
|
-
# "
|
|
279
|
-
# "
|
|
280
|
-
# "
|
|
281
|
-
# "
|
|
282
|
-
# "
|
|
283
|
-
# "
|
|
284
|
-
# "
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
self.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
"
|
|
303
|
-
"
|
|
304
|
-
"
|
|
305
|
-
"
|
|
306
|
-
"
|
|
307
|
-
"
|
|
308
|
-
"
|
|
309
|
-
"
|
|
310
|
-
"
|
|
311
|
-
"Sec-
|
|
312
|
-
"
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
1
|
+
import requests
|
|
2
|
+
import json
|
|
3
|
+
import time
|
|
4
|
+
import uuid
|
|
5
|
+
from typing import List, Dict, Optional, Union, Generator, Any
|
|
6
|
+
|
|
7
|
+
# Import base classes and utility structures
|
|
8
|
+
from .base import OpenAICompatibleProvider, BaseChat, BaseCompletions
|
|
9
|
+
from .utils import (
|
|
10
|
+
ChatCompletionChunk, ChatCompletion, Choice, ChoiceDelta,
|
|
11
|
+
ChatCompletionMessage, CompletionUsage
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
# Attempt to import LitAgent, fallback if not available
|
|
15
|
+
try:
|
|
16
|
+
from webscout.litagent import LitAgent
|
|
17
|
+
except ImportError:
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
# --- DeepInfra Client ---
|
|
21
|
+
|
|
22
|
+
class Completions(BaseCompletions):
|
|
23
|
+
def __init__(self, client: 'DeepInfra'):
|
|
24
|
+
self._client = client
|
|
25
|
+
|
|
26
|
+
def create(
|
|
27
|
+
self,
|
|
28
|
+
*,
|
|
29
|
+
model: str,
|
|
30
|
+
messages: List[Dict[str, str]],
|
|
31
|
+
max_tokens: Optional[int] = 2049,
|
|
32
|
+
stream: bool = False,
|
|
33
|
+
temperature: Optional[float] = None,
|
|
34
|
+
top_p: Optional[float] = None,
|
|
35
|
+
timeout: Optional[int] = None,
|
|
36
|
+
proxies: Optional[Dict[str, str]] = None,
|
|
37
|
+
**kwargs: Any
|
|
38
|
+
) -> Union[ChatCompletion, Generator[ChatCompletionChunk, None, None]]:
|
|
39
|
+
"""
|
|
40
|
+
Creates a model response for the given chat conversation.
|
|
41
|
+
Mimics openai.chat.completions.create
|
|
42
|
+
"""
|
|
43
|
+
payload = {
|
|
44
|
+
"model": model,
|
|
45
|
+
"messages": messages,
|
|
46
|
+
"max_tokens": max_tokens,
|
|
47
|
+
"stream": stream,
|
|
48
|
+
}
|
|
49
|
+
if temperature is not None:
|
|
50
|
+
payload["temperature"] = temperature
|
|
51
|
+
if top_p is not None:
|
|
52
|
+
payload["top_p"] = top_p
|
|
53
|
+
|
|
54
|
+
payload.update(kwargs)
|
|
55
|
+
|
|
56
|
+
request_id = f"chatcmpl-{uuid.uuid4()}"
|
|
57
|
+
created_time = int(time.time())
|
|
58
|
+
|
|
59
|
+
if stream:
|
|
60
|
+
return self._create_stream(request_id, created_time, model, payload, timeout, proxies)
|
|
61
|
+
else:
|
|
62
|
+
return self._create_non_stream(request_id, created_time, model, payload, timeout, proxies)
|
|
63
|
+
|
|
64
|
+
def _create_stream(
|
|
65
|
+
self, request_id: str, created_time: int, model: str, payload: Dict[str, Any],
|
|
66
|
+
timeout: Optional[int] = None, proxies: Optional[Dict[str, str]] = None
|
|
67
|
+
) -> Generator[ChatCompletionChunk, None, None]:
|
|
68
|
+
try:
|
|
69
|
+
response = self._client.session.post(
|
|
70
|
+
self._client.base_url,
|
|
71
|
+
headers=self._client.headers,
|
|
72
|
+
json=payload,
|
|
73
|
+
stream=True,
|
|
74
|
+
timeout=timeout or self._client.timeout,
|
|
75
|
+
proxies=proxies
|
|
76
|
+
)
|
|
77
|
+
response.raise_for_status()
|
|
78
|
+
|
|
79
|
+
# Track token usage across chunks
|
|
80
|
+
prompt_tokens = 0
|
|
81
|
+
completion_tokens = 0
|
|
82
|
+
total_tokens = 0
|
|
83
|
+
|
|
84
|
+
for line in response.iter_lines():
|
|
85
|
+
if line:
|
|
86
|
+
decoded_line = line.decode('utf-8').strip()
|
|
87
|
+
|
|
88
|
+
if decoded_line.startswith("data: "):
|
|
89
|
+
json_str = decoded_line[6:]
|
|
90
|
+
if json_str == "[DONE]":
|
|
91
|
+
# Format the final [DONE] marker in OpenAI format
|
|
92
|
+
# print("data: [DONE]")
|
|
93
|
+
break
|
|
94
|
+
|
|
95
|
+
try:
|
|
96
|
+
data = json.loads(json_str)
|
|
97
|
+
choice_data = data.get('choices', [{}])[0]
|
|
98
|
+
delta_data = choice_data.get('delta', {})
|
|
99
|
+
finish_reason = choice_data.get('finish_reason')
|
|
100
|
+
|
|
101
|
+
# Update token counts if available
|
|
102
|
+
usage_data = data.get('usage', {})
|
|
103
|
+
if usage_data:
|
|
104
|
+
prompt_tokens = usage_data.get('prompt_tokens', prompt_tokens)
|
|
105
|
+
completion_tokens = usage_data.get('completion_tokens', completion_tokens)
|
|
106
|
+
total_tokens = usage_data.get('total_tokens', total_tokens)
|
|
107
|
+
|
|
108
|
+
# Create the delta object
|
|
109
|
+
delta = ChoiceDelta(
|
|
110
|
+
content=delta_data.get('content'),
|
|
111
|
+
role=delta_data.get('role'),
|
|
112
|
+
tool_calls=delta_data.get('tool_calls')
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# Create the choice object
|
|
116
|
+
choice = Choice(
|
|
117
|
+
index=choice_data.get('index', 0),
|
|
118
|
+
delta=delta,
|
|
119
|
+
finish_reason=finish_reason,
|
|
120
|
+
logprobs=choice_data.get('logprobs')
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
# Create the chunk object
|
|
124
|
+
chunk = ChatCompletionChunk(
|
|
125
|
+
id=request_id,
|
|
126
|
+
choices=[choice],
|
|
127
|
+
created=created_time,
|
|
128
|
+
model=model,
|
|
129
|
+
system_fingerprint=data.get('system_fingerprint')
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
# Convert chunk to dict using Pydantic's API
|
|
133
|
+
if hasattr(chunk, "model_dump"):
|
|
134
|
+
chunk_dict = chunk.model_dump(exclude_none=True)
|
|
135
|
+
else:
|
|
136
|
+
chunk_dict = chunk.dict(exclude_none=True)
|
|
137
|
+
|
|
138
|
+
# Add usage information to match OpenAI format
|
|
139
|
+
# Even if we don't have real token counts, include estimated usage
|
|
140
|
+
# This matches the format in the examples
|
|
141
|
+
usage_dict = {
|
|
142
|
+
"prompt_tokens": prompt_tokens or 10,
|
|
143
|
+
"completion_tokens": completion_tokens or (len(delta_data.get('content', '')) if delta_data.get('content') else 0),
|
|
144
|
+
"total_tokens": total_tokens or (10 + (len(delta_data.get('content', '')) if delta_data.get('content') else 0)),
|
|
145
|
+
"estimated_cost": None
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
# Update completion_tokens and total_tokens as we receive more content
|
|
149
|
+
if delta_data.get('content'):
|
|
150
|
+
completion_tokens += 1
|
|
151
|
+
total_tokens = prompt_tokens + completion_tokens
|
|
152
|
+
usage_dict["completion_tokens"] = completion_tokens
|
|
153
|
+
usage_dict["total_tokens"] = total_tokens
|
|
154
|
+
|
|
155
|
+
chunk_dict["usage"] = usage_dict
|
|
156
|
+
|
|
157
|
+
# Format the response in OpenAI format exactly as requested
|
|
158
|
+
# We need to print the raw string and also yield the chunk object
|
|
159
|
+
# This ensures both the console output and the returned object are correct
|
|
160
|
+
# print(f"data: {json.dumps(chunk_dict)}")
|
|
161
|
+
|
|
162
|
+
# Return the chunk object for internal processing
|
|
163
|
+
yield chunk
|
|
164
|
+
except json.JSONDecodeError:
|
|
165
|
+
print(f"Warning: Could not decode JSON line: {json_str}")
|
|
166
|
+
continue
|
|
167
|
+
except requests.exceptions.RequestException as e:
|
|
168
|
+
print(f"Error during DeepInfra stream request: {e}")
|
|
169
|
+
raise IOError(f"DeepInfra request failed: {e}") from e
|
|
170
|
+
except Exception as e:
|
|
171
|
+
print(f"Error processing DeepInfra stream: {e}")
|
|
172
|
+
raise
|
|
173
|
+
|
|
174
|
+
def _create_non_stream(
|
|
175
|
+
self, request_id: str, created_time: int, model: str, payload: Dict[str, Any],
|
|
176
|
+
timeout: Optional[int] = None, proxies: Optional[Dict[str, str]] = None
|
|
177
|
+
) -> ChatCompletion:
|
|
178
|
+
try:
|
|
179
|
+
response = self._client.session.post(
|
|
180
|
+
self._client.base_url,
|
|
181
|
+
headers=self._client.headers,
|
|
182
|
+
json=payload,
|
|
183
|
+
timeout=timeout or self._client.timeout,
|
|
184
|
+
proxies=proxies
|
|
185
|
+
)
|
|
186
|
+
response.raise_for_status()
|
|
187
|
+
data = response.json()
|
|
188
|
+
|
|
189
|
+
choices_data = data.get('choices', [])
|
|
190
|
+
usage_data = data.get('usage', {})
|
|
191
|
+
|
|
192
|
+
choices = []
|
|
193
|
+
for choice_d in choices_data:
|
|
194
|
+
message_d = choice_d.get('message', {})
|
|
195
|
+
message = ChatCompletionMessage(
|
|
196
|
+
role=message_d.get('role', 'assistant'),
|
|
197
|
+
content=message_d.get('content', '')
|
|
198
|
+
)
|
|
199
|
+
choice = Choice(
|
|
200
|
+
index=choice_d.get('index', 0),
|
|
201
|
+
message=message,
|
|
202
|
+
finish_reason=choice_d.get('finish_reason', 'stop')
|
|
203
|
+
)
|
|
204
|
+
choices.append(choice)
|
|
205
|
+
|
|
206
|
+
usage = CompletionUsage(
|
|
207
|
+
prompt_tokens=usage_data.get('prompt_tokens', 0),
|
|
208
|
+
completion_tokens=usage_data.get('completion_tokens', 0),
|
|
209
|
+
total_tokens=usage_data.get('total_tokens', 0)
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
completion = ChatCompletion(
|
|
213
|
+
id=request_id,
|
|
214
|
+
choices=choices,
|
|
215
|
+
created=created_time,
|
|
216
|
+
model=data.get('model', model),
|
|
217
|
+
usage=usage,
|
|
218
|
+
)
|
|
219
|
+
return completion
|
|
220
|
+
|
|
221
|
+
except requests.exceptions.RequestException as e:
|
|
222
|
+
print(f"Error during DeepInfra non-stream request: {e}")
|
|
223
|
+
raise IOError(f"DeepInfra request failed: {e}") from e
|
|
224
|
+
except Exception as e:
|
|
225
|
+
print(f"Error processing DeepInfra response: {e}")
|
|
226
|
+
raise
|
|
227
|
+
|
|
228
|
+
class Chat(BaseChat):
|
|
229
|
+
def __init__(self, client: 'DeepInfra'):
|
|
230
|
+
self.completions = Completions(client)
|
|
231
|
+
|
|
232
|
+
class DeepInfra(OpenAICompatibleProvider):
|
|
233
|
+
|
|
234
|
+
AVAILABLE_MODELS = [
|
|
235
|
+
# "anthropic/claude-3-7-sonnet-latest", # >>>> NOT WORKING
|
|
236
|
+
"deepseek-ai/DeepSeek-R1-0528",
|
|
237
|
+
"deepseek-ai/DeepSeek-R1",
|
|
238
|
+
"deepseek-ai/DeepSeek-R1-Distill-Llama-70B",
|
|
239
|
+
"deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
|
|
240
|
+
"deepseek-ai/DeepSeek-R1-Turbo",
|
|
241
|
+
"deepseek-ai/DeepSeek-V3",
|
|
242
|
+
"deepseek-ai/DeepSeek-Prover-V2-671B",
|
|
243
|
+
"google/gemma-2-27b-it",
|
|
244
|
+
"google/gemma-2-9b-it",
|
|
245
|
+
"google/gemma-3-12b-it",
|
|
246
|
+
"google/gemma-3-27b-it",
|
|
247
|
+
"google/gemma-3-4b-it",
|
|
248
|
+
"meta-llama/Llama-3.3-70B-Instruct",
|
|
249
|
+
"meta-llama/Llama-3.3-70B-Instruct-Turbo",
|
|
250
|
+
"meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",
|
|
251
|
+
"meta-llama/Llama-4-Scout-17B-16E-Instruct",
|
|
252
|
+
"meta-llama/Llama-Guard-4-12B",
|
|
253
|
+
"meta-llama/Meta-Llama-3.1-8B-Instruct",
|
|
254
|
+
"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
|
|
255
|
+
"microsoft/Phi-4-multimodal-instruct",
|
|
256
|
+
"microsoft/WizardLM-2-8x22B",
|
|
257
|
+
"microsoft/phi-4",
|
|
258
|
+
"microsoft/phi-4-reasoning-plus",
|
|
259
|
+
"mistralai/Mistral-Small-24B-Instruct-2501",
|
|
260
|
+
"nvidia/Llama-3.1-Nemotron-70B-Instruct",
|
|
261
|
+
"Qwen/QwQ-32B",
|
|
262
|
+
"Qwen/Qwen2.5-72B-Instruct",
|
|
263
|
+
"Qwen/Qwen2.5-Coder-32B-Instruct",
|
|
264
|
+
"Qwen/Qwen3-14B",
|
|
265
|
+
"Qwen/Qwen3-30B-A3B",
|
|
266
|
+
"Qwen/Qwen3-32B",
|
|
267
|
+
"Qwen/Qwen3-235B-A22B",
|
|
268
|
+
# "google/gemini-1.5-flash", # >>>> NOT WORKING
|
|
269
|
+
# "google/gemini-1.5-flash-8b", # >>>> NOT WORKING
|
|
270
|
+
# "google/gemini-2.0-flash-001", # >>>> NOT WORKING
|
|
271
|
+
|
|
272
|
+
# "Gryphe/MythoMax-L2-13b", # >>>> NOT WORKING
|
|
273
|
+
|
|
274
|
+
# "meta-llama/Llama-3.2-1B-Instruct", # >>>> NOT WORKING
|
|
275
|
+
# "meta-llama/Llama-3.2-3B-Instruct", # >>>> NOT WORKING
|
|
276
|
+
# "meta-llama/Llama-3.2-90B-Vision-Instruct", # >>>> NOT WORKING
|
|
277
|
+
# "meta-llama/Llama-3.2-11B-Vision-Instruct", # >>>> NOT WORKING
|
|
278
|
+
# "meta-llama/Meta-Llama-3-70B-Instruct", # >>>> NOT WORKING
|
|
279
|
+
# "meta-llama/Meta-Llama-3-8B-Instruct", # >>>> NOT WORKING
|
|
280
|
+
# "meta-llama/Meta-Llama-3.1-70B-Instruct", # >>>> NOT WORKING
|
|
281
|
+
# "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo", # >>>> NOT WORKING
|
|
282
|
+
# "meta-llama/Meta-Llama-3.1-405B-Instruct", # >>>> NOT WORKING
|
|
283
|
+
# "mistralai/Mixtral-8x7B-Instruct-v0.1", # >>>> NOT WORKING
|
|
284
|
+
# "mistralai/Mistral-7B-Instruct-v0.3", # >>>> NOT WORKING
|
|
285
|
+
# "mistralai/Mistral-Nemo-Instruct-2407", # >>>> NOT WORKING
|
|
286
|
+
# "NousResearch/Hermes-3-Llama-3.1-405B", # >>>> NOT WORKING
|
|
287
|
+
# "NovaSky-AI/Sky-T1-32B-Preview", # >>>> NOT WORKING
|
|
288
|
+
# "Qwen/Qwen2.5-7B-Instruct", # >>>> NOT WORKING
|
|
289
|
+
# "Sao10K/L3.1-70B-Euryale-v2.2", # >>>> NOT WORKING
|
|
290
|
+
# "Sao10K/L3.3-70B-Euryale-v2.3", # >>>> NOT WORKING
|
|
291
|
+
]
|
|
292
|
+
|
|
293
|
+
def __init__(self, browser: str = "chrome"):
|
|
294
|
+
self.timeout = None # Default timeout
|
|
295
|
+
self.base_url = "https://api.deepinfra.com/v1/openai/chat/completions"
|
|
296
|
+
self.session = requests.Session()
|
|
297
|
+
|
|
298
|
+
agent = LitAgent()
|
|
299
|
+
fingerprint = agent.generate_fingerprint(browser)
|
|
300
|
+
|
|
301
|
+
self.headers = {
|
|
302
|
+
"Accept": fingerprint["accept"],
|
|
303
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
304
|
+
"Accept-Language": fingerprint["accept_language"],
|
|
305
|
+
"Content-Type": "application/json",
|
|
306
|
+
"Cache-Control": "no-cache",
|
|
307
|
+
"Connection": "keep-alive",
|
|
308
|
+
"Origin": "https://deepinfra.com",
|
|
309
|
+
"Pragma": "no-cache",
|
|
310
|
+
"Referer": "https://deepinfra.com/",
|
|
311
|
+
"Sec-Fetch-Dest": "empty",
|
|
312
|
+
"Sec-Fetch-Mode": "cors",
|
|
313
|
+
"Sec-Fetch-Site": "same-site",
|
|
314
|
+
"X-Deepinfra-Source": "web-embed",
|
|
315
|
+
"Sec-CH-UA": fingerprint["sec_ch_ua"] or '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
|
|
316
|
+
"Sec-CH-UA-Mobile": "?0",
|
|
317
|
+
"Sec-CH-UA-Platform": f'"{fingerprint["platform"]}"',
|
|
318
|
+
"User-Agent": fingerprint["user_agent"],
|
|
319
|
+
}
|
|
320
|
+
self.session.headers.update(self.headers)
|
|
321
|
+
self.chat = Chat(self)
|
|
322
|
+
|
|
323
|
+
@property
|
|
324
|
+
def models(self):
|
|
325
|
+
class _ModelList:
|
|
326
|
+
def list(inner_self):
|
|
327
|
+
return type(self).AVAILABLE_MODELS
|
|
322
328
|
return _ModelList()
|