!
Legal Disclaimer
PipeAgent is a data distribution gateway. We do not own, verify, or endorse the data provided by third-party creators. Use at your own discretion.
Docs/consumer / integration langchain
LangChain Integration Guide
LangChain is one of the most popular frameworks for building LLM applications. This guide shows you how to turn any pipeAgent feed into a tool that your LangChain Agent can use.
1. Prerequisites
pip install langchain langchain-openai requests2. Basic Implementation
The most efficient way to use PipeAgent in LangChain is via the @tool decorator.
python
import requests
from langchain.tools import tool
from langchain_openai import ChatOpenAI
from langchain.agents import create_openai_functions_agent, AgentExecutor
from langchain import hub
# Define the Tool
@tool
def product_search_tool(jsonpath: str = "$.data"):
"""
Fetches real-time e-commerce data from PipeAgent.
Use this tool when users ask about product prices, availability, or ratings.
"""
# Replace with your actual Feed ID
FEED_ID = "your-feed-id-here"
API_KEY = "your-read-api-key-here"
url = f"https://api.pipeagent.dev/api/v1/feed/{FEED_ID}"
headers = {"Authorization": f"Bearer {API_KEY}"}
params = {"jsonpath": jsonpath}
response = requests.get(url, headers=headers, params=params)
return response.json()
# Setup the Agent
llm = ChatOpenAI(model="gpt-4o", temperature=0)
tools = [product_search_tool]
prompt = hub.pull("hwchase17/openai-functions-agent")
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# Run
agent_executor.invoke({"input": "What are the top 3 best selling mechanical keyboards right now?"})3. Advanced: Using JSONPath for Token Efficiency
One of the biggest challenges with Agents is context window limits. PipeAgent's built-in JSONPath support allows you to filter data *before* it reaches the LLM.
In your Tool definition, you can encourage the LLM to use specific paths:
python
@tool
def streamlined_search(query: str):
"""
Search for items. The LLM will automatically construct a JSONPath
to fetch only the fields it needs (e.g. name and price).
"""
# PipeAgent logic...
pass4. Why Use PipeAgent with LangChain?
BeautifulSoup or Selenium logic inside your LangChain chains.Version 1.0.4 - Premium Infrastructure