feat: backend orkestrasyonunu ve arac entegrasyonlarini genislet
This commit is contained in:
47
backend/app/tools/registry.py
Normal file
47
backend/app/tools/registry.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from pathlib import Path
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.config import get_settings
|
||||
from app.db import SecretORM
|
||||
from app.models import RuntimeSettings
|
||||
from app.tools.apple_notes import AppleNotesTool
|
||||
from app.tools.browser_use import BrowserUseTool
|
||||
from app.tools.brave_search import BraveSearchTool
|
||||
from app.tools.files import FilesTool
|
||||
from app.tools.second_brain import SecondBrainTool
|
||||
from app.tools.terminal import TerminalTool
|
||||
from app.tools.web_fetch import WebFetchTool
|
||||
|
||||
|
||||
def build_tools(runtime: RuntimeSettings, workspace_root: Path, session: Session) -> dict[str, object]:
|
||||
enabled = {tool.name for tool in runtime.tools if tool.enabled}
|
||||
tools: dict[str, object] = {}
|
||||
settings = get_settings()
|
||||
|
||||
if "files" in enabled:
|
||||
tools["files"] = FilesTool(workspace_root)
|
||||
if "apple_notes" in enabled:
|
||||
tools["apple_notes"] = AppleNotesTool()
|
||||
if "browser_use" in enabled:
|
||||
secret = session.get(SecretORM, "zai_api_key")
|
||||
api_key = secret.value if secret else settings.zai_api_key
|
||||
tools["browser_use"] = BrowserUseTool(workspace_root, runtime, settings, api_key)
|
||||
if "brave_search" in enabled and runtime.search_provider == "brave":
|
||||
secret = session.get(SecretORM, "brave_api_key")
|
||||
api_key = secret.value if secret else settings.brave_api_key
|
||||
tools["brave_search"] = BraveSearchTool(api_key)
|
||||
if "second_brain" in enabled:
|
||||
secret = session.get(SecretORM, "anythingllm_api_key")
|
||||
api_key = secret.value if secret else settings.anythingllm_api_key
|
||||
tools["second_brain"] = SecondBrainTool(
|
||||
base_url=runtime.anythingllm_base_url,
|
||||
workspace_slug=runtime.anythingllm_workspace_slug,
|
||||
api_key=api_key,
|
||||
)
|
||||
if "web_fetch" in enabled:
|
||||
tools["web_fetch"] = WebFetchTool()
|
||||
if "terminal" in enabled:
|
||||
tools["terminal"] = TerminalTool(runtime.terminal_mode, workspace_root)
|
||||
|
||||
return tools
|
||||
Reference in New Issue
Block a user