langchain/libs/partners/azure-dynamic-sessions
Erick Friis c77d2f2b06
multiple: core 0.2 nonbreaking dep, check_diff community->langchain dep (#21646)
0.2 is not a breaking release for core (but it is for langchain and
community)

To keep the core+langchain+community packages in sync at 0.2, we will
relax deps throughout the ecosystem to tolerate `langchain-core` 0.2
2024-05-13 19:50:36 -07:00
..
docs azure-dynamic-sessions: add Python REPL tool (#21264) 2024-05-09 21:39:04 +00:00
langchain_azure_dynamic_sessions azure-dynamic-sessions: add Python REPL tool (#21264) 2024-05-09 21:39:04 +00:00
scripts azure-dynamic-sessions: add Python REPL tool (#21264) 2024-05-09 21:39:04 +00:00
tests azure-dynamic-sessions: add Python REPL tool (#21264) 2024-05-09 21:39:04 +00:00
.gitignore azure-dynamic-sessions: add Python REPL tool (#21264) 2024-05-09 21:39:04 +00:00
LICENSE azure-dynamic-sessions: add Python REPL tool (#21264) 2024-05-09 21:39:04 +00:00
Makefile azure-dynamic-sessions: add Python REPL tool (#21264) 2024-05-09 21:39:04 +00:00
poetry.lock multiple: core 0.2 nonbreaking dep, check_diff community->langchain dep (#21646) 2024-05-13 19:50:36 -07:00
pyproject.toml multiple: core 0.2 nonbreaking dep, check_diff community->langchain dep (#21646) 2024-05-13 19:50:36 -07:00
README.md azure-dynamic-sessions: add Python REPL tool (#21264) 2024-05-09 21:39:04 +00:00

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.