Skip to main content

The Knit LangChain SDK enables seamless integration between LangChain-powered agents and SaaS applications. This toolkit allows developers to easily connect AI agents with hundreds of SaaS platforms using Knit's integration platform. With minimal code, expand your AI assistant's capabilities by incorporating external data and functionalities from popular business applications.

Project description

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

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

knit_langchain-0.1.1.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

knit_langchain-0.1.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file knit_langchain-0.1.1.tar.gz.

File metadata

  • Download URL: knit_langchain-0.1.1.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.9.13 Windows/10

File hashes

Hashes for knit_langchain-0.1.1.tar.gz
Algorithm Hash digest
SHA256 36e5517612463ad5bd703f479b6723cddcdb18dcd4b96f21658db231b87c1df5
MD5 784c13a7ced272f200758242c843d17f
BLAKE2b-256 d042171900aa2f40bbadc981f16f4df05a7899e7dd7190d3dd665bf8d7c737bc

See more details on using hashes here.

File details

Details for the file knit_langchain-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: knit_langchain-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.9.13 Windows/10

File hashes

Hashes for knit_langchain-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1ee4fda50b46b734f4408332cb76b8948bca379642a2bebebe70f797b113d75
MD5 9831b402a23df506cb6bc442073e75e9
BLAKE2b-256 24af7ed0ec1647a3c7fe3cd6f1e5fd30193e8c94874fd27926c5c46fbb530e4c

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