forked from langgenius/dify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove Langchain tools import (langgenius#3407)
- Loading branch information
Showing
9 changed files
with
98 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from typing import NamedTuple, Union | ||
|
||
|
||
@dataclass | ||
class ReactAction: | ||
"""A full description of an action for an ReactAction to execute.""" | ||
|
||
tool: str | ||
"""The name of the Tool to execute.""" | ||
tool_input: Union[str, dict] | ||
"""The input to pass in to the Tool.""" | ||
log: str | ||
"""Additional information to log about the action.""" | ||
|
||
|
||
class ReactFinish(NamedTuple): | ||
"""The final return value of an ReactFinish.""" | ||
|
||
return_values: dict | ||
"""Dictionary of return values.""" | ||
log: str | ||
"""Additional information to log about the return value""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
api/core/tools/tool/dataset_retriever/dataset_retriever_base_tool.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from abc import abstractmethod | ||
from typing import Any, Optional | ||
|
||
from msal_extensions.persistence import ABC | ||
from pydantic import BaseModel | ||
|
||
from core.callback_handler.index_tool_callback_handler import DatasetIndexToolCallbackHandler | ||
|
||
|
||
class DatasetRetrieverBaseTool(BaseModel, ABC): | ||
"""Tool for querying a Dataset.""" | ||
name: str = "dataset" | ||
description: str = "use this to retrieve a dataset. " | ||
tenant_id: str | ||
top_k: int = 2 | ||
score_threshold: Optional[float] = None | ||
hit_callbacks: list[DatasetIndexToolCallbackHandler] = [] | ||
return_resource: bool | ||
retriever_from: str | ||
|
||
class Config: | ||
arbitrary_types_allowed = True | ||
|
||
@abstractmethod | ||
def _run( | ||
self, | ||
*args: Any, | ||
**kwargs: Any, | ||
) -> Any: | ||
"""Use the tool. | ||
Add run_manager: Optional[CallbackManagerForToolRun] = None | ||
to child implementations to enable tracing, | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters