Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alation_ai_agent_langchain-0.12.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alation_ai_agent_langchain-0.12.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file alation_ai_agent_langchain-0.12.0.tar.gz.

File metadata

File hashes

Hashes for alation_ai_agent_langchain-0.12.0.tar.gz
Algorithm Hash digest
SHA256 85f11c0c2144a3eda23a777d723e287ae706e465c00f398aff8a16fb559471cd
MD5 1b7b6a2dcb379ded0bf95100d16a7686
BLAKE2b-256 7fdd60e083fe8c35bc3ae1da842969efd88eb438f2010e75b7804485d6e2bc69

See more details on using hashes here.

File details

Details for the file alation_ai_agent_langchain-0.12.0-py3-none-any.whl.

File metadata

File hashes

Hashes for alation_ai_agent_langchain-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7957c34173987e67ec3a2f599b62496c8ea991fe477c7265395e4c7b8be2a0f6
MD5 565ccd55434615cb653f6dc9dabbfcd0
BLAKE2b-256 32f5b8beaed9e31ff4025fef5ab802b304130ea92b6fd6dfc75f408a6f6b0633

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page