webscout 6.0__py3-none-any.whl → 6.1__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/Agents/Onlinesearcher.py +22 -10
- webscout/Agents/functioncall.py +2 -2
- webscout/Bard.py +21 -21
- webscout/Local/__init__.py +6 -7
- webscout/Local/formats.py +404 -194
- webscout/Local/model.py +1074 -477
- webscout/Local/samplers.py +108 -144
- webscout/Local/thread.py +251 -410
- webscout/Local/ui.py +401 -0
- webscout/Local/utils.py +308 -131
- webscout/Provider/Amigo.py +1 -1
- webscout/Provider/NinjaChat.py +200 -0
- webscout/Provider/TTI/Nexra.py +3 -3
- webscout/Provider/TTI/__init__.py +2 -1
- webscout/Provider/TTI/aiforce.py +2 -2
- webscout/Provider/TTI/imgninza.py +136 -0
- webscout/Provider/Youchat.py +1 -1
- webscout/Provider/__init__.py +8 -1
- webscout/Provider/aimathgpt.py +193 -0
- webscout/Provider/felo_search.py +1 -1
- webscout/Provider/gaurish.py +168 -0
- webscout/Provider/geminiprorealtime.py +160 -0
- webscout/Provider/julius.py +4 -0
- webscout/exceptions.py +5 -1
- webscout/utils.py +3 -0
- webscout/version.py +1 -1
- webscout/webscout_search.py +154 -123
- {webscout-6.0.dist-info → webscout-6.1.dist-info}/METADATA +123 -120
- {webscout-6.0.dist-info → webscout-6.1.dist-info}/RECORD +33 -28
- webscout/Local/rawdog.py +0 -946
- {webscout-6.0.dist-info → webscout-6.1.dist-info}/LICENSE.md +0 -0
- {webscout-6.0.dist-info → webscout-6.1.dist-info}/WHEEL +0 -0
- {webscout-6.0.dist-info → webscout-6.1.dist-info}/entry_points.txt +0 -0
- {webscout-6.0.dist-info → webscout-6.1.dist-info}/top_level.txt +0 -0
|
@@ -2,14 +2,14 @@ import json
|
|
|
2
2
|
import httpx
|
|
3
3
|
from bs4 import BeautifulSoup
|
|
4
4
|
from typing import List, Dict
|
|
5
|
-
from webscout import
|
|
5
|
+
from webscout import GoogleS, GEMINIAPI
|
|
6
6
|
import re
|
|
7
7
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class WebSearchAgent:
|
|
11
11
|
def __init__(self):
|
|
12
|
-
self.webs =
|
|
12
|
+
self.webs = GoogleS()
|
|
13
13
|
self.ai = GEMINIAPI(is_conversation=False, api_key='AIzaSyAYlT5-V0MXZwaLYpXCF1Z-Yvy_tx1jylA')
|
|
14
14
|
|
|
15
15
|
def generate_search_queries(self, information: str, num_queries: int = 10) -> List[str]:
|
|
@@ -62,16 +62,16 @@ Now, generate the optimal search queries: """
|
|
|
62
62
|
else:
|
|
63
63
|
return [information]
|
|
64
64
|
|
|
65
|
-
def search(self, information: str, region: str = 'wt-wt',
|
|
66
|
-
|
|
65
|
+
def search(self, information: str, region: str = 'wt-wt', safe: str = 'off',
|
|
66
|
+
max_results: int = 10) -> List[Dict]:
|
|
67
67
|
search_queries = self.generate_search_queries(information, num_queries=10)
|
|
68
68
|
all_results = []
|
|
69
69
|
|
|
70
70
|
for query in search_queries:
|
|
71
71
|
results = []
|
|
72
72
|
with self.webs as webs:
|
|
73
|
-
for result in webs.
|
|
74
|
-
|
|
73
|
+
for result in webs.search(query, region=region, safe=safe,
|
|
74
|
+
max_results=max_results):
|
|
75
75
|
results.append(result)
|
|
76
76
|
all_results.extend(results)
|
|
77
77
|
|
|
@@ -113,7 +113,7 @@ Now, generate the optimal search queries: """
|
|
|
113
113
|
class OnlineSearcher:
|
|
114
114
|
def __init__(self):
|
|
115
115
|
self.agent = WebSearchAgent()
|
|
116
|
-
self.ai = GEMINIAPI(is_conversation=False, api_key='
|
|
116
|
+
self.ai = GEMINIAPI(is_conversation=False, api_key='GOOGLE GEMINI API')
|
|
117
117
|
|
|
118
118
|
def answer_question(self, question: str) -> None:
|
|
119
119
|
search_results = self.agent.search(question, max_results=10)
|
|
@@ -148,7 +148,7 @@ Instructions:
|
|
|
148
148
|
Your response should be informative, accurate, and properly sourced when possible. Begin your answer now: """
|
|
149
149
|
|
|
150
150
|
for chunk in self.ai.chat(prompt, stream=True):
|
|
151
|
-
print(chunk, end='', flush=True)
|
|
151
|
+
print(chunk, end='', flush=True)
|
|
152
152
|
|
|
153
153
|
|
|
154
154
|
|
|
@@ -161,10 +161,22 @@ if __name__ == "__main__":
|
|
|
161
161
|
if question.lower() == 'quit':
|
|
162
162
|
break
|
|
163
163
|
print("=" * 50)
|
|
164
|
-
assistant.answer_question(question)
|
|
164
|
+
assistant.answer_question(question)
|
|
165
165
|
print("=" * 50)
|
|
166
166
|
except KeyboardInterrupt:
|
|
167
167
|
print("\nExiting.")
|
|
168
168
|
break
|
|
169
169
|
except Exception as e:
|
|
170
|
-
print(f"An error occurred: {e}")
|
|
170
|
+
print(f"An error occurred: {e}")
|
|
171
|
+
|
|
172
|
+
"""
|
|
173
|
+
def format_prompt(messages: Messages, add_special_tokens=False) -> str:
|
|
174
|
+
|
|
175
|
+
if not add_special_tokens and len(messages) <= 1:
|
|
176
|
+
return messages[0]["content"]
|
|
177
|
+
formatted = "\n".join([
|
|
178
|
+
f'{message["role"].capitalize()}: {message["content"]}'
|
|
179
|
+
for message in messages
|
|
180
|
+
])
|
|
181
|
+
return f"{formatted}\nAssistant:
|
|
182
|
+
"""
|
webscout/Agents/functioncall.py
CHANGED
|
@@ -4,12 +4,12 @@ import json
|
|
|
4
4
|
import time
|
|
5
5
|
from typing import Any, Dict, Optional
|
|
6
6
|
import requests
|
|
7
|
-
from webscout import WEBS,
|
|
7
|
+
from webscout import WEBS, Julius
|
|
8
8
|
|
|
9
9
|
class FunctionCallingAgent:
|
|
10
10
|
def __init__(self,
|
|
11
11
|
tools: list = None):
|
|
12
|
-
self.ai =
|
|
12
|
+
self.ai = Julius(timeout=300, intro=None)
|
|
13
13
|
self.tools = tools if tools is not None else []
|
|
14
14
|
self.knowledge_cutoff = "September 2022"
|
|
15
15
|
|
webscout/Bard.py
CHANGED
|
@@ -6,8 +6,7 @@ import random
|
|
|
6
6
|
import re
|
|
7
7
|
import string
|
|
8
8
|
import sys
|
|
9
|
-
from typing import Dict
|
|
10
|
-
from typing import List
|
|
9
|
+
from typing import Dict, List, Tuple
|
|
11
10
|
|
|
12
11
|
import httpx
|
|
13
12
|
from prompt_toolkit import prompt
|
|
@@ -48,6 +47,22 @@ def __get_input(
|
|
|
48
47
|
)
|
|
49
48
|
|
|
50
49
|
|
|
50
|
+
def load_cookies(cookie_path: str) -> Tuple[str, str]:
|
|
51
|
+
"""Loads cookies from the provided JSON file."""
|
|
52
|
+
try:
|
|
53
|
+
with open(cookie_path, 'r') as file:
|
|
54
|
+
cookies = json.load(file)
|
|
55
|
+
session_auth1 = next(item['value'] for item in cookies if item['name'] == '__Secure-1PSID')
|
|
56
|
+
session_auth2 = next(item['value'] for item in cookies if item['name'] == '__Secure-1PSIDTS')
|
|
57
|
+
return session_auth1, session_auth2
|
|
58
|
+
except FileNotFoundError:
|
|
59
|
+
raise Exception(f"Cookie file not found at path: {cookie_path}")
|
|
60
|
+
except json.JSONDecodeError:
|
|
61
|
+
raise Exception("Invalid JSON format in the cookie file.")
|
|
62
|
+
except StopIteration:
|
|
63
|
+
raise Exception("Required cookies not found in the cookie file.")
|
|
64
|
+
|
|
65
|
+
|
|
51
66
|
class Chatbot:
|
|
52
67
|
"""
|
|
53
68
|
Synchronous wrapper for the AsyncChatbot class.
|
|
@@ -55,14 +70,14 @@ class Chatbot:
|
|
|
55
70
|
|
|
56
71
|
def __init__(
|
|
57
72
|
self,
|
|
58
|
-
|
|
59
|
-
secure_1psidts: str,
|
|
73
|
+
cookie_path: str,
|
|
60
74
|
proxy: dict = None,
|
|
61
75
|
timeout: int = 20,
|
|
62
76
|
):
|
|
63
77
|
self.loop = asyncio.get_event_loop()
|
|
78
|
+
self.secure_1psid, self.secure_1psidts = load_cookies(cookie_path)
|
|
64
79
|
self.async_chatbot = self.loop.run_until_complete(
|
|
65
|
-
AsyncChatbot.create(secure_1psid, secure_1psidts, proxy, timeout),
|
|
80
|
+
AsyncChatbot.create(self.secure_1psid, self.secure_1psidts, proxy, timeout),
|
|
66
81
|
)
|
|
67
82
|
|
|
68
83
|
def save_conversation(self, file_path: str, conversation_name: str):
|
|
@@ -309,22 +324,7 @@ class AsyncChatbot:
|
|
|
309
324
|
|
|
310
325
|
if __name__ == "__main__":
|
|
311
326
|
import sys
|
|
312
|
-
|
|
313
|
-
if os.getenv("Gemini_QUICK"):
|
|
314
|
-
Secure_1PSID = os.getenv("Gemini__Secure_1PSID")
|
|
315
|
-
secure_1psidts = os.getenv("Gemini__secure_1psidts")
|
|
316
|
-
if not (Secure_1PSID and secure_1psidts):
|
|
317
|
-
print(
|
|
318
|
-
"Gemini__Secure_1PSID or Gemini__secure_1psidts environment variable not set.",
|
|
319
|
-
)
|
|
320
|
-
sys.exit(1)
|
|
321
|
-
chatbot = Chatbot(Secure_1PSID, secure_1psidts)
|
|
322
|
-
# Join arguments into a single string
|
|
323
|
-
MESSAGE = " ".join(sys.argv[1:])
|
|
324
|
-
response = chatbot.ask(MESSAGE)
|
|
325
|
-
console.print(Markdown(response["content"]))
|
|
326
|
-
console.print(response["images"] if response.get("images") else "")
|
|
327
|
-
sys.exit(0)
|
|
327
|
+
sys.exit(0)
|
|
328
328
|
parser = argparse.ArgumentParser()
|
|
329
329
|
parser.add_argument(
|
|
330
330
|
"--session",
|
webscout/Local/__init__.py
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
from ._version import __version__, __llama_cpp_version__
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
from . import
|
|
6
|
-
from . import
|
|
7
|
-
from . import
|
|
8
|
-
|
|
9
|
-
from .model import
|
|
10
|
-
from .thread import
|
|
11
|
-
from .rawdog import *
|
|
5
|
+
from .utils import *
|
|
6
|
+
from .samplers import *
|
|
7
|
+
from .formats import *
|
|
8
|
+
from .ui import *
|
|
9
|
+
from .model import *
|
|
10
|
+
from .thread import *
|