LangChain Integration
Installation
Section titled “Installation”pip install synapserun langchainfrom synapse.langchain_tool import SynapseCellExecuteTool
tool = SynapseCellExecuteTool(api_key="cell_sk_live_...")
# Use in a LangChain agentfrom langchain.agents import initialize_agentfrom langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4")agent = initialize_agent( tools=[tool], llm=llm, agent="zero-shot-react-description",)
result = agent.run("Calculate the factorial of 20 using Python")Migrating from E2B
Section titled “Migrating from E2B”from langchain_e2b import E2BCodeInterpreterToolfrom synapse.langchain_tool import SynapseCellExecuteTool
tool = E2BCodeInterpreterTool(api_key="...")tool = SynapseCellExecuteTool(api_key="...")