ws-bom-robot-app 0.0.59__py3-none-any.whl → 0.0.60__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.
- ws_bom_robot_app/llm/tools/tool_manager.py +41 -1
- {ws_bom_robot_app-0.0.59.dist-info → ws_bom_robot_app-0.0.60.dist-info}/METADATA +2 -1
- {ws_bom_robot_app-0.0.59.dist-info → ws_bom_robot_app-0.0.60.dist-info}/RECORD +5 -5
- {ws_bom_robot_app-0.0.59.dist-info → ws_bom_robot_app-0.0.60.dist-info}/WHEEL +0 -0
- {ws_bom_robot_app-0.0.59.dist-info → ws_bom_robot_app-0.0.60.dist-info}/top_level.txt +0 -0
|
@@ -171,7 +171,46 @@ class ToolManager:
|
|
|
171
171
|
final_results.append({"url": url, "content": "Page not found"})
|
|
172
172
|
return final_results
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
async def search_online_google(self, query: str):
|
|
175
|
+
from langchain_google_community import GoogleSearchAPIWrapper
|
|
176
|
+
from ws_bom_robot_app.llm.tools.utils import fetch_page, extract_content_with_trafilatura
|
|
177
|
+
import aiohttp, asyncio
|
|
178
|
+
secrets = {}
|
|
179
|
+
for d in self.app_tool.secrets:
|
|
180
|
+
secrets[d.get("secretId")] = d.get("secretValue")
|
|
181
|
+
search_type = secrets.get("searchType")
|
|
182
|
+
if search_type:
|
|
183
|
+
search_kwargs = {"searchType" : search_type}
|
|
184
|
+
search = GoogleSearchAPIWrapper(
|
|
185
|
+
google_api_key=secrets.get("GOOGLE_API_KEY"),
|
|
186
|
+
google_cse_id=secrets.get("GOOGLE_CSE_ID"),
|
|
187
|
+
)
|
|
188
|
+
if search_type:
|
|
189
|
+
raw_results = search.results(query=query,
|
|
190
|
+
num_results=secrets.get("num_results", 5),
|
|
191
|
+
search_params=search_kwargs)
|
|
192
|
+
return raw_results
|
|
193
|
+
raw_results = search.results(
|
|
194
|
+
query=query,
|
|
195
|
+
num_results=secrets.get("num_results", 5)
|
|
196
|
+
)
|
|
197
|
+
urls = [r["link"] for r in raw_results]
|
|
198
|
+
async with aiohttp.ClientSession() as session:
|
|
199
|
+
tasks = [fetch_page(session, url) for url in urls]
|
|
200
|
+
responses = await asyncio.gather(*tasks)
|
|
201
|
+
final_results = []
|
|
202
|
+
for item in responses:
|
|
203
|
+
url = item["url"]
|
|
204
|
+
html = item["html"]
|
|
205
|
+
if html:
|
|
206
|
+
content = await extract_content_with_trafilatura(html)
|
|
207
|
+
if content:
|
|
208
|
+
final_results.append({"url": url, "content": content, "type": "web"})
|
|
209
|
+
else:
|
|
210
|
+
final_results.append({"url": url, "content": "No content found", "type": "web"})
|
|
211
|
+
else:
|
|
212
|
+
final_results.append({"url": url, "content": "Page not found", "type": "web"})
|
|
213
|
+
return final_results
|
|
175
214
|
#endregion
|
|
176
215
|
|
|
177
216
|
#class variables (static)
|
|
@@ -180,6 +219,7 @@ class ToolManager:
|
|
|
180
219
|
"image_generator": ToolConfig(function=image_generator, model=ImageGeneratorInput),
|
|
181
220
|
"llm_chain": ToolConfig(function=llm_chain, model=LlmChainInput),
|
|
182
221
|
"search_online": ToolConfig(function=search_online, model=SearchOnlineInput),
|
|
222
|
+
"search_online_google": ToolConfig(function=search_online_google, model=SearchOnlineInput),
|
|
183
223
|
}
|
|
184
224
|
|
|
185
225
|
#instance methods
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ws_bom_robot_app
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.60
|
|
4
4
|
Summary: A FastAPI application serving ws bom/robot/llm platform ai.
|
|
5
5
|
Home-page: https://github.com/websolutespa/bom
|
|
6
6
|
Author: Websolute Spa
|
|
@@ -50,6 +50,7 @@ Requires-Dist: unstructured-ingest[slack]
|
|
|
50
50
|
Requires-Dist: html5lib==1.1
|
|
51
51
|
Requires-Dist: markdownify==0.14.1
|
|
52
52
|
Requires-Dist: duckduckgo-search==8.0.4
|
|
53
|
+
Requires-Dist: langchain_google_community==2.0.7
|
|
53
54
|
Dynamic: author
|
|
54
55
|
Dynamic: author-email
|
|
55
56
|
Dynamic: classifier
|
|
@@ -26,7 +26,7 @@ ws_bom_robot_app/llm/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
|
|
|
26
26
|
ws_bom_robot_app/llm/providers/llm_manager.py,sha256=zIkxgTLYQCcup2Ixf4eWap4mNinuJH2YmkjLjZGDyJM,8371
|
|
27
27
|
ws_bom_robot_app/llm/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
28
|
ws_bom_robot_app/llm/tools/tool_builder.py,sha256=p_Q32_-OSydcxzj69PgPIuiny816zYv5dVsCHSY0ELc,1188
|
|
29
|
-
ws_bom_robot_app/llm/tools/tool_manager.py,sha256=
|
|
29
|
+
ws_bom_robot_app/llm/tools/tool_manager.py,sha256=J8WQnjXpLe3Sv6thUi_kgXIDBmt1Z4C-ASzs4RHsVNg,10253
|
|
30
30
|
ws_bom_robot_app/llm/tools/utils.py,sha256=Ba7ScFZPVJ3ke8KLO8ik1wyR2f_zC99Bikqx0OGnKoI,1924
|
|
31
31
|
ws_bom_robot_app/llm/tools/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
32
|
ws_bom_robot_app/llm/tools/models/main.py,sha256=pBQNWPd1OZgZ2xkOnUOawNbujQ5oJXLdyuAex1afLWc,579
|
|
@@ -65,7 +65,7 @@ ws_bom_robot_app/llm/vector_store/loader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5
|
|
|
65
65
|
ws_bom_robot_app/llm/vector_store/loader/base.py,sha256=L_ugekNuAq0N9O-24wtlHSNHkqSeD-KsJrfGt_FX9Oc,5340
|
|
66
66
|
ws_bom_robot_app/llm/vector_store/loader/docling.py,sha256=yP0zgXLeFAlByaYuj-6cYariuknckrFds0dxdRcnVz8,3456
|
|
67
67
|
ws_bom_robot_app/llm/vector_store/loader/json_loader.py,sha256=LDppW0ZATo4_1hh-KlsAM3TLawBvwBxva_a7k5Oz1sc,858
|
|
68
|
-
ws_bom_robot_app-0.0.
|
|
69
|
-
ws_bom_robot_app-0.0.
|
|
70
|
-
ws_bom_robot_app-0.0.
|
|
71
|
-
ws_bom_robot_app-0.0.
|
|
68
|
+
ws_bom_robot_app-0.0.60.dist-info/METADATA,sha256=qOMWEMQar7dYSZllRX9OOj_F198nzb4Xmd6Ur3MR1FE,8456
|
|
69
|
+
ws_bom_robot_app-0.0.60.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
70
|
+
ws_bom_robot_app-0.0.60.dist-info/top_level.txt,sha256=Yl0akyHVbynsBX_N7wx3H3ZTkcMLjYyLJs5zBMDAKcM,17
|
|
71
|
+
ws_bom_robot_app-0.0.60.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|