.ipynb
.pdf
Azure Cognitive Services Toolkit
 Contents 
Create the Toolkit
Use within an Agent
Azure Cognitive Services Toolkit#
This toolkit is used to interact with the Azure Cognitive Services API to achieve some multimodal capabilities.
Currently There are four tools bundled in this toolkit:
AzureCogsImageAnalysisTool: used to extract caption, objects, tags, and text from images. (Note: this tool is not available on Mac OS yet, due to the dependency on azure-ai-vision package, which is only supported on Windows and Linux currently.)
AzureCogsFormRecognizerTool: used to extract text, tables, and key-value pairs from documents.
AzureCogsSpeech2TextTool: used to transcribe speech to text.
AzureCogsText2SpeechTool: used to synthesize text to speech.
First, you need to set up an Azure account and create a Cognitive Services resource. You can follow the instructions here to create a resource.
Then, you need to get the endpoint, key and region of your resource, and set them as environment variables. You can find them in the “Keys and Endpoint” page of your resource.
# !pip install --upgrade azure-ai-formrecognizer > /dev/null
# !pip install --upgrade azure-cognitiveservices-speech > /dev/null
# For Windows/Linux
# !pip install --upgrade azure-ai-vision > /dev/null
import os
os.environ["OPENAI_API_KEY"] = "sk-"
os.environ["AZURE_COGS_KEY"] = ""
os.environ["AZURE_COGS_ENDPOINT"] = ""
os.environ["AZURE_COGS_REGION"] = ""
Create the Toolkit#
from langchain.agents.agent_toolkits import AzureCognitiveServicesToolkit
toolkit = AzureCognitiveServicesToolkit()
[tool.name for tool in toolkit.get_tools()]
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/azure_cognitive_services.html