Skip to main content

Knit LangChain SDK

Welcome to the Knit's LangChain SDK, a powerful toolkit designed to integrate AI-powered agents built using LangChain with a wide range of SaaS applications.

As an embedded integration platform, Knit provides a white-labeled solution empowering SaaS companies to effortlessly scale integrations within their own products, enriching customer experiences with dynamic, out-of-the-box functionality.

The Knit LangChain SDK is designed to facilitate seamless integration between LLM agents and SaaS applications by leveraging Knit's platform and its wide range of connectors.

Installation

Kickstart your journey with the Knit LangChain SDK by installing it via pip:

pip install knit-langchain

Quick Start

First, get your Knit API Key by signing up at https://dashboard.getknit.dev/signup

Now, we're ready to start using the SDK. Here's a simple guide to help you start integrating with the Knit LangChain SDK:

import logging
from langchain_openai import ChatOpenAI
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_core.messages import HumanMessage
from langchain_core.prompts import ChatPromptTemplate
from knit_langchain import KnitLangChain, ToolFilter

# Initialize the Knit SDK with your API key
knit = KnitLangChain(api_key="YOUR_KNIT_API_KEY")

# Initialize your Large Language Model (LLM)
model = ChatOpenAI(
    api_key="YOUR_OPENAI_API_KEY",
    model="gpt-4o",  # Choose the appropriate model, e.g., gpt-4o
    temperature=0,   # Set temperature for response variability
)

# Discover available tools from a specific app.
# Use app_id to filter tools for a particular application
tools = knit.find_tools(app_id="charliehr")

# Retrieve specific tools you want to pass to the LLM model.
# Use ToolFilter to select the required tools by their IDs
tool_defs = knit.get_tools(tools=[ToolFilter(app_id="charliehr", tool_ids=[tool.tool_id for tool in tools])])

# Define the conversation prompt template with predefined roles and placeholders
prompt = ChatPromptTemplate.from_messages(
    [
        ("system", "You are a helpful assistant"),  # System message defining the agent role
        ("human", "{input}"),  # Placeholder for human input
        ("placeholder", "{agent_scratchpad}"),  # Placeholder for intermediate steps
    ]
)

# Create the agent capable of using the defined tools and prompt
agent = create_tool_calling_agent(model, tools, prompt)

# Create an executor to run the agent with detailed output
agent_executor = AgentExecutor(agent=agent, tools=tool_defs, verbose=True)

# Configuration settings required for tool execution
config = {"knit_integration_id": "b29fcTlZc2IwSzViSUF1NXI5SmhqOHdydTpjaGFybGllaHI="}

# Invoke the agent to perform a task, supplying necessary inputs and configuration
agent_executor.invoke(
    {"input": "I want to get the list of offices of the company"},
    config={"configurable": config}
)

That's it! It's that easy to get started and add hundreds of SaaS applications to your AI Agent.

Detailed Information

That was a quick introduction of how to get started with Knit's LangChain SDK.

To know more about how to use its advanced features and for more in depth information, please refer to the detailed guide here: Knit LangChain SDK Guide

Support

For support, reach out to kunal@getknit.dev

Metadata

Release files for knit-langchain 0.1.1

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

Source distribution (sdist)

Source distribution for knit-langchain 0.1.1
File Size Uploaded
knit_langchain-0.1.1.tar.gz 9.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for knit-langchain 0.1.1
File Interpreter ABI Platform
knit_langchain-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.5 kB

Release files / knit_langchain-0.1.1.tar.gz

Download URL knit_langchain-0.1.1.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
36e5517612463ad5bd703f479b6723cddcdb18dcd4b96f21658db231b87c1df5
BLAKE2b-256 checksum
How to use checksums
d042171900aa2f40bbadc981f16f4df05a7899e7dd7190d3dd665bf8d7c737bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.9.13 Windows/10

Release files / knit_langchain-0.1.1-py3-none-any.whl

Download URL knit_langchain-0.1.1-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1ee4fda50b46b734f4408332cb76b8948bca379642a2bebebe70f797b113d75
BLAKE2b-256 checksum
How to use checksums
24af7ed0ec1647a3c7fe3cd6f1e5fd30193e8c94874fd27926c5c46fbb530e4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.9.13 Windows/10

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.1

2 release files

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