mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 16:48:30 +00:00
Make RagTool processs-safe (#399)
This commit adds a file lock to `RagTool`. As it uses Embedchain and Chroma internally, this tool was not process-safe.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import portalocker
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any
|
||||
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
||||
|
||||
|
||||
class Adapter(BaseModel, ABC):
|
||||
@@ -39,10 +41,11 @@ class RagTool(BaseTool):
|
||||
def _set_default_adapter(self):
|
||||
if isinstance(self.adapter, RagTool._AdapterPlaceholder):
|
||||
from embedchain import App
|
||||
|
||||
from crewai_tools.adapters.embedchain_adapter import EmbedchainAdapter
|
||||
|
||||
app = App.from_config(config=self.config) if self.config else App()
|
||||
with portalocker.Lock("crewai-rag-tool.lock", timeout=10):
|
||||
app = App.from_config(config=self.config) if self.config else App()
|
||||
|
||||
self.adapter = EmbedchainAdapter(
|
||||
embedchain_app=app, summarize=self.summarize
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user