datapizza-ai-tools-duckduckgo 0.0.2__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.
@@ -0,0 +1,38 @@
|
|
1
|
+
from ddgs import DDGS
|
2
|
+
|
3
|
+
from datapizza.tools import Tool
|
4
|
+
|
5
|
+
|
6
|
+
class DuckDuckGoSearchTool(Tool):
|
7
|
+
"""
|
8
|
+
The DuckDuckGo Search tool.
|
9
|
+
It allows you to search the web for the given query.
|
10
|
+
"""
|
11
|
+
|
12
|
+
def __init__(self):
|
13
|
+
"""Initializes the DuckDuckGoSearch tool."""
|
14
|
+
super().__init__(
|
15
|
+
name="duckduckgo_search",
|
16
|
+
description="Enables DuckDuckGo Search for grounding model responses.",
|
17
|
+
func=self.__call__,
|
18
|
+
)
|
19
|
+
|
20
|
+
def _format_results(self, results: list[str]) -> str:
|
21
|
+
"""Format the results."""
|
22
|
+
return "## Search Results\n\n" + "\n\n".join(
|
23
|
+
[
|
24
|
+
f"[{result['title']}]({result['href']})\n{result['body']}"
|
25
|
+
for result in results
|
26
|
+
]
|
27
|
+
)
|
28
|
+
|
29
|
+
def __call__(self, query: str) -> list[str]:
|
30
|
+
"""Invoke the tool."""
|
31
|
+
res = self.search(query)
|
32
|
+
return self._format_results(res)
|
33
|
+
|
34
|
+
def search(self, query: str) -> list[str]:
|
35
|
+
"""Search the web for the given query."""
|
36
|
+
with DDGS() as ddg:
|
37
|
+
results = list(ddg.text(query))
|
38
|
+
return results
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: datapizza-ai-tools-duckduckgo
|
3
|
+
Version: 0.0.2
|
4
|
+
Summary: Azure Document Intelligence parser for the datapizza-ai framework
|
5
|
+
Author-email: Datapizza <datapizza@datapizza.tech>
|
6
|
+
License: MIT
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
8
|
+
Classifier: Operating System :: OS Independent
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
10
|
+
Requires-Python: <4,>=3.10.0
|
11
|
+
Requires-Dist: datapizza-ai-core==0.0.1
|
12
|
+
Requires-Dist: ddgs>=9.6.0
|
@@ -0,0 +1,5 @@
|
|
1
|
+
datapizza/tools/duckduckgo/__init__.py,sha256=0CGWs0NVHjduXMh1fBwEVbZgSWqdyECnylyj1jXVCjk,75
|
2
|
+
datapizza/tools/duckduckgo/base.py,sha256=0rhiqIxoAIlJTouMTfketA0ibj6i95uMFCnIpHV0Av4,1115
|
3
|
+
datapizza_ai_tools_duckduckgo-0.0.2.dist-info/METADATA,sha256=yDyfgN3pPRw1Kbr-4Jt-Tvnjq4um8iq-cH5Hzw2M5AQ,454
|
4
|
+
datapizza_ai_tools_duckduckgo-0.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
5
|
+
datapizza_ai_tools_duckduckgo-0.0.2.dist-info/RECORD,,
|