Files
crewAI/lib/crewai-tools/src/crewai_tools/adapters/rag_adapter.py
Greyson LaLonde c5ea415cda
Some checks failed
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Check Documentation Broken Links / Check broken links (push) Has been cancelled
Vulnerability Scan / pip-audit (push) Has been cancelled
Nightly Canary Release / Check for new commits (push) Has been cancelled
Nightly Canary Release / Build nightly packages (push) Has been cancelled
Nightly Canary Release / Publish nightly to PyPI (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
chore(crewai-tools): drop self-explanatory comments
2026-05-26 16:25:07 -07:00

38 lines
1.0 KiB
Python

from typing import Any
from crewai_tools.rag.core import RAG
from crewai_tools.tools.rag.rag_tool import Adapter
class RAGAdapter(Adapter):
def __init__(
self,
collection_name: str = "crewai_knowledge_base",
persist_directory: str | None = None,
embedding_model: str = "text-embedding-3-small",
top_k: int = 5,
embedding_api_key: str | None = None,
**embedding_kwargs: Any,
):
super().__init__()
embedding_config = {"api_key": embedding_api_key, **embedding_kwargs}
self._adapter = RAG(
collection_name=collection_name,
persist_directory=persist_directory,
embedding_model=embedding_model,
top_k=top_k,
embedding_config=embedding_config,
)
def query(self, question: str) -> str: # type: ignore[override]
return self._adapter.query(question)
def add(
self,
*args: Any,
**kwargs: Any,
) -> None:
self._adapter.add(*args, **kwargs)