Web Search#
Overview#
Web Search Drivers can be used to search for links from a search query. They are used by BaseWebSearchDriver to provide its functionality. All Web Search Drivers implement the following methods:
search()searches the web and returns a ListArtifact that contains JSON-serializable TextArtifact s with the search results.
You can use Web Search Drivers with Structures :
from griptape.drivers.web_search.duck_duck_go import DuckDuckGoWebSearchDriver
from griptape.structures import Agent
from griptape.tools import PromptSummaryTool, WebSearchTool
agent = Agent(
tools=[WebSearchTool(web_search_driver=DuckDuckGoWebSearchDriver()), PromptSummaryTool(off_prompt=False)],
)
agent.run("Give me some websites with information about AI frameworks.")
PromptTask 45a53f1024494baab41a1f10a67017b1
Output: Here are some websites with information about AI
frameworks:
1. [The Top 16 AI Frameworks and Libraries: A Beginners Guide - DataCamp](https://www.datacamp.com/blog/top-ai-frameworks-and-lib raries)
2. [AI Frameworks: Top Types To Adopt in 2024 - Splunk](https://www.splunk.com/en_us/blog/learn/ai-frameworks.htm l)
3. [Top AI Frameworks in 2024: A Review - BairesDev](https://www.bairesdev.com/blog/ai-frameworks/)
4. [The Top 16 AI Frameworks and Libraries - AI Slackers](https://aislackers.com/the-top-16-ai-frameworks-and-lib raries/)
5. [Top AI Frameworks in 2024: Artificial Intelligence Frameworks Comparison - Clockwise Software](https://clockwise.software/blog/artificial-intelligence -framework/)
Or use them independently:
from griptape.drivers.web_search.duck_duck_go import DuckDuckGoWebSearchDriver
driver = DuckDuckGoWebSearchDriver()
driver.search("griptape ai")
{"title": "The Top 16 AI Frameworks and Libraries: A Beginners Guide", "url": "https://www.datacamp.com/blog/top-ai-frameworks-and-libraries", "description": "PyTorch. Torch is an open-source machine learning library known for its dynamic computational graph and is favored by researchers. The framework is excellent for prototyping and experimentation. Moreover, its empowered by growing community support, with tools like PyTorch being built on the library."}
{"title": "Top 11 AI Frameworks and Tools in 2024 | Fively | 5ly.co", "url": "https://5ly.co/blog/best-ai-frameworks/", "description": "Discover the top 11 modern artificial intelligence tools and frameworks to build robust architectures for your AI-powered apps. ... - Some advanced use cases may need further fine-tuning. Caffe 2. Now we move on to deep learning tools and frameworks. The first one is Caffe 2: an open-source deep learning framework with modularity and speed in ..."}
{"title": "The Top 16 AI Frameworks and Libraries | AI Slackers", "url": "https://aislackers.com/the-top-16-ai-frameworks-and-libraries/", "description": "Experiment with different frameworks to find the one that aligns with your needs and goals as a data practitioner. Embrace the world of AI frameworks, and embark on a journey of building smarter software with confidence. Discover the top AI frameworks and libraries like PyTorch, Scikit-Learn, TensorFlow, Keras, LangChain, and more."}
Web Search Drivers#
Google#
The GoogleWebSearchDriver uses the Google Custom Search JSON API for web searching.
import os
from griptape.drivers.web_search.google import GoogleWebSearchDriver
driver = GoogleWebSearchDriver(
api_key=os.environ["GOOGLE_API_KEY"],
search_id=os.environ["GOOGLE_API_SEARCH_ID"],
)
driver.search("griptape ai")
DuckDuckGo#
The DuckDuckGoWebSearchDriver uses the duckduckgo_search SDK for web searching.
from griptape.drivers.web_search.duck_duck_go import DuckDuckGoWebSearchDriver
driver = DuckDuckGoWebSearchDriver()
driver.search("griptape ai")
Tavily#
import os
from griptape.drivers.web_search.tavily import TavilyWebSearchDriver
driver = TavilyWebSearchDriver(api_key=os.environ["TAVILY_API_KEY"])
driver.search("griptape ai")
Exa#
import os
from griptape.drivers.web_search.exa import ExaWebSearchDriver
driver = ExaWebSearchDriver(api_key=os.environ["EXA_API_KEY"])
driver.search("griptape ai")
Perplexity#
The PerplexityWebSearchDriver uses the Perplexity Prompt Driver internally.
import os
from griptape.drivers.web_search.perplexity import PerplexityWebSearchDriver
driver = PerplexityWebSearchDriver(
api_key=os.environ["PERPLEXITY_API_KEY"],
)
result = driver.search("griptape ai")
print(result.to_text())
# The search results will only contain a single Artifact.
# This Artifact contains the search results and any citations.
for citation in result[0].meta["citations"]:
print(citation)
`
Set up your OpenAI API key:
export OPENAI_API_KEY=your_api_key_here
Create a Python file (e.g.,
app.py) and import necessary modules from Griptape[3].Build your AI application using Griptape’s components such as agents, pipelines, and tools[3].
Griptape offers a powerful and flexible way to create AI-driven applications, from simple chatbots to complex multi-agent systems. Its modular approach allows developers to easily integrate custom tools and external resources, enhancing the capabilities of AI agents[3][4]. https://www.griptape.ai griptape-ai https://www.youtube.com/watch?v=AEcztigpnc0 https://www.youtube.com/watch?v=1FFeMZyWxJA griptape-ai/griptape https://www.youtube.com/@griptape-ai
````