Alation Agent SDK for Langchain
Project description
Langchain Integration
This package integrates the Alation AI Agent SDK with the Langchain framework, allowing Langchain agents to leverage metadata from the Alation Data Catalog.
Overview
The Langchain integration enables:
- Using Alation's context tool within Langchain agent workflows
- Accessing Alation metadata through Langchain's structured tools interface
- Building sophisticated AI agents that can reason about your data catalog
Prerequisites
- Python 3.10 or higher
- Access to an Alation Data Catalog instance
- A valid refresh token or client_id and secret. For more details, refer to the Authentication Guide.
- If you cannot obtain service account credentials (admin only), see the User Account Authentication Guide for instructions.
Installation
pip install alation-ai-agent-langchain
Quick Start
import os
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_openai_functions_agent
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
from alation_ai_agent_sdk import AlationAIAgentSDK, ServiceAccountAuthParams
from alation_ai_agent_langchain import get_langchain_tools
# Initialize Alation SDK using service account authentication (recommended)
sdk = AlationAIAgentSDK(
base_url=os.getenv("ALATION_BASE_URL"),
auth_method="service_account",
auth_params=ServiceAccountAuthParams(
client_id=os.getenv("ALATION_CLIENT_ID"),
client_secret=os.getenv("ALATION_CLIENT_SECRET")
)
)
# Get Langchain tools
tools = get_langchain_tools(sdk)
# Define agent prompt
prompt = ChatPromptTemplate.from_messages([
("system", "You are a helpful assistant using Alation's metadata catalog."),
("user", "{input}"),
MessagesPlaceholder(variable_name="agent_scratchpad"),
])
# Initialize LLM and create agent
llm = ChatOpenAI(model="gpt-4o", temperature=0)
agent = create_openai_functions_agent(llm=llm, tools=tools, prompt=prompt)
# Create agent executor
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# Run the agent
response = executor.invoke({
"input": "What tables contain customer data?"}
)
print(response)
Using Signatures with Langchain
You can pass Alation signatures through the Langchain agent:
# Define a signature to customize the response
tables_only_signature = {
"table": {
"fields_required": ["name", "title", "description", "url"]
}
}
# Pass the signature with the input
response = executor.invoke({
"input": "What tables contain sales data?",
"signature": tables_only_signature,
})
print(response)
See the examples directory for a complete example of a return eligibility agent built with Langchain and Alation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alation_ai_agent_langchain-0.12.0.tar.gz.
File metadata
- Download URL: alation_ai_agent_langchain-0.12.0.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85f11c0c2144a3eda23a777d723e287ae706e465c00f398aff8a16fb559471cd
|
|
| MD5 |
1b7b6a2dcb379ded0bf95100d16a7686
|
|
| BLAKE2b-256 |
7fdd60e083fe8c35bc3ae1da842969efd88eb438f2010e75b7804485d6e2bc69
|
File details
Details for the file alation_ai_agent_langchain-0.12.0-py3-none-any.whl.
File metadata
- Download URL: alation_ai_agent_langchain-0.12.0-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7957c34173987e67ec3a2f599b62496c8ea991fe477c7265395e4c7b8be2a0f6
|
|
| MD5 |
565ccd55434615cb653f6dc9dabbfcd0
|
|
| BLAKE2b-256 |
32f5b8beaed9e31ff4025fef5ab802b304130ea92b6fd6dfc75f408a6f6b0633
|