Skip to content

Commit

Permalink
ready to deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaytonSmith committed Aug 7, 2024
1 parent ac58ad2 commit ad2eb48
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 109 deletions.
206 changes: 103 additions & 103 deletions src/backend/config/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,29 @@ class ToolName(StrEnum):


ALL_TOOLS = {
ToolName.Wiki_Retriever_LangChain: ManagedTool(
name=ToolName.Wiki_Retriever_LangChain,
implementation=LangChainWikiRetriever,
parameter_definitions={
"query": {
"description": "Query for retrieval.",
"type": "str",
"required": True,
}
},
kwargs={"chunk_size": 300, "chunk_overlap": 0},
is_visible=True,
is_available=LangChainWikiRetriever.is_available(),
error_message="LangChainWikiRetriever not available.",
category=Category.DataLoader,
description="Retrieves documents from Wikipedia using LangChain.",
),
# ToolName.Wiki_Retriever_LangChain: ManagedTool(
# name=ToolName.Wiki_Retriever_LangChain,
# implementation=LangChainWikiRetriever,
# parameter_definitions={
# "query": {
# "description": "Query for retrieval.",
# "type": "str",
# "required": True,
# }
# },
# kwargs={"chunk_size": 300, "chunk_overlap": 0},
# is_visible=True,
# is_available=LangChainWikiRetriever.is_available(),
# error_message="LangChainWikiRetriever not available.",
# category=Category.DataLoader,
# description="Retrieves documents from Wikipedia using LangChain.",
# ),
ToolName.Minimap: ManagedTool(
name=ToolName.Minimap,
implementation=LangChainMinimapRetriever,
parameter_definitions={
"query": {
"description": "Query for searching the news. It can be a topic, a named entities, or a quoted keyword.",
"description": "Search API that takes a query or phrase.",
"type": "str",
"required": True,
}
Expand All @@ -70,91 +70,91 @@ class ToolName(StrEnum):
category=Category.DataLoader,
description="Fetches the most relevant news and content from Minimap.ai.",
),
ToolName.Search_File: ManagedTool(
name=ToolName.Search_File,
implementation=SearchFileTool,
parameter_definitions={
"search_query": {
"description": "Textual search query to search over the file's content for",
"type": "str",
"required": True,
},
"filenames": {
"description": "A list of one or more uploaded filename strings to search over",
"type": "list",
"required": True,
},
},
is_visible=True,
is_available=SearchFileTool.is_available(),
error_message="SearchFileTool not available.",
category=Category.FileLoader,
description="Performs a search over a list of one or more of the attached files for a textual search query",
),
ToolName.Read_File: ManagedTool(
name=ToolName.Read_File,
implementation=ReadFileTool,
parameter_definitions={
"filename": {
"description": "The name of the attached file to read.",
"type": "str",
"required": True,
}
},
is_visible=True,
is_available=ReadFileTool.is_available(),
error_message="ReadFileTool not available.",
category=Category.FileLoader,
description="Returns the textual contents of an uploaded file, broken up in text chunks.",
),
ToolName.Python_Interpreter: ManagedTool(
name=ToolName.Python_Interpreter,
implementation=PythonInterpreter,
parameter_definitions={
"code": {
"description": "Python code to execute using an interpreter",
"type": "str",
"required": True,
}
},
is_visible=True,
is_available=PythonInterpreter.is_available(),
error_message="PythonInterpreterFunctionTool not available, please make sure to set the PYTHON_INTERPRETER_URL environment variable.",
category=Category.Function,
description="Runs python code in a sandbox.",
),
ToolName.Calculator: ManagedTool(
name=ToolName.Calculator,
implementation=Calculator,
parameter_definitions={
"code": {
"description": "The expression for the calculator to evaluate, it should be a valid mathematical expression.",
"type": "str",
"required": True,
}
},
is_visible=True,
is_available=Calculator.is_available(),
error_message="Calculator tool not available.",
category=Category.Function,
description="This is a powerful multi-purpose calculator. It is capable of a wide array of math calculation and a range of other useful features. Features include a large library of customizable functions, unit calculations and conversion, currency conversion, symbolic calculations (including integrals and equations) and interval arithmetic.",
),
ToolName.Tavily_Internet_Search: ManagedTool(
name=ToolName.Tavily_Internet_Search,
implementation=TavilyInternetSearch,
parameter_definitions={
"query": {
"description": "Query for retrieval.",
"type": "str",
"required": True,
}
},
is_visible=True,
is_available=TavilyInternetSearch.is_available(),
error_message="TavilyInternetSearch not available, please make sure to set the TAVILY_API_KEY environment variable.",
category=Category.DataLoader,
description="Returns a list of relevant document snippets for a textual query retrieved from the internet using Tavily.",
),
# ToolName.Search_File: ManagedTool(
# name=ToolName.Search_File,
# implementation=SearchFileTool,
# parameter_definitions={
# "search_query": {
# "description": "Textual search query to search over the file's content for",
# "type": "str",
# "required": True,
# },
# "filenames": {
# "description": "A list of one or more uploaded filename strings to search over",
# "type": "list",
# "required": True,
# },
# },
# is_visible=True,
# is_available=SearchFileTool.is_available(),
# error_message="SearchFileTool not available.",
# category=Category.FileLoader,
# description="Performs a search over a list of one or more of the attached files for a textual search query",
# ),
# ToolName.Read_File: ManagedTool(
# name=ToolName.Read_File,
# implementation=ReadFileTool,
# parameter_definitions={
# "filename": {
# "description": "The name of the attached file to read.",
# "type": "str",
# "required": True,
# }
# },
# is_visible=True,
# is_available=ReadFileTool.is_available(),
# error_message="ReadFileTool not available.",
# category=Category.FileLoader,
# description="Returns the textual contents of an uploaded file, broken up in text chunks.",
# ),
# ToolName.Python_Interpreter: ManagedTool(
# name=ToolName.Python_Interpreter,
# implementation=PythonInterpreter,
# parameter_definitions={
# "code": {
# "description": "Python code to execute using an interpreter",
# "type": "str",
# "required": True,
# }
# },
# is_visible=True,
# is_available=PythonInterpreter.is_available(),
# error_message="PythonInterpreterFunctionTool not available, please make sure to set the PYTHON_INTERPRETER_URL environment variable.",
# category=Category.Function,
# description="Runs python code in a sandbox.",
# ),
# ToolName.Calculator: ManagedTool(
# name=ToolName.Calculator,
# implementation=Calculator,
# parameter_definitions={
# "code": {
# "description": "The expression for the calculator to evaluate, it should be a valid mathematical expression.",
# "type": "str",
# "required": True,
# }
# },
# is_visible=True,
# is_available=Calculator.is_available(),
# error_message="Calculator tool not available.",
# category=Category.Function,
# description="This is a powerful multi-purpose calculator. It is capable of a wide array of math calculation and a range of other useful features. Features include a large library of customizable functions, unit calculations and conversion, currency conversion, symbolic calculations (including integrals and equations) and interval arithmetic.",
# ),
# ToolName.Tavily_Internet_Search: ManagedTool(
# name=ToolName.Tavily_Internet_Search,
# implementation=TavilyInternetSearch,
# parameter_definitions={
# "query": {
# "description": "Query for retrieval.",
# "type": "str",
# "required": True,
# }
# },
# is_visible=True,
# is_available=TavilyInternetSearch.is_available(),
# error_message="TavilyInternetSearch not available, please make sure to set the TAVILY_API_KEY environment variable.",
# category=Category.DataLoader,
# description="Returns a list of relevant document snippets for a textual query retrieved from the internet using Tavily.",
# ),
}


Expand Down
7 changes: 3 additions & 4 deletions src/backend/tools/minimap.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class MinimapAPIWrapper(BaseModel):
max_retry: int = 5

# Default values for the parameters
top_k_results: int = 15
top_k_results: int = 100
MAX_QUERY_LENGTH: int = 300
doc_content_chars_max: int = 2000

Expand Down Expand Up @@ -97,11 +97,10 @@ def run(self, query: str) -> str:
for result in results:
result['doc_id'] = result.pop('id')

print(results)
return results

except Exception as ex:
return f"PubMed exception: {ex}"
return f"Minimap exception: {ex}"


class MinimapQueryRun(BaseTool):
Expand All @@ -122,7 +121,7 @@ def _run(
query: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
"""Use the PubMed tool."""
"""Use the Minimap tool."""
return self.api_wrapper.run(query)

class LangChainMinimapRetriever(CohereBaseTool):
Expand Down
11 changes: 9 additions & 2 deletions src/interfaces/coral_web/src/components/Configuration/Tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export const Tools: React.FC<{ className?: string }> = ({ className = '' }) => {
<ToolSection />

{/* File upload is not supported for conversarions without an id */}
{conversationId && files.length > 0 && (
{/* {conversationId && files.length > 0 && (
<>
<hr className="my-6 border-t border-marble-400" />
<FilesSection />
</>
)}
)} */}
</article>
);
};
Expand Down Expand Up @@ -72,6 +72,13 @@ const ToolSection = () => {
updateEnabledTools(updatedTools);
};

// useEffect to enable all tools by default
React.useEffect(() => {
if (tools.length > 0 && enabledTools.length === 0) {
updateEnabledTools(tools);
}
}, []);

return (
<section className="relative flex flex-col gap-y-5 px-5">
<ToolsInfoBox />
Expand Down

0 comments on commit ad2eb48

Please sign in to comment.