2023-12-11 21:53:30 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
import sys
|
|
|
|
from typing import List
|
|
|
|
|
2024-04-26 21:45:51 +00:00
|
|
|
from langchain_core.tools import BaseTool, BaseToolkit
|
2023-12-11 21:53:30 +00:00
|
|
|
|
|
|
|
from langchain_community.tools.azure_cognitive_services import (
|
|
|
|
AzureCogsFormRecognizerTool,
|
|
|
|
AzureCogsImageAnalysisTool,
|
|
|
|
AzureCogsSpeech2TextTool,
|
|
|
|
AzureCogsText2SpeechTool,
|
|
|
|
AzureCogsTextAnalyticsHealthTool,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class AzureCognitiveServicesToolkit(BaseToolkit):
|
|
|
|
"""Toolkit for Azure Cognitive Services."""
|
|
|
|
|
|
|
|
def get_tools(self) -> List[BaseTool]:
|
|
|
|
"""Get the tools in the toolkit."""
|
|
|
|
|
|
|
|
tools: List[BaseTool] = [
|
2024-05-13 18:55:07 +00:00
|
|
|
AzureCogsFormRecognizerTool(), # type: ignore[call-arg]
|
|
|
|
AzureCogsSpeech2TextTool(), # type: ignore[call-arg]
|
|
|
|
AzureCogsText2SpeechTool(), # type: ignore[call-arg]
|
|
|
|
AzureCogsTextAnalyticsHealthTool(), # type: ignore[call-arg]
|
2023-12-11 21:53:30 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
# TODO: Remove check once azure-ai-vision supports MacOS.
|
|
|
|
if sys.platform.startswith("linux") or sys.platform.startswith("win"):
|
2024-05-13 18:55:07 +00:00
|
|
|
tools.append(AzureCogsImageAnalysisTool()) # type: ignore[call-arg]
|
2023-12-11 21:53:30 +00:00
|
|
|
return tools
|