Skip to main content

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.

Metadata

Release files for alation-ai-agent-langchain 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alation-ai-agent-langchain 0.12.0
File Size Uploaded
alation_ai_agent_langchain-0.12.0.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for alation-ai-agent-langchain 0.12.0
File Interpreter ABI Platform
alation_ai_agent_langchain-0.12.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.9 kB

Release files / alation_ai_agent_langchain-0.12.0.tar.gz

Download URL alation_ai_agent_langchain-0.12.0.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
85f11c0c2144a3eda23a777d723e287ae706e465c00f398aff8a16fb559471cd
BLAKE2b-256 checksum
How to use checksums
7fdd60e083fe8c35bc3ae1da842969efd88eb438f2010e75b7804485d6e2bc69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.0

Release files / alation_ai_agent_langchain-0.12.0-py3-none-any.whl

Download URL alation_ai_agent_langchain-0.12.0-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7957c34173987e67ec3a2f599b62496c8ea991fe477c7265395e4c7b8be2a0f6
BLAKE2b-256 checksum
How to use checksums
32f5b8beaed9e31ff4025fef5ab802b304130ea92b6fd6dfc75f408a6f6b0633
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page