-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from ant-xuexiao/feat_tool_knowledge
feat: add the knowledge tool
- Loading branch information
Showing
3 changed files
with
73 additions
and
49 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,19 @@ | ||
from langchain.tools import tool | ||
from rag import retrieval | ||
|
||
|
||
@tool | ||
def search_knowledge( | ||
query: str, | ||
): | ||
""" | ||
Search for information based on the query. When use this tool, do not translate the search query. Use the original query language to search. eg: When user's question is 'Ant Design 有哪些新特性?', the query should be 'Ant Design 有哪些新特性?'. | ||
:param query: The user's question. | ||
""" | ||
try: | ||
return retrieval.search_knowledge(query) | ||
except Exception as e: | ||
print(f"An error occurred: {e}") | ||
return None | ||
|