webscout 6.5__py3-none-any.whl → 6.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.
- webscout/Extra/autocoder/autocoder_utiles.py +119 -101
- 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 +235 -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/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/conversation.py +24 -9
- webscout/exceptions.py +188 -20
- webscout/litprinter/__init__.py +4 -117
- 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/zeroart/base.py +15 -16
- webscout/zeroart/effects.py +1 -1
- webscout/zeroart/fonts.py +1 -1
- {webscout-6.5.dist-info → webscout-6.6.dist-info}/METADATA +8 -165
- {webscout-6.5.dist-info → webscout-6.6.dist-info}/RECORD +59 -41
- webscout-6.6.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.6.dist-info}/LICENSE.md +0 -0
- {webscout-6.5.dist-info → webscout-6.6.dist-info}/WHEEL +0 -0
- {webscout-6.5.dist-info → webscout-6.6.dist-info}/entry_points.txt +0 -0
webscout/update_checker.py
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
Ayy, check it out! 👀
|
|
3
|
+
>>> from webscout import check_for_updates
|
|
4
|
+
>>> check_for_updates()
|
|
5
|
+
'Yo, new Webscout version just dropped: 2.0.0! 🔥
|
|
6
|
+
Level up with: `pip install --upgrade webscout`'
|
|
4
7
|
"""
|
|
5
8
|
|
|
6
|
-
import requests
|
|
7
|
-
import re
|
|
8
9
|
import subprocess
|
|
9
10
|
import sys
|
|
10
11
|
import os
|
|
11
|
-
from packaging import version
|
|
12
12
|
from typing import Optional
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
import requests
|
|
15
|
+
from packaging import version
|
|
16
|
+
import re
|
|
17
|
+
|
|
18
|
+
from webscout import LitLogger, ColorScheme
|
|
19
|
+
from importlib.metadata import version as get_package_version
|
|
20
|
+
from importlib.metadata import PackageNotFoundError
|
|
21
|
+
from importlib.metadata import metadata as get_package_metadata
|
|
15
22
|
|
|
16
|
-
#
|
|
23
|
+
# Setting up that clean logger format, no cap! 💯
|
|
17
24
|
CUSTOM_FORMAT = """{message}"""
|
|
18
25
|
|
|
19
26
|
logger = LitLogger(
|
|
@@ -22,7 +29,7 @@ logger = LitLogger(
|
|
|
22
29
|
color_scheme=ColorScheme.OCEAN,
|
|
23
30
|
level_styles={
|
|
24
31
|
"TRACE": "DIM",
|
|
25
|
-
"DEBUG": "NORMAL",
|
|
32
|
+
"DEBUG": "NORMAL",
|
|
26
33
|
"INFO": "BOLD",
|
|
27
34
|
"SUCCESS": "BOLD",
|
|
28
35
|
"WARNING": "BOLD",
|
|
@@ -32,38 +39,44 @@ logger = LitLogger(
|
|
|
32
39
|
)
|
|
33
40
|
|
|
34
41
|
def get_installed_version() -> Optional[str]:
|
|
35
|
-
"""
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
import pkg_resources
|
|
42
|
-
return pkg_resources.get_distribution('webscout').version
|
|
43
|
-
except Exception:
|
|
44
|
-
logger.error("Could not determine installed version using pkg_resources")
|
|
45
|
-
return None
|
|
46
|
-
except Exception:
|
|
47
|
-
logger.error("Could not determine installed version using importlib.metadata")
|
|
48
|
-
return None
|
|
42
|
+
"""Yo, let's check what version you're running! 🔍
|
|
43
|
+
|
|
44
|
+
What this function's all about:
|
|
45
|
+
- Checking your setup real quick 💨
|
|
46
|
+
- Getting them version deets 📱
|
|
47
|
+
- Handling any problems like a boss 💪
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
Returns:
|
|
50
|
+
Optional[str]: Your version number or None if we can't find it
|
|
51
|
+
|
|
52
|
+
Examples:
|
|
53
|
+
>>> version = get_installed_version()
|
|
54
|
+
>>> print(version)
|
|
55
|
+
'1.2.3'
|
|
56
|
+
"""
|
|
52
57
|
try:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
version_match = re.search(r'\d+\.\d+\.\d+', result.stdout)
|
|
59
|
-
if version_match:
|
|
60
|
-
return version_match.group(0)
|
|
61
|
-
except (subprocess.TimeoutExpired, subprocess.SubprocessError, FileNotFoundError) as e:
|
|
62
|
-
logger.error(f"Failed to get version from CLI: {str(e)}")
|
|
63
|
-
return None
|
|
58
|
+
return get_package_version('webscout')
|
|
59
|
+
except PackageNotFoundError:
|
|
60
|
+
return None
|
|
61
|
+
except Exception as e:
|
|
62
|
+
return None
|
|
64
63
|
|
|
65
64
|
def get_pypi_version() -> Optional[str]:
|
|
66
|
-
"""
|
|
65
|
+
"""Let's see what's fresh on PyPI! 🚀
|
|
66
|
+
|
|
67
|
+
This function's vibe:
|
|
68
|
+
- Hitting up PyPI for the latest drop 🌐
|
|
69
|
+
- Keeping it smooth with timeout handling ⚡
|
|
70
|
+
- Making sure we get good data fr fr 💯
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
Optional[str]: Latest version or None if something's not right
|
|
74
|
+
|
|
75
|
+
Examples:
|
|
76
|
+
>>> latest = get_pypi_version()
|
|
77
|
+
>>> print(latest)
|
|
78
|
+
'2.0.0'
|
|
79
|
+
"""
|
|
67
80
|
try:
|
|
68
81
|
response = requests.get(
|
|
69
82
|
"https://pypi.org/pypi/webscout/json",
|
|
@@ -72,54 +85,100 @@ def get_pypi_version() -> Optional[str]:
|
|
|
72
85
|
response.raise_for_status()
|
|
73
86
|
return response.json()['info']['version']
|
|
74
87
|
except requests.RequestException as e:
|
|
75
|
-
|
|
88
|
+
pass
|
|
76
89
|
except (KeyError, ValueError) as e:
|
|
77
|
-
|
|
90
|
+
pass
|
|
91
|
+
except Exception as e:
|
|
92
|
+
pass
|
|
78
93
|
return None
|
|
79
94
|
|
|
80
95
|
def version_compare(v1: str, v2: str) -> int:
|
|
81
|
-
"""
|
|
96
|
+
"""Time to compare these versions! 💪
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
v1: First version we checking
|
|
100
|
+
v2: Second version to compare with
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
int: -1 if v1's older, 1 if v1's newer, 0 if they twins
|
|
104
|
+
|
|
105
|
+
Examples:
|
|
106
|
+
>>> version_compare('1.0.0', '2.0.0')
|
|
107
|
+
-1
|
|
108
|
+
"""
|
|
82
109
|
try:
|
|
83
|
-
|
|
84
|
-
|
|
110
|
+
version1 = version.parse(v1)
|
|
111
|
+
version2 = version.parse(v2)
|
|
112
|
+
if version1 < version2:
|
|
113
|
+
return -1
|
|
114
|
+
if version1 > version2:
|
|
115
|
+
return 1
|
|
85
116
|
return 0
|
|
117
|
+
except version.InvalidVersion as e:
|
|
118
|
+
pass
|
|
119
|
+
return 0
|
|
120
|
+
except Exception as e:
|
|
121
|
+
pass
|
|
122
|
+
return 0
|
|
123
|
+
|
|
124
|
+
def display_version_info(installed: Optional[str], latest: Optional[str]) -> None:
|
|
125
|
+
"""Let's break down your version status! 📱
|
|
126
|
+
|
|
127
|
+
What we doing here:
|
|
128
|
+
- Comparing your version with the latest drop 🔄
|
|
129
|
+
- Letting you know if you need to level up ⬆️
|
|
130
|
+
- Keeping you in the loop with style 💯
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
installed: What you running rn
|
|
134
|
+
latest: What's fresh out there
|
|
86
135
|
|
|
87
|
-
|
|
88
|
-
|
|
136
|
+
Examples:
|
|
137
|
+
>>> display_version_info('1.0.0', '2.0.0')
|
|
138
|
+
'Yo, new Webscout version just dropped: 2.0.0! 🔥'
|
|
139
|
+
"""
|
|
89
140
|
if installed:
|
|
90
|
-
|
|
141
|
+
pass
|
|
91
142
|
|
|
92
143
|
if latest and installed:
|
|
93
|
-
|
|
144
|
+
comparison_result = version_compare(installed, latest)
|
|
145
|
+
if comparison_result < 0:
|
|
94
146
|
logger.warning(
|
|
95
|
-
f"
|
|
96
|
-
f"
|
|
147
|
+
f"Yo, new Webscout version just dropped: {latest}! 🔥\n"
|
|
148
|
+
f"Level up with: `pip install --upgrade webscout`"
|
|
97
149
|
)
|
|
98
|
-
|
|
99
|
-
logger.success("You
|
|
150
|
+
elif comparison_result > 0:
|
|
151
|
+
logger.success("You already got the latest version, no cap! 💯")
|
|
100
152
|
|
|
101
153
|
def check_for_updates() -> None:
|
|
102
|
-
"""
|
|
103
|
-
|
|
104
|
-
|
|
154
|
+
"""Time to check if you're running the latest! 🚀
|
|
155
|
+
|
|
156
|
+
What we doing:
|
|
157
|
+
- Peeking at your current setup 📱
|
|
158
|
+
- Checking what's new out there 🌐
|
|
159
|
+
- Keeping you updated fr fr ⚡
|
|
160
|
+
|
|
161
|
+
Examples:
|
|
162
|
+
>>> check_for_updates()
|
|
163
|
+
# We got you with them version checks fam!
|
|
164
|
+
"""
|
|
105
165
|
installed_version = get_installed_version()
|
|
106
|
-
current_version = get_webscout_version()
|
|
107
166
|
latest_version = get_pypi_version()
|
|
108
167
|
|
|
109
168
|
if not installed_version:
|
|
110
|
-
|
|
169
|
+
pass
|
|
111
170
|
return
|
|
112
171
|
|
|
113
172
|
if not latest_version:
|
|
114
|
-
|
|
173
|
+
pass
|
|
115
174
|
return
|
|
116
175
|
|
|
117
|
-
display_version_info(installed_version,
|
|
176
|
+
display_version_info(installed_version, latest_version)
|
|
118
177
|
|
|
119
178
|
if __name__ == "__main__":
|
|
120
179
|
try:
|
|
121
180
|
check_for_updates()
|
|
122
181
|
except KeyboardInterrupt:
|
|
123
|
-
logger.warning("Update check cancelled
|
|
182
|
+
logger.warning("Update check got cancelled, no worries fam! 🤚")
|
|
124
183
|
except Exception as e:
|
|
125
|
-
logger.error(f"
|
|
184
|
+
logger.error(f"Uh oh, something went wrong: {str(e)} 😔")
|
webscout/version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "6.
|
|
1
|
+
__version__ = "6.6"
|
|
2
2
|
__prog__ = "webscout"
|
webscout/zeroart/base.py
CHANGED
|
@@ -37,25 +37,24 @@ class ZeroArtFont:
|
|
|
37
37
|
return self.letters.get(char.upper(), self.letters.get(' ', [' ']))
|
|
38
38
|
|
|
39
39
|
def render(self, text):
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"""
|
|
46
|
-
# Ensure text is uppercase
|
|
47
|
-
text = text.upper()
|
|
40
|
+
if not text:
|
|
41
|
+
return ""
|
|
42
|
+
|
|
43
|
+
# Get the maximum height of any character in the font
|
|
44
|
+
max_height = max(len(self.get_letter(c)) for c in text)
|
|
48
45
|
|
|
49
|
-
# Initialize
|
|
50
|
-
art_lines = [
|
|
46
|
+
# Initialize art_lines with empty strings
|
|
47
|
+
art_lines = ["" for _ in range(max_height)]
|
|
51
48
|
|
|
49
|
+
# Process each character
|
|
52
50
|
for char in text:
|
|
53
|
-
# Get character's art or use space if not found
|
|
54
51
|
char_art = self.get_letter(char)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
# Pad shorter characters with empty lines to match max_height
|
|
53
|
+
while len(char_art) < max_height:
|
|
54
|
+
char_art.append(" " * len(char_art[0]))
|
|
55
|
+
|
|
56
|
+
# Add character art to each line
|
|
57
|
+
for i in range(max_height):
|
|
58
58
|
art_lines[i] += char_art[i] + " "
|
|
59
|
-
|
|
60
|
-
# Join lines and remove trailing space
|
|
59
|
+
|
|
61
60
|
return "\n".join(art_lines)
|
webscout/zeroart/effects.py
CHANGED
webscout/zeroart/fonts.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: webscout
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.6
|
|
4
4
|
Summary: Search for anything using Google, DuckDuckGo, phind.com, Contains AI models, can transcribe yt videos, temporary email and phone number generation, has TTS support, webai (terminal gpt and open interpreter) and offline LLMs and more
|
|
5
5
|
Author: OEvortex
|
|
6
6
|
Author-email: helpingai5@gmail.com
|
|
@@ -24,6 +24,9 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
24
24
|
Requires-Python: >=3.7
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
License-File: LICENSE.md
|
|
27
|
+
Requires-Dist: setuptools
|
|
28
|
+
Requires-Dist: wheel
|
|
29
|
+
Requires-Dist: pip
|
|
27
30
|
Requires-Dist: mistune
|
|
28
31
|
Requires-Dist: tenacity
|
|
29
32
|
Requires-Dist: curl-cffi
|
|
@@ -51,7 +54,6 @@ Requires-Dist: pyreqwest-impersonate
|
|
|
51
54
|
Requires-Dist: gradio-client
|
|
52
55
|
Requires-Dist: psutil
|
|
53
56
|
Requires-Dist: yaspin
|
|
54
|
-
Requires-Dist: websocket
|
|
55
57
|
Provides-Extra: dev
|
|
56
58
|
Requires-Dist: ruff>=0.1.6; extra == "dev"
|
|
57
59
|
Requires-Dist: pytest>=7.4.2; extra == "dev"
|
|
@@ -64,6 +66,7 @@ Requires-Dist: unicorn; extra == "local"
|
|
|
64
66
|
|
|
65
67
|
<div align="center">
|
|
66
68
|
<!-- Replace `#` with your actual links -->
|
|
69
|
+
|
|
67
70
|
<a href="https://t.me/official_helpingai"><img alt="Telegram" src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white"></a>
|
|
68
71
|
<a href="https://www.instagram.com/oevortex/"><img alt="Instagram" src="https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white"></a>
|
|
69
72
|
<a href="https://www.linkedin.com/in/oe-vortex-29a407265/"><img alt="LinkedIn" src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white"></a>
|
|
@@ -109,13 +112,13 @@ Requires-Dist: unicorn; extra == "local"
|
|
|
109
112
|
* **Rawdog Scripting:** Execute Python scripts directly within your terminal using the `rawdog` feature.
|
|
110
113
|
* **GGUF Conversion & Quantization:** Convert and quantize Hugging Face models to GGUF format.
|
|
111
114
|
* **Autollama:** Download Hugging Face models and automatically convert them for Ollama compatibility.
|
|
112
|
-
* **Function Calling (Beta):** Experiment with function calling capabilities for enhanced AI interactions.
|
|
113
115
|
* **[SwiftCLI](webscout/swiftcli/Readme.md):** A powerful and elegant CLI framework that makes it easy to create beautiful command-line interfaces.
|
|
114
116
|
* **[LitPrinter](webscout/litprinter/Readme.md):** Provides beautiful, styled console output with rich formatting and colors
|
|
115
117
|
* **[LitLogger](webscout/litlogger/Readme.md):** Simplifies logging with customizable formats and color schemes
|
|
116
118
|
* **[LitAgent](webscout/litagent/Readme.md):** Powerful and modern user agent generator that keeps your requests fresh and undetectable
|
|
117
119
|
* **[Text-to-Image](webscout/Provider/TTI/README.md):** Generate high-quality images using a wide range of AI art providers
|
|
118
120
|
* **[MarkdownLite](webscout/Extra/markdownlite/README.md):** Powerful HTML to Markdown conversion library with advanced parsing and structured output
|
|
121
|
+
* **[Scout](webscout/scout/README.md):** Advanced web parsing and crawling library with intelligent HTML/XML parsing, web crawling, and Markdown conversion
|
|
119
122
|
|
|
120
123
|
## ⚙️ Installation
|
|
121
124
|
```python
|
|
@@ -851,40 +854,11 @@ print(response)
|
|
|
851
854
|
|
|
852
855
|
```python
|
|
853
856
|
from webscout import YEPCHAT
|
|
854
|
-
ai = YEPCHAT(
|
|
857
|
+
ai = YEPCHAT()
|
|
855
858
|
response = ai.chat(input(">>> "))
|
|
856
859
|
for chunk in response:
|
|
857
860
|
print(chunk, end="", flush=True)
|
|
858
|
-
#---------------Tool Call-------------
|
|
859
861
|
|
|
860
|
-
from rich import print
|
|
861
|
-
from webscout import YEPCHAT
|
|
862
|
-
def get_current_time():
|
|
863
|
-
import datetime
|
|
864
|
-
return f"The current time is {datetime.datetime.now().strftime('%H:%M:%S')}"
|
|
865
|
-
def get_weather(location: str) -> str:
|
|
866
|
-
return f"The weather in {location} is sunny."
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
ai = YEPCHAT(Tools=True) # Set Tools=True to use tools in the chat.
|
|
870
|
-
|
|
871
|
-
ai.tool_registry.register_tool("get_current_time", get_current_time, "Gets the current time.")
|
|
872
|
-
ai.tool_registry.register_tool(
|
|
873
|
-
"get_weather",
|
|
874
|
-
get_weather,
|
|
875
|
-
"Gets the weather for a given location.",
|
|
876
|
-
parameters={
|
|
877
|
-
"type": "object",
|
|
878
|
-
"properties": {
|
|
879
|
-
"location": {"title": "Location", "type": "string"}
|
|
880
|
-
},
|
|
881
|
-
"required": ["location"]
|
|
882
|
-
},
|
|
883
|
-
)
|
|
884
|
-
|
|
885
|
-
response = ai.chat(input(">>> "))
|
|
886
|
-
for chunk in response:
|
|
887
|
-
print(chunk, end="", flush=True)
|
|
888
862
|
```
|
|
889
863
|
|
|
890
864
|
### ⬛ `BlackBox` - Search/Chat with BlackBox
|
|
@@ -914,20 +888,6 @@ r = ai.chat(prompt)
|
|
|
914
888
|
print(r)
|
|
915
889
|
```
|
|
916
890
|
|
|
917
|
-
### ❓ `PERPLEXITY` - Search with PERPLEXITY
|
|
918
|
-
|
|
919
|
-
```python
|
|
920
|
-
from webscout import Perplexity
|
|
921
|
-
from rich import print
|
|
922
|
-
|
|
923
|
-
perplexity = Perplexity()
|
|
924
|
-
# Stream the response
|
|
925
|
-
response = perplexity.chat(input(">>> "))
|
|
926
|
-
for chunk in response:
|
|
927
|
-
print(chunk, end="", flush=True)
|
|
928
|
-
|
|
929
|
-
perplexity.close()
|
|
930
|
-
```
|
|
931
891
|
|
|
932
892
|
### 🤖 `Meta AI` - Chat with Meta AI
|
|
933
893
|
|
|
@@ -1170,125 +1130,8 @@ a = AndiSearch()
|
|
|
1170
1130
|
print(a.chat("HelpingAI-9B"))
|
|
1171
1131
|
```
|
|
1172
1132
|
|
|
1173
|
-
### 📞 Function Calling (Beta)
|
|
1174
|
-
|
|
1175
|
-
```python
|
|
1176
|
-
import json
|
|
1177
|
-
import logging
|
|
1178
|
-
from webscout import Julius, WEBS
|
|
1179
|
-
from webscout.Agents.functioncall import FunctionCallingAgent
|
|
1180
|
-
from rich import print
|
|
1181
|
-
|
|
1182
|
-
class FunctionExecutor:
|
|
1183
|
-
def __init__(self, llama):
|
|
1184
|
-
self.llama = llama
|
|
1185
|
-
|
|
1186
|
-
def execute_web_search(self, arguments):
|
|
1187
|
-
query = arguments.get("query")
|
|
1188
|
-
if not query:
|
|
1189
|
-
return "Please provide a search query."
|
|
1190
|
-
with WEBS() as webs:
|
|
1191
|
-
search_results = webs.text(query, max_results=5)
|
|
1192
|
-
prompt = (
|
|
1193
|
-
f"Based on the following search results:\n\n{search_results}\n\n"
|
|
1194
|
-
f"Question: {query}\n\n"
|
|
1195
|
-
"Please provide a comprehensive answer to the question based on the search results above. "
|
|
1196
|
-
"Include relevant webpage URLs in your answer when appropriate. "
|
|
1197
|
-
"If the search results don't contain relevant information, please state that and provide the best answer you can based on your general knowledge."
|
|
1198
|
-
)
|
|
1199
|
-
return self.llama.chat(prompt)
|
|
1200
|
-
|
|
1201
|
-
def execute_general_ai(self, arguments):
|
|
1202
|
-
question = arguments.get("question")
|
|
1203
|
-
if not question:
|
|
1204
|
-
return "Please provide a question."
|
|
1205
|
-
return self.llama.chat(question)
|
|
1206
|
-
|
|
1207
|
-
def execute_UserDetail(self, arguments):
|
|
1208
|
-
name = arguments.get("name")
|
|
1209
|
-
age = arguments.get("age")
|
|
1210
|
-
return f"User details - Name: {name}, Age: {age}"
|
|
1211
|
-
|
|
1212
|
-
def main():
|
|
1213
|
-
tools = [
|
|
1214
|
-
{
|
|
1215
|
-
"type": "function",
|
|
1216
|
-
"function": {
|
|
1217
|
-
"name": "UserDetail",
|
|
1218
|
-
"parameters": {
|
|
1219
|
-
"type": "object",
|
|
1220
|
-
"properties": {
|
|
1221
|
-
"name": {"title": "Name", "type": "string"},
|
|
1222
|
-
"age": {"title": "Age", "type": "integer"}
|
|
1223
|
-
},
|
|
1224
|
-
"required": ["name", "age"]
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
},
|
|
1228
|
-
{
|
|
1229
|
-
"type": "function",
|
|
1230
|
-
"function": {
|
|
1231
|
-
"name": "web_search",
|
|
1232
|
-
"description": "Search the web for information using Google Search.",
|
|
1233
|
-
"parameters": {
|
|
1234
|
-
"type": "object",
|
|
1235
|
-
"properties": {
|
|
1236
|
-
"query": {
|
|
1237
|
-
"type": "string",
|
|
1238
|
-
"description": "The search query to be executed."
|
|
1239
|
-
}
|
|
1240
|
-
},
|
|
1241
|
-
"required": ["query"]
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
},
|
|
1245
|
-
{
|
|
1246
|
-
"type": "function",
|
|
1247
|
-
"function": {
|
|
1248
|
-
"name": "general_ai",
|
|
1249
|
-
"description": "Use general AI knowledge to answer the question",
|
|
1250
|
-
"parameters": {
|
|
1251
|
-
"type": "object",
|
|
1252
|
-
"properties": {
|
|
1253
|
-
"question": {"type": "string", "description": "The question to answer"}
|
|
1254
|
-
},
|
|
1255
|
-
"required": ["question"]
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
]
|
|
1260
|
-
|
|
1261
|
-
agent = FunctionCallingAgent(tools=tools)
|
|
1262
|
-
llama = Julius()
|
|
1263
|
-
function_executor = FunctionExecutor(llama)
|
|
1264
|
-
|
|
1265
|
-
user_input = input(">>> ")
|
|
1266
|
-
function_call_data = agent.function_call_handler(user_input)
|
|
1267
|
-
print(f"Function Call Data: {function_call_data}")
|
|
1268
|
-
|
|
1269
|
-
try:
|
|
1270
|
-
if "error" not in function_call_data:
|
|
1271
|
-
function_name = function_call_data.get("tool_name")
|
|
1272
|
-
arguments = function_call_data.get("tool_input", {})
|
|
1273
|
-
|
|
1274
|
-
execute_function = getattr(function_executor, f"execute_{function_name}", None)
|
|
1275
|
-
if execute_function:
|
|
1276
|
-
result = execute_function(arguments)
|
|
1277
|
-
print("Function Execution Result:")
|
|
1278
|
-
for c in result:
|
|
1279
|
-
print(c, end="", flush=True)
|
|
1280
|
-
else:
|
|
1281
|
-
print(f"Unknown function: {function_name}")
|
|
1282
|
-
else:
|
|
1283
|
-
print(f"Error: {function_call_data['error']}")
|
|
1284
|
-
except Exception as e:
|
|
1285
|
-
print(f"An error occurred: {str(e)}")
|
|
1286
|
-
|
|
1287
|
-
if __name__ == "__main__":
|
|
1288
|
-
main()
|
|
1289
|
-
```
|
|
1290
1133
|
|
|
1291
|
-
### LLAMA3, pizzagpt, RUBIKSAI, Koala, Darkai, AI4Chat, Farfalle, PIAI, Felo, Julius, YouChat, YEPCHAT, Cloudflare, TurboSeek, Editee, AI21, Chatify, Cerebras, X0GPT, Lepton, GEMINIAPI, Cleeai, Elmo,
|
|
1134
|
+
### LLAMA3, pizzagpt, RUBIKSAI, Koala, Darkai, AI4Chat, Farfalle, PIAI, Felo, Julius, YouChat, YEPCHAT, Cloudflare, TurboSeek, Editee, AI21, Chatify, Cerebras, X0GPT, Lepton, GEMINIAPI, Cleeai, Elmo, Free2GPT, Bing, DiscordRocks, GPTWeb, LlamaTutor, PromptRefine, TutorAI, ChatGPTES, Bagoodex, ChatHub, AmigoChat, AIMathGPT, GaurishCerebras, NinjaChat, GeminiPro, Talkai, LLMChat, AskMyAI, Llama3Mitril, Marcus, TypeGPT, Mhystical, Netwrck, MultiChatAI, JadveOpenAI, OOAi
|
|
1292
1135
|
|
|
1293
1136
|
Code is similar to other providers.
|
|
1294
1137
|
|