langchain/libs/partners/azure-dynamic-sessions
wenngong af620db9c7
partners: add lint docstrings for azure-dynamic-sessions/together modules (#23303)
Description: add lint docstrings for azure-dynamic-sessions/together
modules
Issue: #23188 @baskaryan

test: ruff check passed.
<img width="782" alt="image"
src="https://github.com/langchain-ai/langchain/assets/76683249/bf11783d-65b3-4e56-a563-255eae89a3e4">

---------

Co-authored-by: gongwn1 <gongwn1@lenovo.com>
2024-06-24 16:26:54 -04:00
..
langchain_azure_dynamic_sessions partners: add lint docstrings for azure-dynamic-sessions/together modules (#23303) 2024-06-24 16:26:54 -04:00
scripts partners: add lint docstrings for azure-dynamic-sessions/together modules (#23303) 2024-06-24 16:26:54 -04:00
tests
.gitignore
LICENSE
Makefile
poetry.lock partners: add lint docstrings for azure-dynamic-sessions/together modules (#23303) 2024-06-24 16:26:54 -04:00
pyproject.toml partners: add lint docstrings for azure-dynamic-sessions/together modules (#23303) 2024-06-24 16:26:54 -04:00
README.md

langchain-azure-dynamic-sessions

This package contains the LangChain integration for Azure Container Apps dynamic sessions. You can use it to add a secure and scalable code interpreter to your agents.

Installation

pip install -U langchain-azure-dynamic-sessions

Usage

You first need to create an Azure Container Apps session pool and obtain its management endpoint. Then you can use the SessionsPythonREPLTool tool to give your agent the ability to execute Python code.

from langchain_azure_dynamic_sessions import SessionsPythonREPLTool


# get the management endpoint from the session pool in the Azure portal
tool = SessionsPythonREPLTool(pool_management_endpoint=POOL_MANAGEMENT_ENDPOINT)

prompt = hub.pull("hwchase17/react")
tools=[tool]
react_agent = create_react_agent(
    llm=llm,
    tools=tools,
    prompt=prompt,
)

react_agent_executor = AgentExecutor(agent=react_agent, tools=tools, verbose=True, handle_parsing_errors=True)

react_agent_executor.invoke({"input": "What is the current time in Vancouver, Canada?"})

By default, the tool uses DefaultAzureCredential to authenticate with Azure. If you're using a user-assigned managed identity, you must set the AZURE_CLIENT_ID environment variable to the ID of the managed identity.