webscout 4.9__tar.gz → 5.0__tar.gz
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-4.9/webscout.egg-info → webscout-5.0}/PKG-INFO +1 -1
- {webscout-4.9 → webscout-5.0}/setup.py +1 -1
- webscout-5.0/webscout/Agents/functioncall.py +142 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/DiscordRocks.py +2 -1
- {webscout-4.9 → webscout-5.0/webscout.egg-info}/PKG-INFO +1 -1
- webscout-4.9/webscout/Agents/functioncall.py +0 -186
- {webscout-4.9 → webscout-5.0}/LICENSE.md +0 -0
- {webscout-4.9 → webscout-5.0}/README.md +0 -0
- {webscout-4.9 → webscout-5.0}/setup.cfg +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/AIauto.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/AIbase.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/AIutel.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Agents/Onlinesearcher.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Agents/__init__.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Bard.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Bing_search.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/DWEBS.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Extra/__init__.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Extra/autollama.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Extra/gguf.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Extra/weather.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Extra/weather_ascii.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/LLM.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Local/__init__.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Local/_version.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Local/formats.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Local/model.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Local/rawdog.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Local/samplers.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Local/thread.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Local/utils.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Andi.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/BasedGPT.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Berlin4h.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Blackboxai.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Cloudflare.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Cohere.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/DARKAI.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Deepinfra.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Deepseek.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Farfalle.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Gemini.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Groq.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Koboldai.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Llama.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Llama3.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/OLLAMA.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Openai.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/PI.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Perplexity.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Phind.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/PizzaGPT.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Poe.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/RUBIKSAI.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Reka.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/ThinkAnyAI.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/Youchat.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/__init__.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/ai4chat.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/felo_search.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/julius.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/koala.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/liaobots.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/meta.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/turboseek.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/xdash.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/Provider/yep.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/YTdownloader.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/__init__.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/__main__.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/async_providers.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/cli.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/exceptions.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/g4f.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/models.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/tempid.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/transcriber.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/utils.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/version.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/voice.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/webai.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/webscout_search.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/webscout_search_async.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout/websx_search.py +0 -0
- {webscout-4.9 → webscout-5.0}/webscout.egg-info/SOURCES.txt +0 -0
- {webscout-4.9 → webscout-5.0}/webscout.egg-info/dependency_links.txt +0 -0
- {webscout-4.9 → webscout-5.0}/webscout.egg-info/entry_points.txt +0 -0
- {webscout-4.9 → webscout-5.0}/webscout.egg-info/requires.txt +0 -0
- {webscout-4.9 → webscout-5.0}/webscout.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: webscout
|
|
3
|
-
Version:
|
|
3
|
+
Version: 5.0
|
|
4
4
|
Summary: Search for anything using Google, DuckDuckGo, brave, qwant, 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
|
|
@@ -5,7 +5,7 @@ with open("README.md", encoding="utf-8") as f:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name="webscout",
|
|
8
|
-
version="
|
|
8
|
+
version="5.0",
|
|
9
9
|
description="Search for anything using Google, DuckDuckGo, brave, qwant, 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",
|
|
10
10
|
long_description=README,
|
|
11
11
|
long_description_content_type="text/markdown",
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
from webscout import LLAMA3, WEBS
|
|
4
|
+
|
|
5
|
+
class FunctionCallingAgent:
|
|
6
|
+
def __init__(self, model: str = "llama3-8b",
|
|
7
|
+
system_prompt: str = 'You are a helpful assistant that will always answer what the user wants',
|
|
8
|
+
tools: list = None):
|
|
9
|
+
self.LLAMA3 = LLAMA3(model=model, system=system_prompt, timeout=300)
|
|
10
|
+
self.tools = tools if tools is not None else []
|
|
11
|
+
self.webs = WEBS()
|
|
12
|
+
|
|
13
|
+
def function_call_handler(self, message_text: str) -> dict:
|
|
14
|
+
system_message = self._generate_system_message(message_text)
|
|
15
|
+
response = self.LLAMA3.chat(system_message)
|
|
16
|
+
# logging.info(f"Raw response: {response}")
|
|
17
|
+
return self._parse_function_call(response)
|
|
18
|
+
|
|
19
|
+
def _generate_system_message(self, user_message: str) -> str:
|
|
20
|
+
tools_description = '\n'.join([f"- {tool['function']['name']}: {tool['function'].get('description', '')}" for tool in self.tools])
|
|
21
|
+
return (
|
|
22
|
+
"You are an AI assistant capable of understanding user requests and using tools to fulfill them. "
|
|
23
|
+
"Always respond using the JSON format specified below, even if you're not sure about the answer. "
|
|
24
|
+
f"Available tools:\n{tools_description}\n\n"
|
|
25
|
+
"Instructions:\n"
|
|
26
|
+
"1. Analyze the user's request.\n"
|
|
27
|
+
"2. Choose the most appropriate tool based on the request.\n"
|
|
28
|
+
"3. Respond ONLY with a JSON object in this exact format:\n"
|
|
29
|
+
"{\n"
|
|
30
|
+
' "tool_name": "name_of_the_tool",\n'
|
|
31
|
+
' "tool_input": {\n'
|
|
32
|
+
' "param1": "value1",\n'
|
|
33
|
+
' "param2": "value2"\n'
|
|
34
|
+
" }\n"
|
|
35
|
+
"}\n\n"
|
|
36
|
+
"If you can't determine a suitable tool, use the 'general_ai' tool with the user's message as the 'question' parameter.\n\n"
|
|
37
|
+
f"User request: {user_message}\n\n"
|
|
38
|
+
"Your response (in JSON format):"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
def _parse_function_call(self, response: str) -> dict:
|
|
42
|
+
try:
|
|
43
|
+
# Find the JSON-like part of the response
|
|
44
|
+
start_idx = response.find("{")
|
|
45
|
+
end_idx = response.rfind("}") + 1
|
|
46
|
+
|
|
47
|
+
if start_idx == -1 or end_idx == -1:
|
|
48
|
+
raise ValueError("No valid JSON structure found in the response.")
|
|
49
|
+
|
|
50
|
+
response_json_str = response[start_idx:end_idx]
|
|
51
|
+
|
|
52
|
+
# Attempt to load the JSON string
|
|
53
|
+
return json.loads(response_json_str)
|
|
54
|
+
|
|
55
|
+
except (ValueError, json.JSONDecodeError) as e:
|
|
56
|
+
logging.error(f"Error parsing function call: {e}")
|
|
57
|
+
return {"error": str(e)}
|
|
58
|
+
|
|
59
|
+
def execute_function(self, function_call_data: dict) -> str:
|
|
60
|
+
function_name = function_call_data.get("tool_name")
|
|
61
|
+
arguments = function_call_data.get("tool_input", {})
|
|
62
|
+
|
|
63
|
+
if not isinstance(arguments, dict):
|
|
64
|
+
logging.error("Invalid arguments format.")
|
|
65
|
+
return "Invalid arguments format."
|
|
66
|
+
|
|
67
|
+
logging.info(f"Executing function: {function_name} with arguments: {arguments}")
|
|
68
|
+
|
|
69
|
+
# if function_name == "web_search":
|
|
70
|
+
# return self._handle_web_search(arguments)
|
|
71
|
+
# elif function_name == "general_ai":
|
|
72
|
+
# return self._handle_general_ai(arguments)
|
|
73
|
+
# else:
|
|
74
|
+
# return f"Function '{function_name}' is not implemented."
|
|
75
|
+
|
|
76
|
+
# def _handle_web_search(self, arguments: dict) -> str:
|
|
77
|
+
# query = arguments.get("query")
|
|
78
|
+
# if not query:
|
|
79
|
+
# return "Please provide a search query."
|
|
80
|
+
|
|
81
|
+
# search_results = self.webs.text(query, max_results=3)
|
|
82
|
+
# formatted_results = "\n\n".join(
|
|
83
|
+
# f"{i+1}. {result['title']}\n{result['body']}\nURL: {result['href']}"
|
|
84
|
+
# for i, result in enumerate(search_results)
|
|
85
|
+
# )
|
|
86
|
+
# return f"Here's what I found:\n\n{formatted_results}"
|
|
87
|
+
|
|
88
|
+
# def _handle_general_ai(self, arguments: dict) -> str:
|
|
89
|
+
# question = arguments.get("question")
|
|
90
|
+
# if not question:
|
|
91
|
+
# return "Please provide a question for the AI to answer."
|
|
92
|
+
|
|
93
|
+
# response = self.LLAMA3.chat(question)
|
|
94
|
+
# return response
|
|
95
|
+
|
|
96
|
+
# Example usage
|
|
97
|
+
if __name__ == "__main__":
|
|
98
|
+
tools = [
|
|
99
|
+
{
|
|
100
|
+
"type": "function",
|
|
101
|
+
"function": {
|
|
102
|
+
"name": "web_search",
|
|
103
|
+
"description": "Search query on Google",
|
|
104
|
+
"parameters": {
|
|
105
|
+
"type": "object",
|
|
106
|
+
"properties": {
|
|
107
|
+
"query": {
|
|
108
|
+
"type": "string",
|
|
109
|
+
"description": "web search query"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"required": ["query"]
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"type": "function",
|
|
118
|
+
"function": {
|
|
119
|
+
"name": "general_ai",
|
|
120
|
+
"description": "Use AI to answer a general question",
|
|
121
|
+
"parameters": {
|
|
122
|
+
"type": "object",
|
|
123
|
+
"properties": {
|
|
124
|
+
"question": {
|
|
125
|
+
"type": "string",
|
|
126
|
+
"description": "The question to be answered by the AI"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"required": ["question"]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
agent = FunctionCallingAgent(tools=tools)
|
|
136
|
+
message = "open yt"
|
|
137
|
+
function_call_data = agent.function_call_handler(message)
|
|
138
|
+
print(f"Function Call Data: {function_call_data}")
|
|
139
|
+
|
|
140
|
+
if "error" not in function_call_data:
|
|
141
|
+
result = agent.execute_function(function_call_data)
|
|
142
|
+
print(f"Function Execution Result: {result}")
|
|
@@ -122,7 +122,7 @@ class DiscordRocks(Provider):
|
|
|
122
122
|
|
|
123
123
|
def __init__(
|
|
124
124
|
self,
|
|
125
|
-
model: str = "
|
|
125
|
+
model: str = "llama-3.1-405b-turbo",
|
|
126
126
|
max_tokens: int = 4096,
|
|
127
127
|
temperature: float = 1,
|
|
128
128
|
top_p: float = 1,
|
|
@@ -176,6 +176,7 @@ class DiscordRocks(Provider):
|
|
|
176
176
|
"accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
|
|
177
177
|
"content-type": "application/json",
|
|
178
178
|
"dnt": "1",
|
|
179
|
+
"authorization": "Bearer missing api key",
|
|
179
180
|
"origin": "https://llmplayground.net",
|
|
180
181
|
"priority": "u=1, i",
|
|
181
182
|
"referer": "https://llmplayground.net/",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: webscout
|
|
3
|
-
Version:
|
|
3
|
+
Version: 5.0
|
|
4
4
|
Summary: Search for anything using Google, DuckDuckGo, brave, qwant, 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
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import logging
|
|
3
|
-
from webscout import DeepInfra, WEBS
|
|
4
|
-
|
|
5
|
-
class FunctionCallingAgent:
|
|
6
|
-
def __init__(self, model: str = "Qwen/Qwen2-72B-Instruct",
|
|
7
|
-
system_prompt: str = 'You are a helpful assistant that will always answer what the user wants',
|
|
8
|
-
tools: list = None):
|
|
9
|
-
"""
|
|
10
|
-
Initialize the FunctionCallingAgent with the model, system prompt, and tools.
|
|
11
|
-
|
|
12
|
-
Args:
|
|
13
|
-
model (str): The model to use for deepinfra chat.
|
|
14
|
-
system_prompt (str): The system prompt to initialize the model.
|
|
15
|
-
tools (list): A list of tools the agent can use.
|
|
16
|
-
"""
|
|
17
|
-
self.deepinfra = DeepInfra(model=model, system_prompt=system_prompt, timeout=300)
|
|
18
|
-
self.tools = tools if tools is not None else []
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def function_call_handler(self, message_text: str) -> dict:
|
|
22
|
-
"""
|
|
23
|
-
Handles function calls based on the provided message text.
|
|
24
|
-
|
|
25
|
-
Args:
|
|
26
|
-
message_text (str): The input message text from the user.
|
|
27
|
-
|
|
28
|
-
Returns:
|
|
29
|
-
dict: The extracted function call and arguments.
|
|
30
|
-
"""
|
|
31
|
-
system_message = self._generate_system_message(message_text)
|
|
32
|
-
response = self.deepinfra.chat(system_message)
|
|
33
|
-
# logging.info(f"Raw response: {response}")
|
|
34
|
-
|
|
35
|
-
return self._parse_function_call(response)
|
|
36
|
-
|
|
37
|
-
def _generate_system_message(self, user_message: str) -> str:
|
|
38
|
-
"""
|
|
39
|
-
Generates a system message incorporating the user message and available tools.
|
|
40
|
-
|
|
41
|
-
Args:
|
|
42
|
-
user_message (str): The input message from the user.
|
|
43
|
-
|
|
44
|
-
Returns:
|
|
45
|
-
str: The formatted system message.
|
|
46
|
-
"""
|
|
47
|
-
tools_description = '\n'.join([f"{tool['function']['name']}: {tool['function'].get('description', '')}" for tool in self.tools])
|
|
48
|
-
return (
|
|
49
|
-
f"[SYSTEM] You are a helpful and capable AI assistant. "
|
|
50
|
-
"Your goal is to understand the user's request and provide accurate and relevant information. "
|
|
51
|
-
"You have access to the following tools:\n\n"
|
|
52
|
-
f"{tools_description}\n\n"
|
|
53
|
-
"To use a tool, please follow this format:\n\n"
|
|
54
|
-
"```json\n"
|
|
55
|
-
"{{ 'tool_name': 'tool_name', 'tool_input': {{ 'arg_1': 'value_1', 'arg_2': 'value_2', ... }} }}\n"
|
|
56
|
-
"```\n\n"
|
|
57
|
-
f"[USER] {user_message}"
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
def _parse_function_call(self, response: str) -> dict:
|
|
61
|
-
"""
|
|
62
|
-
Parses the response from the model to extract the function call.
|
|
63
|
-
|
|
64
|
-
Args:
|
|
65
|
-
response (str): The raw response from the model.
|
|
66
|
-
|
|
67
|
-
Returns:
|
|
68
|
-
dict: A dictionary containing the function name and arguments.
|
|
69
|
-
"""
|
|
70
|
-
try:
|
|
71
|
-
# Find the JSON-like part of the response
|
|
72
|
-
start_idx = response.find("{")
|
|
73
|
-
end_idx = response.rfind("}") + 1
|
|
74
|
-
|
|
75
|
-
if start_idx == -1 or end_idx == -1:
|
|
76
|
-
raise ValueError("No valid JSON structure found in the response.")
|
|
77
|
-
|
|
78
|
-
response_json_str = response[start_idx:end_idx]
|
|
79
|
-
|
|
80
|
-
# Replace single quotes with double quotes and remove extra braces
|
|
81
|
-
response_json_str = response_json_str.replace("'", '"')
|
|
82
|
-
response_json_str = response_json_str.replace("{{", "{").replace("}}", "}")
|
|
83
|
-
|
|
84
|
-
# Remove any leading or trailing whitespace
|
|
85
|
-
response_json_str = response_json_str.strip()
|
|
86
|
-
|
|
87
|
-
# Attempt to load the JSON string
|
|
88
|
-
return json.loads(response_json_str)
|
|
89
|
-
|
|
90
|
-
except (ValueError, json.JSONDecodeError) as e:
|
|
91
|
-
logging.error(f"Error parsing function call: {e}")
|
|
92
|
-
return {"error": str(e)}
|
|
93
|
-
|
|
94
|
-
def execute_function(self, function_call_data: dict) -> str:
|
|
95
|
-
"""
|
|
96
|
-
Executes the specified function with the provided arguments.
|
|
97
|
-
|
|
98
|
-
Args:
|
|
99
|
-
function_call_data (dict): A dictionary containing the function name and arguments.
|
|
100
|
-
|
|
101
|
-
Returns:
|
|
102
|
-
str: The result of the function execution.
|
|
103
|
-
"""
|
|
104
|
-
function_name = function_call_data.get("tool_name") # Use 'tool_name' instead of 'name'
|
|
105
|
-
arguments = function_call_data.get("tool_input", {}) # Use 'tool_input' instead of 'arguments'
|
|
106
|
-
|
|
107
|
-
if not isinstance(arguments, dict):
|
|
108
|
-
logging.error("Invalid arguments format.")
|
|
109
|
-
return "Invalid arguments format."
|
|
110
|
-
|
|
111
|
-
logging.info(f"Executing function: {function_name} with arguments: {arguments}")
|
|
112
|
-
|
|
113
|
-
if function_name == "web_search":
|
|
114
|
-
return self._handle_web_search(arguments)
|
|
115
|
-
else:
|
|
116
|
-
return f"Function '{function_name}' is not implemented."
|
|
117
|
-
|
|
118
|
-
# def _handle_web_search(self, arguments: dict) -> str:
|
|
119
|
-
# """
|
|
120
|
-
# Handles web search queries using the WEBS tool.
|
|
121
|
-
|
|
122
|
-
# Args:
|
|
123
|
-
# arguments (dict): A dictionary containing the query argument.
|
|
124
|
-
|
|
125
|
-
# Returns:
|
|
126
|
-
# str: The result of the web search.
|
|
127
|
-
# """
|
|
128
|
-
# query = arguments.get("query")
|
|
129
|
-
# if not query:
|
|
130
|
-
# return "Please provide a search query."
|
|
131
|
-
|
|
132
|
-
# search_results = self.webs.text(query)
|
|
133
|
-
# # Additional processing of search results can be done here if needed.
|
|
134
|
-
# return f"Here's what I found:\n\n{search_results}"
|
|
135
|
-
|
|
136
|
-
# Example usage
|
|
137
|
-
if __name__ == "__main__":
|
|
138
|
-
tools = [
|
|
139
|
-
{
|
|
140
|
-
"type": "function",
|
|
141
|
-
"function": {
|
|
142
|
-
"name": "UserDetail",
|
|
143
|
-
"parameters": {
|
|
144
|
-
"type": "object",
|
|
145
|
-
"title": "UserDetail",
|
|
146
|
-
"properties": {
|
|
147
|
-
"name": {
|
|
148
|
-
"title": "Name",
|
|
149
|
-
"type": "string"
|
|
150
|
-
},
|
|
151
|
-
"age": {
|
|
152
|
-
"title": "Age",
|
|
153
|
-
"type": "integer"
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
"required": ["name", "age"]
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
"type": "function",
|
|
162
|
-
"function": {
|
|
163
|
-
"name": "web_search",
|
|
164
|
-
"description": "Search query on google",
|
|
165
|
-
"parameters": {
|
|
166
|
-
"type": "object",
|
|
167
|
-
"properties": {
|
|
168
|
-
"query": {
|
|
169
|
-
"type": "string",
|
|
170
|
-
"description": "web search query"
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
"required": ["query"]
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
]
|
|
178
|
-
|
|
179
|
-
agent = FunctionCallingAgent(tools=tools)
|
|
180
|
-
message = "websearch about helpingai-9b"
|
|
181
|
-
function_call_data = agent.function_call_handler(message)
|
|
182
|
-
print(f"Function Call Data: {function_call_data}")
|
|
183
|
-
|
|
184
|
-
if "error" not in function_call_data:
|
|
185
|
-
result = agent.execute_function(function_call_data)
|
|
186
|
-
print(f"Function Execution Result: {result}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|