Skip to content

LangChain Integration Preview

Learn how to build your AI agent with the EVO Payment Agent Toolkit.

Explore this SDK to integrate EVO Payment into agentic workflows. Because agent behavior is non-deterministic, use the SDK in a sandbox and run evaluations to assess your application’s performance.

1. Install Dependencies

bash
pip install evocloud-agent-toolkit langchain langchain-openai

2. Configure Environment Variables

bash
cp env.example .env
# Edit the .env file and fill in your actual configuration
EVOCLOUD_BASE_URL=https://online-uat.everonet.com
EVOCLOUD_SIGN_KEY=your_sign_key
EVOCLOUD_SID=your_sid
EVOCLOUD_WEBHOOK_URL=https://your-domain.com/webhook  # optional
OPENAI_API_KEY=your_openai_api_key

3. Integrate with LangChain Agent

python
from evocloud_agent_toolkit.langchain import EvoCloudToolkit
from langchain.agents import create_openai_functions_agent, AgentExecutor
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_openai import ChatOpenAI

# Initialize toolkit and model
toolkit = EvoCloudToolkit()
tools = toolkit.get_tools()
llm = ChatOpenAI(model="gpt-4", temperature=0)

# Create prompt template
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a professional payment assistant who can help users handle LinkPay-related business."),
    ("user", "{input}"),
    MessagesPlaceholder(variable_name="agent_scratchpad")
])

# Create and run the Agent
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools)

# Interact via natural language
response = agent_executor.invoke({
    "input": "Please create an order, order number ORDER_123, amount $99.99, product is Premium Service."
})
print(response["output"])