webscout 7.4__py3-none-any.whl → 7.6__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 (137) hide show
  1. webscout/AIauto.py +5 -53
  2. webscout/AIutel.py +8 -318
  3. webscout/DWEBS.py +460 -489
  4. webscout/Extra/YTToolkit/YTdownloader.py +14 -53
  5. webscout/Extra/YTToolkit/transcriber.py +12 -13
  6. webscout/Extra/YTToolkit/ytapi/video.py +0 -1
  7. webscout/Extra/__init__.py +0 -1
  8. webscout/Extra/autocoder/autocoder_utiles.py +0 -4
  9. webscout/Extra/autocoder/rawdog.py +13 -41
  10. webscout/Extra/gguf.py +652 -428
  11. webscout/Extra/weather.py +178 -156
  12. webscout/Extra/weather_ascii.py +70 -17
  13. webscout/Litlogger/core/logger.py +1 -2
  14. webscout/Litlogger/handlers/file.py +1 -1
  15. webscout/Litlogger/styles/formats.py +0 -2
  16. webscout/Litlogger/utils/detectors.py +0 -1
  17. webscout/Provider/AISEARCH/DeepFind.py +0 -1
  18. webscout/Provider/AISEARCH/ISou.py +1 -1
  19. webscout/Provider/AISEARCH/felo_search.py +0 -1
  20. webscout/Provider/AllenAI.py +24 -9
  21. webscout/Provider/C4ai.py +432 -0
  22. webscout/Provider/ChatGPTGratis.py +24 -56
  23. webscout/Provider/Cloudflare.py +18 -21
  24. webscout/Provider/DeepSeek.py +27 -48
  25. webscout/Provider/Deepinfra.py +129 -53
  26. webscout/Provider/Gemini.py +1 -1
  27. webscout/Provider/GithubChat.py +362 -0
  28. webscout/Provider/Glider.py +25 -8
  29. webscout/Provider/HF_space/qwen_qwen2.py +2 -2
  30. webscout/Provider/HeckAI.py +38 -5
  31. webscout/Provider/HuggingFaceChat.py +462 -0
  32. webscout/Provider/Jadve.py +20 -5
  33. webscout/Provider/Marcus.py +7 -50
  34. webscout/Provider/Netwrck.py +43 -67
  35. webscout/Provider/PI.py +4 -2
  36. webscout/Provider/Perplexitylabs.py +26 -6
  37. webscout/Provider/Phind.py +29 -3
  38. webscout/Provider/PizzaGPT.py +10 -51
  39. webscout/Provider/TTI/AiForce/async_aiforce.py +4 -37
  40. webscout/Provider/TTI/AiForce/sync_aiforce.py +41 -38
  41. webscout/Provider/TTI/FreeAIPlayground/__init__.py +9 -9
  42. webscout/Provider/TTI/FreeAIPlayground/async_freeaiplayground.py +206 -206
  43. webscout/Provider/TTI/FreeAIPlayground/sync_freeaiplayground.py +192 -192
  44. webscout/Provider/TTI/MagicStudio/__init__.py +2 -0
  45. webscout/Provider/TTI/MagicStudio/async_magicstudio.py +111 -0
  46. webscout/Provider/TTI/MagicStudio/sync_magicstudio.py +109 -0
  47. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +5 -24
  48. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +2 -22
  49. webscout/Provider/TTI/__init__.py +2 -3
  50. webscout/Provider/TTI/aiarta/__init__.py +2 -0
  51. webscout/Provider/TTI/aiarta/async_aiarta.py +482 -0
  52. webscout/Provider/TTI/aiarta/sync_aiarta.py +440 -0
  53. webscout/Provider/TTI/fastflux/__init__.py +22 -0
  54. webscout/Provider/TTI/fastflux/async_fastflux.py +257 -0
  55. webscout/Provider/TTI/fastflux/sync_fastflux.py +247 -0
  56. webscout/Provider/TTS/__init__.py +2 -2
  57. webscout/Provider/TTS/deepgram.py +12 -39
  58. webscout/Provider/TTS/elevenlabs.py +14 -40
  59. webscout/Provider/TTS/gesserit.py +11 -35
  60. webscout/Provider/TTS/murfai.py +13 -39
  61. webscout/Provider/TTS/parler.py +17 -40
  62. webscout/Provider/TTS/speechma.py +180 -0
  63. webscout/Provider/TTS/streamElements.py +17 -44
  64. webscout/Provider/TextPollinationsAI.py +39 -59
  65. webscout/Provider/Venice.py +217 -200
  66. webscout/Provider/WiseCat.py +27 -5
  67. webscout/Provider/Youchat.py +63 -36
  68. webscout/Provider/__init__.py +13 -8
  69. webscout/Provider/akashgpt.py +28 -10
  70. webscout/Provider/copilot.py +416 -0
  71. webscout/Provider/flowith.py +196 -0
  72. webscout/Provider/freeaichat.py +32 -45
  73. webscout/Provider/granite.py +17 -53
  74. webscout/Provider/koala.py +20 -5
  75. webscout/Provider/llamatutor.py +7 -47
  76. webscout/Provider/llmchat.py +36 -53
  77. webscout/Provider/multichat.py +92 -98
  78. webscout/Provider/talkai.py +1 -0
  79. webscout/Provider/turboseek.py +3 -0
  80. webscout/Provider/tutorai.py +2 -0
  81. webscout/Provider/typegpt.py +154 -64
  82. webscout/Provider/x0gpt.py +3 -1
  83. webscout/Provider/yep.py +102 -20
  84. webscout/__init__.py +3 -0
  85. webscout/cli.py +4 -40
  86. webscout/conversation.py +1 -10
  87. webscout/exceptions.py +19 -9
  88. webscout/litagent/__init__.py +2 -2
  89. webscout/litagent/agent.py +351 -20
  90. webscout/litagent/constants.py +34 -5
  91. webscout/litprinter/__init__.py +0 -3
  92. webscout/models.py +181 -0
  93. webscout/optimizers.py +1 -1
  94. webscout/prompt_manager.py +2 -8
  95. webscout/scout/core/scout.py +1 -4
  96. webscout/scout/core/search_result.py +1 -1
  97. webscout/scout/core/text_utils.py +1 -1
  98. webscout/scout/core.py +2 -5
  99. webscout/scout/element.py +1 -1
  100. webscout/scout/parsers/html_parser.py +1 -1
  101. webscout/scout/utils.py +0 -1
  102. webscout/swiftcli/__init__.py +1 -3
  103. webscout/tempid.py +1 -1
  104. webscout/update_checker.py +55 -95
  105. webscout/version.py +1 -1
  106. webscout/webscout_search_async.py +1 -2
  107. webscout/yep_search.py +297 -297
  108. webscout-7.6.dist-info/LICENSE.md +146 -0
  109. {webscout-7.4.dist-info → webscout-7.6.dist-info}/METADATA +104 -514
  110. {webscout-7.4.dist-info → webscout-7.6.dist-info}/RECORD +113 -120
  111. webscout/Extra/autollama.py +0 -231
  112. webscout/Local/__init__.py +0 -10
  113. webscout/Local/_version.py +0 -3
  114. webscout/Local/formats.py +0 -747
  115. webscout/Local/model.py +0 -1368
  116. webscout/Local/samplers.py +0 -125
  117. webscout/Local/thread.py +0 -539
  118. webscout/Local/ui.py +0 -401
  119. webscout/Local/utils.py +0 -388
  120. webscout/Provider/Amigo.py +0 -274
  121. webscout/Provider/Bing.py +0 -243
  122. webscout/Provider/DiscordRocks.py +0 -253
  123. webscout/Provider/TTI/blackbox/__init__.py +0 -4
  124. webscout/Provider/TTI/blackbox/async_blackbox.py +0 -212
  125. webscout/Provider/TTI/blackbox/sync_blackbox.py +0 -199
  126. webscout/Provider/TTI/deepinfra/__init__.py +0 -4
  127. webscout/Provider/TTI/deepinfra/async_deepinfra.py +0 -227
  128. webscout/Provider/TTI/deepinfra/sync_deepinfra.py +0 -199
  129. webscout/Provider/TTI/imgninza/__init__.py +0 -4
  130. webscout/Provider/TTI/imgninza/async_ninza.py +0 -214
  131. webscout/Provider/TTI/imgninza/sync_ninza.py +0 -209
  132. webscout/Provider/TTS/voicepod.py +0 -117
  133. webscout/Provider/dgaf.py +0 -214
  134. webscout-7.4.dist-info/LICENSE.md +0 -211
  135. {webscout-7.4.dist-info → webscout-7.6.dist-info}/WHEEL +0 -0
  136. {webscout-7.4.dist-info → webscout-7.6.dist-info}/entry_points.txt +0 -0
  137. {webscout-7.4.dist-info → webscout-7.6.dist-info}/top_level.txt +0 -0
@@ -9,12 +9,10 @@ from webscout import exceptions
9
9
  from typing import Any, AsyncGenerator, Dict
10
10
  import cloudscraper
11
11
  from webscout import LitAgent
12
- from webscout.Litlogger import Logger, LogFormat
13
12
 
14
13
  class Cloudflare(Provider):
15
14
  """
16
15
  Cloudflare provider to interact with Cloudflare's text generation API.
17
- Includes logging capabilities using Logger and uses LitAgent for user-agent.
18
16
  """
19
17
 
20
18
  # Updated AVAILABLE_MODELS from given JSON data
@@ -72,7 +70,6 @@ class Cloudflare(Provider):
72
70
  act: str = None,
73
71
  model: str = "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b",
74
72
  system_prompt: str = "You are a helpful assistant.",
75
- logging: bool = False
76
73
  ):
77
74
  """Instantiates Cloudflare Provider
78
75
 
@@ -145,13 +142,13 @@ class Cloudflare(Provider):
145
142
  self.conversation.history_offset = history_offset
146
143
 
147
144
  # Initialize logger if logging is enabled
148
- self.logger = Logger(
149
- name="Cloudflare",
150
- format=LogFormat.MODERN_EMOJI,
151
- ) if logging else None
145
+ # self.logger = Logger(
146
+ # name="Cloudflare",
147
+ # format=LogFormat.MODERN_EMOJI,
148
+ # ) if logging else None
152
149
 
153
- if self.logger:
154
- self.logger.info("Cloudflare initialized successfully")
150
+ # if self.logger:
151
+ # self.logger.info("Cloudflare initialized successfully")
155
152
 
156
153
  def ask(
157
154
  self,
@@ -178,11 +175,11 @@ class Cloudflare(Provider):
178
175
  conversation_prompt = getattr(Optimizers, optimizer)(
179
176
  conversation_prompt if conversationally else prompt
180
177
  )
181
- if self.logger:
182
- self.logger.debug(f"Applied optimizer: {optimizer}")
178
+ # if self.logger:
179
+ # self.logger.debug(f"Applied optimizer: {optimizer}")
183
180
  else:
184
- if self.logger:
185
- self.logger.error(f"Invalid optimizer requested: {optimizer}")
181
+ # if self.logger:
182
+ # self.logger.error(f"Invalid optimizer requested: {optimizer}")
186
183
  raise Exception(f"Optimizer is not one of {list(self.__available_optimizers)}")
187
184
 
188
185
  payload = {
@@ -192,13 +189,13 @@ class Cloudflare(Provider):
192
189
  ],
193
190
  "lora": None,
194
191
  "model": self.model,
195
- "max_tokens": 512,
192
+ "max_tokens": self.max_tokens_to_sample,
196
193
  "stream": True
197
194
  }
198
195
 
199
196
  def for_stream():
200
- if self.logger:
201
- self.logger.debug("Sending streaming request to Cloudflare API...")
197
+ # if self.logger:
198
+ # self.logger.debug("Sending streaming request to Cloudflare API...")
202
199
  response = self.scraper.post(
203
200
  self.chat_endpoint,
204
201
  headers=self.headers,
@@ -208,8 +205,8 @@ class Cloudflare(Provider):
208
205
  timeout=self.timeout
209
206
  )
210
207
  if not response.ok:
211
- if self.logger:
212
- self.logger.error(f"Request failed: ({response.status_code}, {response.reason})")
208
+ # if self.logger:
209
+ # self.logger.error(f"Request failed: ({response.status_code}, {response.reason})")
213
210
  raise exceptions.FailedToGenerateResponseError(
214
211
  f"Failed to generate response - ({response.status_code}, {response.reason})"
215
212
  )
@@ -222,8 +219,8 @@ class Cloudflare(Provider):
222
219
  yield content if raw else dict(text=content)
223
220
  self.last_response.update(dict(text=streaming_response))
224
221
  self.conversation.update_chat_history(prompt, self.get_message(self.last_response))
225
- if self.logger:
226
- self.logger.info("Streaming response completed successfully")
222
+ # if self.logger:
223
+ # self.logger.info("Streaming response completed successfully")
227
224
 
228
225
  def for_non_stream():
229
226
  for _ in for_stream():
@@ -269,7 +266,7 @@ class Cloudflare(Provider):
269
266
 
270
267
  if __name__ == '__main__':
271
268
  from rich import print
272
- ai = Cloudflare(timeout=5000, logging=True)
269
+ ai = Cloudflare(timeout=5000)
273
270
  response = ai.chat("write a poem about AI", stream=True)
274
271
  for chunk in response:
275
272
  print(chunk, end="", flush=True)
@@ -1,13 +1,11 @@
1
-
2
1
  import requests
3
2
  import json
4
- from typing import Any, Dict, Optional, Generator
3
+ from typing import Any, Dict, Generator
5
4
  from webscout.AIutel import Optimizers
6
5
  from webscout.AIutel import Conversation
7
6
  from webscout.AIutel import AwesomePrompts
8
7
  from webscout.AIbase import Provider
9
8
  from webscout import exceptions
10
- from webscout.Litlogger import Logger, LogFormat
11
9
  from webscout import LitAgent as Lit
12
10
 
13
11
  class DeepSeek(Provider):
@@ -15,11 +13,11 @@ class DeepSeek(Provider):
15
13
  A class to interact with the DeepSeek AI API.
16
14
  """
17
15
 
18
- AVAILABLE_MODELS = {
19
- "deepseek-v3": "deepseek-v3",
20
- "deepseek-r1": "deepseek-r1",
21
- "deepseek-llm-67b-chat": "deepseek-llm-67b-chat"
22
- }
16
+ AVAILABLE_MODELS = [
17
+ "deepseek-v3",
18
+ "deepseek-r1",
19
+ "deepseek-llm-67b-chat"
20
+ ]
23
21
 
24
22
  def __init__(
25
23
  self,
@@ -33,8 +31,7 @@ class DeepSeek(Provider):
33
31
  history_offset: int = 10250,
34
32
  act: str = None,
35
33
  model: str = "deepseek-r1", # Default model
36
- system_prompt: str = "You are a helpful AI assistant.",
37
- logging: bool = False
34
+ system_prompt: str = "You are a helpful AI assistant."
38
35
  ):
39
36
  """
40
37
  Initializes the DeepSeek AI API with given parameters.
@@ -42,15 +39,6 @@ class DeepSeek(Provider):
42
39
  if model not in self.AVAILABLE_MODELS:
43
40
  raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS.keys()}")
44
41
 
45
- # Initialize logging
46
- self.logger = Logger(
47
- name="DeepSeek",
48
- format=LogFormat.MODERN_EMOJI,
49
- ) if logging else None
50
-
51
- if self.logger:
52
- self.logger.info(f"Initializing DeepSeek with model: {model}")
53
-
54
42
  self.session = requests.Session()
55
43
  self.is_conversation = is_conversation
56
44
  self.max_tokens_to_sample = max_tokens
@@ -93,20 +81,13 @@ class DeepSeek(Provider):
93
81
  conversationally: bool = False,
94
82
  ) -> Dict[str, Any]:
95
83
  """Chat with AI"""
96
- if self.logger:
97
- self.logger.debug(f"Processing request - Prompt: {prompt[:50]}...")
98
-
99
84
  conversation_prompt = self.conversation.gen_complete_prompt(prompt)
100
85
  if optimizer:
101
86
  if optimizer in self.__available_optimizers:
102
87
  conversation_prompt = getattr(Optimizers, optimizer)(
103
88
  conversation_prompt if conversationally else prompt
104
89
  )
105
- if self.logger:
106
- self.logger.debug(f"Applied optimizer: {optimizer}")
107
90
  else:
108
- if self.logger:
109
- self.logger.error(f"Invalid optimizer: {optimizer}")
110
91
  raise Exception(
111
92
  f"Optimizer is not one of {self.__available_optimizers}"
112
93
  )
@@ -122,13 +103,9 @@ class DeepSeek(Provider):
122
103
  }
123
104
 
124
105
  def for_stream():
125
- if self.logger:
126
- self.logger.debug("Sending streaming request to DeepInfra API...")
127
106
  try:
128
107
  with requests.post(self.api_endpoint, headers=self.headers, json=payload, stream=True, timeout=self.timeout) as response:
129
108
  if response.status_code != 200:
130
- if self.logger:
131
- self.logger.error(f"Request failed with status code {response.status_code}")
132
109
  raise exceptions.FailedToGenerateResponseError(
133
110
  f"Request failed with status code {response.status_code}"
134
111
  )
@@ -151,18 +128,12 @@ class DeepSeek(Provider):
151
128
  resp = {"text": content}
152
129
  yield resp if raw else resp
153
130
  except json.JSONDecodeError:
154
- if self.logger:
155
- self.logger.error("JSON decode error in streaming data")
156
131
  continue
157
132
 
158
133
  self.last_response = {"text": streaming_text}
159
134
  self.conversation.update_chat_history(prompt, streaming_text)
160
- if self.logger:
161
- self.logger.info("Streaming response completed successfully")
162
135
 
163
136
  except requests.RequestException as e:
164
- if self.logger:
165
- self.logger.error(f"Request failed: {e}")
166
137
  raise exceptions.FailedToGenerateResponseError(f"Request failed: {e}")
167
138
 
168
139
  def for_non_stream():
@@ -204,15 +175,23 @@ class DeepSeek(Provider):
204
175
  return response["text"]
205
176
 
206
177
  if __name__ == "__main__":
207
- from rich import print
208
-
209
- # Example usage
210
- ai = DeepSeek(system_prompt="You are an expert AI assistant.", logging=True)
211
-
212
- try:
213
- # Send a prompt and stream the response
214
- response = ai.chat("Write me a short poem about AI.", stream=True)
215
- for chunk in response:
216
- print(chunk, end="", flush=True)
217
- except Exception as e:
218
- print(f"Error: {e}")
178
+ print("-" * 80)
179
+ print(f"{'Model':<50} {'Status':<10} {'Response'}")
180
+ print("-" * 80)
181
+
182
+ for model in DeepSeek.AVAILABLE_MODELS:
183
+ try:
184
+ test_ai = DeepSeek(model=model, timeout=60)
185
+ response = test_ai.chat("Say 'Hello' in one word")
186
+ response_text = response
187
+
188
+ if response_text and len(response_text.strip()) > 0:
189
+ status = "✓"
190
+ # Truncate response if too long
191
+ display_text = response_text.strip()[:50] + "..." if len(response_text.strip()) > 50 else response_text.strip()
192
+ else:
193
+ status = "✗"
194
+ display_text = "Empty or invalid response"
195
+ print(f"{model:<50} {status:<10} {display_text}")
196
+ except Exception as e:
197
+ print(f"{model:<50} {'✗':<10} {str(e)}")
@@ -16,39 +16,48 @@ class DeepInfra(Provider):
16
16
  """
17
17
 
18
18
  AVAILABLE_MODELS = [
19
- "deepseek-ai/DeepSeek-R1-Turbo",
19
+ # "anthropic/claude-3-7-sonnet-latest", # >>>> NOT WORKING
20
20
  "deepseek-ai/DeepSeek-R1",
21
21
  "deepseek-ai/DeepSeek-R1-Distill-Llama-70B",
22
- "deepseek-ai/DeepSeek-V3",
23
- "meta-llama/Llama-3.3-70B-Instruct-Turbo",
24
- "mistralai/Mistral-Small-24B-Instruct-2501",
25
22
  "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
26
- "microsoft/phi-4",
27
- "meta-llama/Meta-Llama-3.1-70B-Instruct",
23
+ "deepseek-ai/DeepSeek-R1-Turbo",
24
+ "deepseek-ai/DeepSeek-V3",
25
+ # "google/gemma-2-27b-it", # >>>> NOT WORKING
26
+ # "google/gemma-2-9b-it", # >>>> NOT WORKING
27
+ "google/gemma-3-27b-it",
28
+ # "google/gemini-1.5-flash", # >>>> NOT WORKING
29
+ # "google/gemini-1.5-flash-8b", # >>>> NOT WORKING
30
+ # "google/gemini-2.0-flash-001", # >>>> NOT WORKING
31
+ # "Gryphe/MythoMax-L2-13b", # >>>> NOT WORKING
32
+ # "meta-llama/Llama-3.2-1B-Instruct", # >>>> NOT WORKING
33
+ # "meta-llama/Llama-3.2-3B-Instruct", # >>>> NOT WORKING
34
+ "meta-llama/Llama-3.2-90B-Vision-Instruct",
35
+ "meta-llama/Llama-3.2-11B-Vision-Instruct",
36
+ # "meta-llama/Meta-Llama-3-70B-Instruct", # >>>> NOT WORKING
37
+ # "meta-llama/Meta-Llama-3-8B-Instruct", # >>>> NOT WORKING
38
+ # "meta-llama/Meta-Llama-3.1-70B-Instruct", # >>>> NOT WORKING
39
+ "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
28
40
  "meta-llama/Meta-Llama-3.1-8B-Instruct",
29
- "meta-llama/Meta-Llama-3.1-405B-Instruct",
30
41
  "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
31
- "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
32
- "Qwen/Qwen2.5-Coder-32B-Instruct",
42
+ # "meta-llama/Meta-Llama-3.1-405B-Instruct", # >>>> NOT WORKING
43
+ "microsoft/phi-4",
44
+ "microsoft/Phi-4-multimodal-instruct",
45
+ "microsoft/WizardLM-2-8x22B",
46
+ # "mistralai/Mixtral-8x7B-Instruct-v0.1", # >>>> NOT WORKING
47
+ # "mistralai/Mistral-7B-Instruct-v0.3", # >>>> NOT WORKING
48
+ # "mistralai/Mistral-Nemo-Instruct-2407", # >>>> NOT WORKING
49
+ "mistralai/Mistral-Small-24B-Instruct-2501",
33
50
  "nvidia/Llama-3.1-Nemotron-70B-Instruct",
51
+ # "NousResearch/Hermes-3-Llama-3.1-405B", # >>>> NOT WORKING
52
+ # "NovaSky-AI/Sky-T1-32B-Preview", # >>>> NOT WORKING
53
+ "Qwen/QwQ-32B",
54
+ # "Qwen/Qwen2.5-7B-Instruct", # >>>> NOT WORKING
34
55
  "Qwen/Qwen2.5-72B-Instruct",
35
- "meta-llama/Llama-3.2-90B-Vision-Instruct",
36
- "meta-llama/Llama-3.2-11B-Vision-Instruct",
37
- "Gryphe/MythoMax-L2-13b",
38
- "NousResearch/Hermes-3-Llama-3.1-405B",
39
- "NovaSky-AI/Sky-T1-32B-Preview",
40
- "Qwen/Qwen2.5-7B-Instruct",
41
- "Sao10K/L3.1-70B-Euryale-v2.2",
42
- "Sao10K/L3.3-70B-Euryale-v2.3",
43
- "google/gemma-2-27b-it",
44
- "google/gemma-2-9b-it",
45
- "meta-llama/Llama-3.2-1B-Instruct",
46
- "meta-llama/Llama-3.2-3B-Instruct",
47
- "meta-llama/Meta-Llama-3-70B-Instruct",
48
- "meta-llama/Meta-Llama-3-8B-Instruct",
49
- "mistralai/Mistral-Nemo-Instruct-2407",
50
- "mistralai/Mistral-7B-Instruct-v0.3",
51
- "mistralai/Mixtral-8x7B-Instruct-v0.1"
56
+ "Qwen/Qwen2.5-Coder-32B-Instruct",
57
+ # "Sao10K/L3.1-70B-Euryale-v2.2", # >>>> NOT WORKING
58
+ # "Sao10K/L3.3-70B-Euryale-v2.3", # >>>> NOT WORKING
59
+ "meta-llama/Llama-3.3-70B-Instruct",
60
+ "meta-llama/Llama-3.3-70B-Instruct-Turbo",
52
61
  ]
53
62
 
54
63
  def __init__(
@@ -62,32 +71,41 @@ class DeepInfra(Provider):
62
71
  proxies: dict = {},
63
72
  history_offset: int = 10250,
64
73
  act: str = None,
65
- model: str = "meta-llama/Llama-3.3-70B-Instruct-Turbo" # Updated default model
74
+ model: str = "meta-llama/Llama-3.3-70B-Instruct-Turbo",
75
+ browser: str = "chrome"
66
76
  ):
67
77
  """Initializes the DeepInfra API client."""
68
78
  if model not in self.AVAILABLE_MODELS:
69
79
  raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
70
80
 
71
81
  self.url = "https://api.deepinfra.com/v1/openai/chat/completions"
72
- # Use LitAgent for user-agent instead of hardcoded string.
82
+
83
+ # Initialize LitAgent for user agent generation
84
+ self.agent = LitAgent()
85
+ # Use fingerprinting to create a consistent browser identity
86
+ self.fingerprint = self.agent.generate_fingerprint(browser)
87
+
88
+ # Use the fingerprint for headers
73
89
  self.headers = {
74
- 'User-Agent': LitAgent().random(),
75
- 'Accept-Language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
76
- 'Cache-Control': 'no-cache',
77
- 'Connection': 'keep-alive',
78
- 'Content-Type': 'application/json',
79
- 'Origin': 'https://deepinfra.com',
80
- 'Pragma': 'no-cache',
81
- 'Referer': 'https://deepinfra.com/',
82
- 'Sec-Fetch-Dest': 'empty',
83
- 'Sec-Fetch-Mode': 'cors',
84
- 'Sec-Fetch-Site': 'same-site',
85
- 'X-Deepinfra-Source': 'web-embed',
86
- 'accept': 'text/event-stream',
87
- 'sec-ch-ua': '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
88
- 'sec-ch-ua-mobile': '?0',
89
- 'sec-ch-ua-platform': '"macOS"'
90
+ "Accept": self.fingerprint["accept"],
91
+ "Accept-Encoding": "gzip, deflate, br, zstd",
92
+ "Accept-Language": self.fingerprint["accept_language"],
93
+ "Content-Type": "application/json",
94
+ "Cache-Control": "no-cache",
95
+ "Connection": "keep-alive",
96
+ "Origin": "https://deepinfra.com",
97
+ "Pragma": "no-cache",
98
+ "Referer": "https://deepinfra.com/",
99
+ "Sec-Fetch-Dest": "empty",
100
+ "Sec-Fetch-Mode": "cors",
101
+ "Sec-Fetch-Site": "same-site",
102
+ "X-Deepinfra-Source": "web-embed",
103
+ "Sec-CH-UA": self.fingerprint["sec_ch_ua"] or '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
104
+ "Sec-CH-UA-Mobile": "?0",
105
+ "Sec-CH-UA-Platform": f'"{self.fingerprint["platform"]}"',
106
+ "User-Agent": self.fingerprint["user_agent"],
90
107
  }
108
+
91
109
  self.session = requests.Session()
92
110
  self.session.headers.update(self.headers)
93
111
  self.session.proxies.update(proxies)
@@ -116,6 +134,31 @@ class DeepInfra(Provider):
116
134
  )
117
135
  self.conversation.history_offset = history_offset
118
136
 
137
+ def refresh_identity(self, browser: str = None):
138
+ """
139
+ Refreshes the browser identity fingerprint.
140
+
141
+ Args:
142
+ browser: Specific browser to use for the new fingerprint
143
+ """
144
+ browser = browser or self.fingerprint.get("browser_type", "chrome")
145
+ self.fingerprint = self.agent.generate_fingerprint(browser)
146
+
147
+ # Update headers with new fingerprint
148
+ self.headers.update({
149
+ "Accept": self.fingerprint["accept"],
150
+ "Accept-Language": self.fingerprint["accept_language"],
151
+ "Sec-CH-UA": self.fingerprint["sec_ch_ua"] or self.headers["Sec-CH-UA"],
152
+ "Sec-CH-UA-Platform": f'"{self.fingerprint["platform"]}"',
153
+ "User-Agent": self.fingerprint["user_agent"],
154
+ })
155
+
156
+ # Update session headers
157
+ for header, value in self.headers.items():
158
+ self.session.headers[header] = value
159
+
160
+ return self.fingerprint
161
+
119
162
  def ask(
120
163
  self,
121
164
  prompt: str,
@@ -171,15 +214,30 @@ class DeepInfra(Provider):
171
214
  except json.JSONDecodeError:
172
215
  continue
173
216
 
217
+ self.last_response = {"text": streaming_text}
174
218
  self.conversation.update_chat_history(prompt, streaming_text)
175
219
 
176
220
  except requests.RequestException as e:
177
221
  raise exceptions.FailedToGenerateResponseError(f"Request failed: {str(e)}")
178
222
 
179
223
  def for_non_stream():
180
- for _ in for_stream():
181
- pass
182
- return self.last_response
224
+ try:
225
+ response = requests.post(self.url, headers=self.headers, data=json.dumps(payload), timeout=self.timeout)
226
+ if response.status_code != 200:
227
+ raise exceptions.FailedToGenerateResponseError(
228
+ f"Request failed with status code {response.status_code}"
229
+ )
230
+
231
+ response_data = response.json()
232
+ if 'choices' in response_data and len(response_data['choices']) > 0:
233
+ content = response_data['choices'][0].get('message', {}).get('content', '')
234
+ self.last_response = {"text": content}
235
+ self.conversation.update_chat_history(prompt, content)
236
+ return {"text": content}
237
+ else:
238
+ raise exceptions.FailedToGenerateResponseError("No response content found")
239
+ except Exception as e:
240
+ raise exceptions.FailedToGenerateResponseError(f"Request failed: {e}")
183
241
 
184
242
  return for_stream() if stream else for_non_stream()
185
243
 
@@ -189,7 +247,7 @@ class DeepInfra(Provider):
189
247
  stream: bool = False,
190
248
  optimizer: str = None,
191
249
  conversationally: bool = False,
192
- ) -> str:
250
+ ) -> Union[str, Generator[str, None, None]]:
193
251
  def for_stream():
194
252
  for response in self.ask(prompt, True, optimizer=optimizer, conversationally=conversationally):
195
253
  yield self.get_message(response)
@@ -204,8 +262,26 @@ class DeepInfra(Provider):
204
262
  return response["text"]
205
263
 
206
264
  if __name__ == "__main__":
207
- from rich import print
208
- ai = DeepInfra(timeout=5000)
209
- response = ai.chat("write a poem about AI", stream=True)
210
- for chunk in response:
211
- print(chunk, end="", flush=True)
265
+ print("-" * 80)
266
+ print(f"{'Model':<50} {'Status':<10} {'Response'}")
267
+ print("-" * 80)
268
+
269
+ for model in DeepInfra.AVAILABLE_MODELS:
270
+ try:
271
+ test_ai = DeepInfra(model=model, timeout=60)
272
+ response = test_ai.chat("Say 'Hello' in one word", stream=True)
273
+ response_text = ""
274
+ for chunk in response:
275
+ response_text += chunk
276
+
277
+ if response_text and len(response_text.strip()) > 0:
278
+ status = "✓"
279
+ # Clean and truncate response
280
+ clean_text = response_text.strip().encode('utf-8', errors='ignore').decode('utf-8')
281
+ display_text = clean_text[:50] + "..." if len(clean_text) > 50 else clean_text
282
+ else:
283
+ status = "✗"
284
+ display_text = "Empty or invalid response"
285
+ print(f"\r{model:<50} {status:<10} {display_text}")
286
+ except Exception as e:
287
+ print(f"\r{model:<50} {'✗':<10} {str(e)}")
@@ -10,7 +10,7 @@ from ..AIbase import Provider, AsyncProvider
10
10
  from ..Bard import Chatbot, Model
11
11
 
12
12
  # Import Logger and related classes (assumed similar to what is in yep.py)
13
- from webscout import Logger, LogFormat
13
+ from webscout.Litlogger import Logger, LogFormat
14
14
 
15
15
  warnings.simplefilter("ignore", category=UserWarning)
16
16