mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-03 00:02:36 +00:00
Merge pull request #64 from sethcoast/pdf-search-tool-query-fix
Limit PDF search results to the provided PDF (IF a PDF is provided)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from typing import Any, Optional, Type
|
||||
|
||||
from embedchain.models.data_type import DataType
|
||||
from pydantic import model_validator
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
|
||||
from ..rag.rag_tool import RagTool
|
||||
@@ -35,6 +36,22 @@ class PDFSearchTool(RagTool):
|
||||
self.args_schema = FixedPDFSearchToolSchema
|
||||
self._generate_description()
|
||||
|
||||
@model_validator(mode="after")
|
||||
def _set_default_adapter(self):
|
||||
if isinstance(self.adapter, RagTool._AdapterPlaceholder):
|
||||
from embedchain import App
|
||||
|
||||
from crewai_tools.adapters.pdf_embedchain_adapter import (
|
||||
PDFEmbedchainAdapter,
|
||||
)
|
||||
|
||||
app = App.from_config(config=self.config) if self.config else App()
|
||||
self.adapter = PDFEmbedchainAdapter(
|
||||
embedchain_app=app, summarize=self.summarize
|
||||
)
|
||||
|
||||
return self
|
||||
|
||||
def add(
|
||||
self,
|
||||
*args: Any,
|
||||
|
||||
Reference in New Issue
Block a user