Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split up display name and name for Tools #241

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/backend/config/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@


class ToolName(StrEnum):
Wiki_Retriever_LangChain = "Wikipedia"
Wiki_Retriever_LangChain = "wikipedia"
Search_File = "search_file"
Read_File = "read_document"
Python_Interpreter = "Python_Interpreter"
Calculator = "Calculator"
Tavily_Internet_Search = "Internet_Search"
Python_Interpreter = "python_interpreter"
Calculator = "calculator"
Tavily_Internet_Search = "internet_search"


ALL_TOOLS = {
ToolName.Wiki_Retriever_LangChain: ManagedTool(
name=ToolName.Wiki_Retriever_LangChain,
display_name="Wikipedia",
implementation=LangChainWikiRetriever,
parameter_definitions={
"query": {
Expand All @@ -54,6 +55,7 @@ class ToolName(StrEnum):
),
ToolName.Search_File: ManagedTool(
name=ToolName.Search_File,
display_name="Search File",
implementation=SearchFileTool,
parameter_definitions={
"search_query": {
Expand All @@ -75,6 +77,7 @@ class ToolName(StrEnum):
),
ToolName.Read_File: ManagedTool(
name=ToolName.Read_File,
display_name="Read Document",
implementation=ReadFileTool,
parameter_definitions={
"filename": {
Expand All @@ -91,6 +94,7 @@ class ToolName(StrEnum):
),
ToolName.Python_Interpreter: ManagedTool(
name=ToolName.Python_Interpreter,
display_name="Python Interpreter",
implementation=PythonInterpreter,
parameter_definitions={
"code": {
Expand All @@ -107,6 +111,7 @@ class ToolName(StrEnum):
),
ToolName.Calculator: ManagedTool(
name=ToolName.Calculator,
display_name="Calculator",
implementation=Calculator,
parameter_definitions={
"code": {
Expand All @@ -123,6 +128,7 @@ class ToolName(StrEnum):
),
ToolName.Tavily_Internet_Search: ManagedTool(
name=ToolName.Tavily_Internet_Search,
display_name="Web Search",
implementation=TavilyInternetSearch,
parameter_definitions={
"query": {
Expand Down
1 change: 1 addition & 0 deletions src/backend/schemas/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ToolInput(BaseModel):

class Tool(BaseModel):
name: str
display_name: str = ""
description: Optional[str] = ""
parameter_definitions: Optional[dict] = {}

Expand Down
18 changes: 12 additions & 6 deletions src/community/config/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@


class CommunityToolName(StrEnum):
Arxiv = "Arxiv"
Connector = "Connector"
Pub_Med = "Pub Med"
File_Upload_LlamaIndex = "File Reader - LlamaIndex"
Wolfram_Alpha = "Wolfram_Alpha"
ClinicalTrials = "ClinicalTrials"
Arxiv = "arxiv"
Connector = "example_connector"
Pub_Med = "pub_med"
File_Upload_LlamaIndex = "file_reader_llamaindex"
Wolfram_Alpha = "wolfram_alpha"
ClinicalTrials = "clinical_trials"


COMMUNITY_TOOLS = {
CommunityToolName.Arxiv: ManagedTool(
name=CommunityToolName.Arxiv,
display_name="Arxiv",
implementation=ArxivRetriever,
parameter_definitions={
"query": {
Expand All @@ -40,6 +41,7 @@ class CommunityToolName(StrEnum):
),
CommunityToolName.Connector: ManagedTool(
name=CommunityToolName.Connector,
display_name="Example Connector",
implementation=ConnectorRetriever,
is_visible=True,
is_available=ConnectorRetriever.is_available(),
Expand All @@ -49,6 +51,7 @@ class CommunityToolName(StrEnum):
),
CommunityToolName.Pub_Med: ManagedTool(
name=CommunityToolName.Pub_Med,
display_name="PubMed",
implementation=PubMedRetriever,
parameter_definitions={
"query": {
Expand All @@ -65,6 +68,7 @@ class CommunityToolName(StrEnum):
),
CommunityToolName.File_Upload_LlamaIndex: ManagedTool(
name=CommunityToolName.File_Upload_LlamaIndex,
display_name="File Reader",
implementation=LlamaIndexUploadPDFRetriever,
is_visible=True,
is_available=LlamaIndexUploadPDFRetriever.is_available(),
Expand All @@ -74,6 +78,7 @@ class CommunityToolName(StrEnum):
),
CommunityToolName.Wolfram_Alpha: ManagedTool(
name=CommunityToolName.Wolfram_Alpha,
display_name="Wolfram Alpha",
implementation=WolframAlpha,
is_visible=False,
is_available=WolframAlpha.is_available(),
Expand All @@ -83,6 +88,7 @@ class CommunityToolName(StrEnum):
),
CommunityToolName.ClinicalTrials: ManagedTool(
name=CommunityToolName.ClinicalTrials,
display_name="Clinical Trials",
implementation=ClinicalTrials,
is_visible=True,
is_available=ClinicalTrials.is_available(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { Category } from './Category';

export type ManagedTool = {
name: string;
display_name?: string;
description?: string | null;
parameter_definitions?: Record<string, any> | null;
kwargs?: Record<string, any>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/* eslint-disable */
export type Tool = {
name: string;
display_name?: string;
description?: string | null;
parameter_definitions?: Record<string, any> | null;
};
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const ToolSection = () => {
/>
</div>
<div className="flex flex-col gap-y-5">
{tools.map(({ name, is_available, description, error_message }) => {
{tools.map(({ name, display_name, is_available, description, error_message }) => {
const enabledTool = enabledTools.find(
(enabledTool) => enabledTool.name.toLocaleLowerCase() === name.toLocaleLowerCase()
);
Expand All @@ -109,7 +109,7 @@ const ToolSection = () => {
onChange={(e) => {
handleToolToggle(name, e.target.checked);
}}
label={name}
label={display_name}
name={name}
theme="secondary"
dataTestId={`checkbox-tool-${name}`}
Expand Down
Loading