Skip to content

Framework Integrations

Use your favorite LLM framework with Zynd. Each framework has a dedicated setter method.

LangChain

Use LangChain agents with tool calling and ReAct loops.

python
from zyndai_agent.agent import ZyndAIAgent, AgentConfig
from langchain_openai import ChatOpenAI
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder

llm = ChatOpenAI(model="gpt-4")
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant."),
    MessagesPlaceholder(variable_name="chat_history"),
    ("human", "{input}"),
    MessagesPlaceholder(variable_name="agent_scratchpad"),
])
agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools)

config = AgentConfig(name="MyAgent", webhook_port=5000)
zynd_agent = ZyndAIAgent(agent_config=config)
zynd_agent.set_langchain_agent(executor)

LangGraph

Use LangGraph for complex multi-step workflows and state machines.

python
from zyndai_agent.agent import ZyndAIAgent, AgentConfig
from langgraph.graph import StateGraph, START, END
from typing_extensions import TypedDict

class State(TypedDict):
    messages: list
    result: str

graph = StateGraph(State)
graph.add_node("agent", agent_fn)
graph.add_edge(START, "agent")
graph.add_edge("agent", END)
compiled = graph.compile()

config = AgentConfig(name="MyAgent", webhook_port=5000)
zynd_agent = ZyndAIAgent(agent_config=config)
zynd_agent.set_langgraph_agent(compiled)

CrewAI

Use CrewAI for multi-agent crews with specialized roles.

python
from zyndai_agent.agent import ZyndAIAgent, AgentConfig
from crewai import Agent, Task, Crew

researcher = Agent(
    role="Researcher",
    goal="Research topics",
    backstory="Expert researcher",
    llm=llm,
)
task = Task(description="Research AI", agent=researcher)
crew = Crew(agents=[researcher], tasks=[task])

config = AgentConfig(name="MyAgent", webhook_port=5000)
zynd_agent = ZyndAIAgent(agent_config=config)
zynd_agent.set_crewai_agent(crew)

PydanticAI

Use PydanticAI for type-safe agents with structured outputs.

python
from zyndai_agent.agent import ZyndAIAgent, AgentConfig
from pydantic_ai import Agent as PydanticAgent
from pydantic import BaseModel

class Response(BaseModel):
    answer: str
    confidence: float

pydantic_agent = PydanticAgent(
    "gpt-4",
    result_type=Response,
    system_prompt="Answer questions accurately."
)

config = AgentConfig(name="MyAgent", webhook_port=5000)
zynd_agent = ZyndAIAgent(agent_config=config)
zynd_agent.set_pydantic_ai_agent(pydantic_agent)

Custom Functions

Use any function or callable for maximum flexibility.

python
from zyndai_agent.agent import ZyndAIAgent, AgentConfig

async def my_agent_fn(input_text: str) -> str:
    # Your custom logic here
    return f"Response to: {input_text}"

config = AgentConfig(name="MyAgent", webhook_port=5000)
zynd_agent = ZyndAIAgent(agent_config=config)
zynd_agent.set_custom_agent(my_agent_fn)

Choosing a framework

FrameworkBest ForComplexity
LangChainTool calling and ReAct loopsMedium
LangGraphWorkflows with state and memoryHigh
CrewAIMulti-agent teams with rolesMedium
PydanticAIType-safe structured outputsLow
CustomComplete controlVariable

Start with LangChain or PydanticAI if you're new to agents. Use LangGraph for complex workflows. Choose CrewAI for multi-agent teams.

Switching frameworks

You can only set one framework per agent. To switch frameworks, create a new agent or reinitialize:

python
zynd_agent.set_langchain_agent(executor)  # ✓ works
zynd_agent.set_pydantic_ai_agent(agent)   # ✗ raises error

Next steps

Released under the MIT License.