Web Enhanced Self Reflecting Agent
agentic-aiagenticagentsgenaiAIhaystack-cookbookgenai-usecaseshaystack-ainotebooksPythonragai-tools
Export
Web-Enhanced Self-Reflecting Agent
Notebook by Bilge Yucel
In this notebook, we will use Ollama, Gemma2 and Haystack to build a self-reflecting agent that can leverage web resources to augment its self-reflection and decision-making capabilities.
📚 Useful Sources
Install Dependencies
[ ]
Enable Tracing
[ ]
Disable Tracing
[ ]
Index Documents for the Agent
[2]
/Users/bilgeyucel/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020 warnings.warn(
{'writer': {'documents_written': 70}} API Keys
[3]
Build the Agent
Routes
[4]
Agent Prompt
[5]
Web-Enhanced Self-Reflecting Agent
[6]
<haystack.core.pipeline.pipeline.Pipeline object at 0x286bf0f40> ,🚅 Components , - retriever: InMemoryBM25Retriever , - prompt_builder_for_agent: PromptBuilder , - llm_for_agent: OllamaGenerator , - web_search: SerperDevWebSearch , - router: ConditionalRouter ,🛤️ Connections , - retriever.documents -> prompt_builder_for_agent.documents (List[Document]) , - prompt_builder_for_agent.prompt -> llm_for_agent.prompt (str) , - llm_for_agent.replies -> router.replies (List[str]) , - web_search.documents -> prompt_builder_for_agent.web_documents (List[Document]) , - router.go_web -> web_search.query (str)
[7]
/Users/bilgeyucel/Library/Python/3.9/lib/python/site-packages/haystack/core/pipeline/pipeline.py:521: RuntimeWarning: Pipeline is stuck running in a loop. Partial outputs will be returned. Check the Pipeline graph for possible issues. warn(RuntimeWarning(msg))
[8]
Haystack is an open source framework for building production-ready LLM applications, retrieval-augmented generative pipelines and state-of-the-art search systems that work intelligently over large document collections. It lets you quickly try out the latest AI models while being flexible and easy to use. Our inspiring community of users and builders has helped shape Haystack into the modular, intuitive, complete framework it is today.
[9]
[10]
Gemma 2 is Google's latest iteration of open LLMs. It comes in two sizes, 9 billion and 27 billion parameters with base (pre-trained) and instruction-tuned versions. **Used Links:** https://huggingface.co/blog/gemma2