webscout 5.2__py3-none-any.whl → 5.4__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 (58) hide show
  1. webscout/AIauto.py +8 -12
  2. webscout/AIutel.py +10 -10
  3. webscout/Agents/Onlinesearcher.py +5 -5
  4. webscout/Agents/functioncall.py +123 -97
  5. webscout/DWEBS.py +99 -77
  6. webscout/Local/_version.py +2 -2
  7. webscout/Provider/Andi.py +1 -21
  8. webscout/Provider/BasedGPT.py +1 -21
  9. webscout/Provider/Blackboxai.py +1 -21
  10. webscout/Provider/Chatify.py +175 -0
  11. webscout/Provider/Cloudflare.py +1 -22
  12. webscout/Provider/Cohere.py +2 -23
  13. webscout/Provider/DARKAI.py +0 -1
  14. webscout/Provider/Deepinfra.py +2 -16
  15. webscout/Provider/EDITEE.py +3 -26
  16. webscout/Provider/Gemini.py +1 -24
  17. webscout/Provider/Groq.py +0 -2
  18. webscout/Provider/Koboldai.py +0 -21
  19. webscout/Provider/Llama.py +4 -21
  20. webscout/Provider/NetFly.py +21 -61
  21. webscout/Provider/OLLAMA.py +0 -17
  22. webscout/Provider/Openai.py +2 -22
  23. webscout/Provider/Perplexity.py +1 -2
  24. webscout/Provider/Phind.py +3 -508
  25. webscout/Provider/RUBIKSAI.py +11 -5
  26. webscout/Provider/Reka.py +4 -21
  27. webscout/Provider/TTS/streamElements.py +1 -22
  28. webscout/Provider/TTS/voicepod.py +11 -8
  29. webscout/Provider/ThinkAnyAI.py +17 -78
  30. webscout/Provider/Youchat.py +3 -20
  31. webscout/Provider/__init__.py +17 -8
  32. webscout/Provider/ai4chat.py +14 -8
  33. webscout/Provider/cerebras.py +199 -0
  34. webscout/Provider/{Berlin4h.py → cleeai.py} +68 -73
  35. webscout/Provider/{liaobots.py → elmo.py} +75 -106
  36. webscout/Provider/felo_search.py +29 -87
  37. webscout/Provider/geminiapi.py +198 -0
  38. webscout/Provider/genspark.py +222 -0
  39. webscout/Provider/julius.py +3 -20
  40. webscout/Provider/koala.py +1 -1
  41. webscout/Provider/lepton.py +194 -0
  42. webscout/Provider/turboseek.py +4 -21
  43. webscout/Provider/x0gpt.py +182 -0
  44. webscout/Provider/xdash.py +2 -22
  45. webscout/Provider/yep.py +391 -149
  46. webscout/YTdownloader.py +2 -3
  47. webscout/__init__.py +2 -2
  48. webscout/exceptions.py +2 -1
  49. webscout/transcriber.py +195 -140
  50. webscout/version.py +1 -1
  51. {webscout-5.2.dist-info → webscout-5.4.dist-info}/METADATA +47 -134
  52. webscout-5.4.dist-info/RECORD +98 -0
  53. webscout/voice.py +0 -34
  54. webscout-5.2.dist-info/RECORD +0 -93
  55. {webscout-5.2.dist-info → webscout-5.4.dist-info}/LICENSE.md +0 -0
  56. {webscout-5.2.dist-info → webscout-5.4.dist-info}/WHEEL +0 -0
  57. {webscout-5.2.dist-info → webscout-5.4.dist-info}/entry_points.txt +0 -0
  58. {webscout-5.2.dist-info → webscout-5.4.dist-info}/top_level.txt +0 -0
webscout/AIauto.py CHANGED
@@ -9,11 +9,8 @@ from webscout.Provider.Perplexity import Perplexity
9
9
  from webscout.Provider.Blackboxai import BLACKBOXAI
10
10
  from webscout.Provider.Blackboxai import AsyncBLACKBOXAI
11
11
  from webscout.Provider.Phind import PhindSearch
12
- from webscout.Provider.Phind import AsyncPhindSearch
13
12
  from webscout.Provider.Phind import Phindv2
14
- from webscout.Provider.Phind import AsyncPhindv2
15
13
  from webscout.Provider.yep import YEPCHAT
16
- from webscout.Provider.Berlin4h import Berlin4h
17
14
  from webscout.Provider.Poe import POE
18
15
  from webscout.Provider.BasedGPT import BasedGPT
19
16
  from webscout.Provider.Deepseek import DeepSeek
@@ -25,7 +22,7 @@ from webscout.Provider.DARKAI import DARKAI
25
22
  from webscout.Provider.koala import KOALA
26
23
  from webscout.Provider.RUBIKSAI import RUBIKSAI
27
24
  from webscout.Provider.meta import Meta
28
- from webscout.Provider.liaobots import LiaoBots
25
+
29
26
  from webscout.Provider.DiscordRocks import DiscordRocks
30
27
  from webscout.Provider.felo_search import Felo
31
28
  from webscout.Provider.xdash import XDASH
@@ -35,7 +32,7 @@ from webscout.Provider.Cloudflare import Cloudflare
35
32
  from webscout.Provider.turboseek import TurboSeek
36
33
  from webscout.Provider.NetFly import NetFly
37
34
  from webscout.Provider.EDITEE import Editee
38
- # from webscout.Provider.Chatify import Chatify # TODO: UNFINISHED
35
+ from webscout.Provider.Chatify import Chatify
39
36
  from webscout.Provider.PI import PiAI
40
37
  from webscout.g4f import GPT4FREE, AsyncGPT4FREE
41
38
  from webscout.g4f import TestProviders
@@ -58,7 +55,6 @@ provider_map: dict[
58
55
  PhindSearch,
59
56
  Phindv2,
60
57
  YEPCHAT,
61
- Berlin4h,
62
58
  POE,
63
59
  BasedGPT,
64
60
  DeepSeek,
@@ -72,7 +68,7 @@ provider_map: dict[
72
68
  KOALA,
73
69
  RUBIKSAI,
74
70
  Meta,
75
- LiaoBots,
71
+
76
72
  DiscordRocks,
77
73
  Felo,
78
74
  XDASH,
@@ -82,7 +78,7 @@ provider_map: dict[
82
78
  TurboSeek,
83
79
  NetFly,
84
80
  Editee,
85
- # Chatify,
81
+ Chatify,
86
82
  PiAI,
87
83
  ],
88
84
  ] = {
@@ -94,7 +90,7 @@ provider_map: dict[
94
90
  "PhindSearch": PhindSearch,
95
91
  "Phindv2": Phindv2,
96
92
  "YEPCHAT": YEPCHAT,
97
- "Berlin4h": Berlin4h,
93
+
98
94
  "POE": POE,
99
95
  "BasedGPT": BasedGPT,
100
96
  "DeepSeek": DeepSeek,
@@ -108,7 +104,7 @@ provider_map: dict[
108
104
  "koala": KOALA,
109
105
  "rubiksai": RUBIKSAI,
110
106
  "meta": Meta,
111
- "liaobots": LiaoBots,
107
+
112
108
  "discordrocks": DiscordRocks,
113
109
  "felo": Felo,
114
110
  "xdash": XDASH,
@@ -160,7 +156,7 @@ class AUTO(Provider):
160
156
  PhindSearch,
161
157
  Phindv2,
162
158
  YEPCHAT,
163
- Berlin4h,
159
+
164
160
  POE,
165
161
  BasedGPT,
166
162
  DeepSeek,
@@ -174,7 +170,7 @@ class AUTO(Provider):
174
170
  KOALA,
175
171
  RUBIKSAI,
176
172
  Meta,
177
- LiaoBots,
173
+
178
174
  DiscordRocks,
179
175
  Felo,
180
176
  XDASH,
webscout/AIutel.py CHANGED
@@ -594,16 +594,16 @@ w.print_weather(weather)
594
594
  interpreter (str, optional): Python's interpreter name. Defaults to Python.
595
595
  prettify (bool, optional): Prettify the code on stdout. Defaults to True.
596
596
  """
597
- if not quiet:
598
- print(
599
- "Rawdog is an experimental tool that generates and auto-executes Python scripts in the cli.\n"
600
- "To get the most out of Rawdog. Ensure the following are installed:\n"
601
- " 1. Python 3.x\n"
602
- " 2. Dependency:\n"
603
- " - Matplotlib\n"
604
- "Be alerted on the risk posed! (Experimental)\n"
605
- "Use '--quiet' to suppress this message and code/logs stdout.\n"
606
- )
597
+ # if not quiet:
598
+ # print(
599
+ # "Rawdog is an experimental tool that generates and auto-executes Python scripts in the cli.\n"
600
+ # "To get the most out of Rawdog. Ensure the following are installed:\n"
601
+ # " 1. Python 3.x\n"
602
+ # " 2. Dependency:\n"
603
+ # " - Matplotlib\n"
604
+ # "Be alerted on the risk posed! (Experimental)\n"
605
+ # "Use '--quiet' to suppress this message and code/logs stdout.\n"
606
+ # )
607
607
  self.internal_exec = internal_exec
608
608
  self.confirm_script = confirm_script
609
609
  self.quiet = quiet
@@ -10,7 +10,7 @@ import logging
10
10
  class WebSearchAgent:
11
11
  def __init__(self):
12
12
  self.webs = WEBS()
13
- self.ai = LLAMA3(system="You are an advanced AI assistant specialized in generating optimal search queries and providing comprehensive answers based on web search results.")
13
+ self.ai = LLAMA3(system="You are an advanced AI assistant specialized in generating optimal search queries and providing comprehensive answers based on web search results.", is_conversation=False)
14
14
 
15
15
  def generate_search_queries(self, information, num_queries=3):
16
16
  prompt = f"""
@@ -94,8 +94,8 @@ class WebSearchAgent:
94
94
  paragraphs = soup.find_all('p')
95
95
  text = ' '.join([p.get_text() for p in paragraphs])
96
96
  words = text.split()
97
- if len(words) > 150:
98
- text = ' '.join(words[:150]) + '...'
97
+ if len(words) > 600:
98
+ text = ' '.join(words[:600]) + '...'
99
99
  return text
100
100
  else:
101
101
  return f"Failed to fetch {url}: HTTP {response.status}"
@@ -112,7 +112,7 @@ class WebSearchAgent:
112
112
  class OnlineSearcher:
113
113
  def __init__(self):
114
114
  self.agent = WebSearchAgent()
115
- self.ai = LLAMA3(system="You are an advanced AI assistant specialized in providing comprehensive and accurate answers based on web search results and your general knowledge.")
115
+ self.ai = LLAMA3(system="You are an advanced AI assistant specialized in providing comprehensive and accurate answers based on web search results and your general knowledge.", is_conversation=False)
116
116
 
117
117
  def answer_question(self, question: str):
118
118
  search_results = self.agent.search(question)
@@ -125,7 +125,7 @@ class OnlineSearcher:
125
125
 
126
126
  context += "Extracted webpage contents:\n"
127
127
  for i, webpage in enumerate(webpage_contents):
128
- context += f"{i}. URL: {webpage['url']}\n Content: {webpage['content'][:150]}...\n\n"
128
+ context += f"{i}. URL: {webpage['url']}\n Content: {webpage['content'][:600]}...\n\n"
129
129
 
130
130
  prompt = f"""
131
131
  Task: Provide a comprehensive and accurate answer to the given question based on the provided web search results and your general knowledge.
@@ -1,159 +1,170 @@
1
+ from datetime import date
1
2
  import json
2
- import logging
3
+ # import logging
3
4
  import time
4
5
  from typing import Any, Dict, Optional
5
-
6
6
  import requests
7
- from webscout import WEBS # Import only WEBS from webscout
8
-
9
- class LLAMA3:
10
-
11
- AVAILABLE_MODELS = ["llama3-70b", "llama3-8b", "llama3-405b"]
12
-
13
- def __init__(
14
- self,
15
- is_conversation: bool = True,
16
- max_tokens: int = 600,
17
- timeout: int = 30,
18
- model: str = "llama3-8b",
19
- system: str = "GPT syle",
20
- proxies: dict = {}, # Add proxies parameter
21
- ):
22
- """Instantiates Snova
23
-
24
- Args:
25
- is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
26
- max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
27
- timeout (int, optional): Http request timeout. Defaults to 30.
28
- model (str, optional): Snova model name. Defaults to "llama3-70b".
29
- system (str, optional): System prompt for Snova. Defaults to "Answer as concisely as possible.".
30
- proxies (dict, optional): Proxy settings for requests. Defaults to an empty dictionary.
31
- """
32
- if model not in self.AVAILABLE_MODELS:
33
- raise ValueError(f"Invalid model: {model}. Choose from: {self.AVAILABLE_MODELS}")
34
-
35
- self.session = requests.Session()
36
- self.is_conversation = is_conversation
37
- self.max_tokens_to_sample = max_tokens
38
- self.timeout = timeout
39
- self.model = model
40
- self.system = system
41
- self.last_response = {}
42
- self.env_type = "tp16405b" if "405b" in model else "tp16"
43
- self.headers = {'content-type': 'application/json'}
44
- self.session.headers.update(self.headers)
45
- self.session.proxies = proxies
46
-
47
- def chat(self, prompt: str) -> str:
48
- data = {'body': {'messages': [{'role': 'system', 'content': self.system}, {'role': 'user', 'content': prompt}], 'stream': True, 'model': self.model}, 'env_type': self.env_type}
49
- response = self.session.post('https://fast.snova.ai/api/completion', headers=self.headers, json=data, stream=True, timeout=self.timeout)
50
- output = ''
51
- for line in response.iter_lines(decode_unicode=True):
52
- if line.startswith('data:'):
53
- try:
54
- data = json.loads(line[len('data: '):])
55
- output += data.get("choices", [{}])[0].get("delta", {}).get("content", '')
56
- except json.JSONDecodeError:
57
- if line[len('data: '):] == '[DONE]':
58
- break
59
- return output
7
+ from webscout import WEBS, Julius
60
8
 
61
9
  class FunctionCallingAgent:
62
- def __init__(self, model: str = "llama3-8b",
63
- system_prompt: str = 'You are a helpful assistant that will always answer what the user wants',
10
+ def __init__(self, model: str = "GPT-4o",
64
11
  tools: list = None):
65
- self.LLAMA3 = LLAMA3(model=model, system=system_prompt, timeout=300)
12
+ self.ai = Julius(model=model, timeout=300, intro=None)
66
13
  self.tools = tools if tools is not None else []
67
- self.webs = WEBS()
14
+ self.knowledge_cutoff = "September 2022"
68
15
 
69
16
  def function_call_handler(self, message_text: str) -> dict:
70
17
  system_message = self._generate_system_message(message_text)
71
- response = self.LLAMA3.chat(system_message)
18
+ response = self.ai.chat(system_message)
72
19
  # logging.info(f"Raw response: {response}")
73
20
  return self._parse_function_call(response)
74
21
 
75
22
  def _generate_system_message(self, user_message: str) -> str:
76
- tools_description = '\n'.join([f"- {tool['function']['name']}: {tool['function'].get('description', '')}" for tool in self.tools])
77
- return (
78
- "You are an AI assistant capable of understanding user requests and using tools to fulfill them. "
79
- "Always respond using the JSON format specified below, even if you're not sure about the answer. "
80
- f"Available tools:\n{tools_description}\n\n"
81
- "Instructions:\n"
82
- "1. Analyze the user's request.\n"
83
- "2. Choose the most appropriate tool based on the request.\n"
84
- "3. Respond ONLY with a JSON object in this exact format:\n"
85
- "{\n"
86
- ' "tool_name": "name_of_the_tool",\n'
87
- ' "tool_input": {\n'
88
- ' "param1": "value1",\n'
89
- ' "param2": "value2"\n'
90
- " }\n"
91
- "}\n\n"
92
- "If you can't determine a suitable tool, use the 'general_ai' tool with the user's message as the 'question' parameter.\n\n"
93
- f"User request: {user_message}\n\n"
94
- "Your response (in JSON format):"
95
- )
23
+ tools_description = ""
24
+ for tool in self.tools:
25
+ tools_description += f"- {tool['function']['name']}: {tool['function'].get('description', '')}\n"
26
+ tools_description += " Parameters:\n"
27
+ for key, value in tool['function']['parameters']['properties'].items():
28
+ tools_description += f" - {key}: {value.get('description', '')} ({value.get('type')})\n"
29
+
30
+ current_date = date.today().strftime("%B %d, %Y")
31
+ return f"""Today is {current_date}. Your knowledge is current up to {self.knowledge_cutoff}.
32
+
33
+ You are an advanced AI assistant tasked with analyzing user requests and determining the most appropriate action. You have access to the following tools:
34
+
35
+ {tools_description}
36
+
37
+ Instructions:
38
+ 1. Carefully analyze the user's request.
39
+ 2. If the user request is about controlling the web browser (opening websites, searching, playing videos, etc.), ALWAYS use the 'browser_control' tool.
40
+ 3. If the user request is something else, determine if any of the other provided tools are necessary to fulfill the request.
41
+ 4. If a tool is needed, select the MOST APPROPRIATE one. Do not use a tool if it's not directly relevant to the user's request.
42
+ 5. If you decide to use a tool, respond ONLY with a JSON object in this format:
43
+ {{
44
+ "tool_name": "name_of_the_tool",
45
+ "tool_input": {{
46
+ "param1": "value1",
47
+ "param2": "value2"
48
+ }}
49
+ }}
50
+
51
+ - Use the exact tool name as listed above.
52
+ - Include only the necessary parameters for the chosen tool.
53
+ - Do not include any explanations or additional text outside the JSON object.
54
+
55
+ 6. If no tool is needed and you can answer directly, respond with:
56
+ {{
57
+ "tool_name": "general_ai",
58
+ "tool_input": {{
59
+ "question": "user's original question"
60
+ }}
61
+ }}
62
+
63
+ User Request: {user_message}
64
+
65
+ Your Response (JSON only):"""
96
66
 
97
67
  def _parse_function_call(self, response: str) -> dict:
98
68
  try:
99
- # Find the JSON-like part of the response
69
+ # Ensure to locate the start and end of the JSON structure
100
70
  start_idx = response.find("{")
101
71
  end_idx = response.rfind("}") + 1
102
72
 
103
73
  if start_idx == -1 or end_idx == -1:
104
74
  raise ValueError("No valid JSON structure found in the response.")
105
75
 
76
+ # Extract the JSON string
106
77
  response_json_str = response[start_idx:end_idx]
107
-
108
- # Attempt to load the JSON string
109
- return json.loads(response_json_str)
78
+
79
+ # Load the JSON string
80
+ parsed_response = json.loads(response_json_str)
81
+
82
+ # Check for the expected format
83
+ if "tool_name" in parsed_response and "tool_input" in parsed_response:
84
+ return parsed_response
85
+
86
+ # If not in the expected format, try to convert
87
+ for key, value in parsed_response.items():
88
+ if isinstance(value, dict):
89
+ return {
90
+ "tool_name": key,
91
+ "tool_input": value
92
+ }
93
+
94
+ # If the response structure is still incorrect
95
+ raise ValueError("Invalid response structure: missing required fields.")
110
96
 
111
97
  except (ValueError, json.JSONDecodeError) as e:
112
- logging.error(f"Error parsing function call: {e}")
98
+ # logging.error(f"Error parsing function call: {e}")
113
99
  return {"error": str(e)}
114
100
 
101
+
115
102
  def execute_function(self, function_call_data: dict) -> str:
116
103
  function_name = function_call_data.get("tool_name")
117
104
  arguments = function_call_data.get("tool_input", {})
118
105
 
119
106
  if not isinstance(arguments, dict):
120
- logging.error("Invalid arguments format.")
107
+ # logging.error("Invalid arguments format.")
121
108
  return "Invalid arguments format."
122
109
 
123
- logging.info(f"Executing function: {function_name} with arguments: {arguments}")
110
+ # logging.info(f"Executing function: {function_name} with arguments: {arguments}")
124
111
 
125
112
 
126
113
  # Example usage
127
114
  if __name__ == "__main__":
115
+ # Configure logging
116
+ # logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
117
+
128
118
  tools = [
129
119
  {
130
120
  "type": "function",
131
121
  "function": {
132
122
  "name": "web_search",
133
- "description": "Search query on Google",
123
+ "description": "Search the web for current information on a given query",
134
124
  "parameters": {
135
125
  "type": "object",
136
126
  "properties": {
137
127
  "query": {
138
128
  "type": "string",
139
- "description": "web search query"
129
+ "description": "The search query to be executed"
140
130
  }
141
131
  },
142
132
  "required": ["query"]
143
133
  }
144
134
  }
145
135
  },
136
+ {
137
+ "type": "function",
138
+ "function": {
139
+ "name": "get_user_detail",
140
+ "description": "Get the user's name and age.",
141
+ "parameters": {
142
+ "type": "object",
143
+ "properties": {
144
+ "name": {
145
+ "type": "string",
146
+ "description": "The user's name."
147
+ },
148
+ "age": {
149
+ "type": "integer",
150
+ "description": "The user's age."
151
+ }
152
+ },
153
+ "required": ["name", "age"]
154
+ }
155
+ }
156
+ },
146
157
  {
147
158
  "type": "function",
148
159
  "function": {
149
160
  "name": "general_ai",
150
- "description": "Use AI to answer a general question",
161
+ "description": "Use AI to answer general questions or perform tasks not requiring external tools",
151
162
  "parameters": {
152
163
  "type": "object",
153
164
  "properties": {
154
165
  "question": {
155
166
  "type": "string",
156
- "description": "The question to be answered by the AI"
167
+ "description": "The question or task for the AI to process"
157
168
  }
158
169
  },
159
170
  "required": ["question"]
@@ -163,10 +174,25 @@ if __name__ == "__main__":
163
174
  ]
164
175
 
165
176
  agent = FunctionCallingAgent(tools=tools)
166
- message = "open yt"
167
- function_call_data = agent.function_call_handler(message)
168
- print(f"Function Call Data: {function_call_data}")
177
+
178
+ # Test cases
179
+ test_messages = [
180
+ "What's the weather like in New York today?",
181
+ "Who won the last FIFA World Cup?",
182
+ "Can you explain quantum computing?",
183
+ "What are the latest developments in AI?",
184
+ "Tell me a joke about programming.",
185
+ "What's the meaning of life?",
186
+ "Get user details name as John and age as 30"
187
+ ]
188
+
189
+ for message in test_messages:
190
+ print(f"\nProcessing: {message}")
191
+ function_call_data = agent.function_call_handler(message)
192
+ print(f"Function Call Data: {function_call_data}")
169
193
 
170
- if "error" not in function_call_data:
171
- result = agent.execute_function(function_call_data)
172
- print(f"Function Execution Result: {result}")
194
+ if "error" not in function_call_data:
195
+ result = agent.execute_function(function_call_data)
196
+ print(f"Function Execution Result: {result}")
197
+ else:
198
+ print(f"Error: {function_call_data['error']}")