A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://python.langchain.com/docs/integrations/tools/payman-tool/ below:

PaymanAI | 🦜️🔗 LangChain

PaymanAI provides functionality to send and receive payments (fiat and crypto) on behalf of an AI Agent. To get started:

This notebook gives a quick overview of integrating PaymanAI into LangChain as a tool. For complete reference, see the API documentation.

The PaymanAI integration is part of the langchain-community (or your custom) package. It allows you to:

These can be wrapped as LangChain Tools for an LLM-based agent to call them automatically.

If you're simply calling the PaymanAI SDK, you can do it directly or via the Tool interface in LangChain.

Your PAYMAN_API_SECRET should be the secret key from app.paymanai.com. The PAYMAN_ENVIRONMENT can be sandbox or production depending on your usage.

Here is an example of instantiating a PaymanAI tool. If you have multiple Payman methods, you can create multiple tools.

from langchain_community.tools.langchain_payman_tool.tool import PaymanAI


tool = PaymanAI(
name="send_payment",
description="Send a payment to a specified payee.",
)

You can call tool.invoke(...) and pass a dictionary matching the tool's expected fields. For example:

response = tool.invoke({
"amount_decimal": 10.00,
"payment_destination_id": "abc123",
"customer_id": "cust_001",
"memo": "Payment for invoice #XYZ"
})

When used inside an AI workflow, the LLM might produce a ToolCall dict. You can simulate it as follows:

model_generated_tool_call = {
"args": {
"amount_decimal": 10.00,
"payment_destination_id": "abc123"
},
"id": "1",
"name": tool.name,
"type": "tool_call",
}
tool.invoke(model_generated_tool_call)

You can bind a PaymanAI tool to a LangChain agent or chain that supports tool-calling.

from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnableConfig, chain
from langchain.chat_models import init_chat_model


payman_tool = PaymanAITool(name="send_payment")


prompt = ChatPromptTemplate([
("system", "You are a helpful AI that can send payments if asked."),
("human", "{user_input}"),
("placeholder", "{messages}"),
])

llm = init_chat_model(model="gpt-4", model_provider="openai")
llm_with_tools = llm.bind_tools([payman_tool], tool_choice=payman_tool.name)

llm_chain = prompt | llm_with_tools

@chain
def tool_chain(user_input: str, config: RunnableConfig):
input_ = {"user_input": user_input}
ai_msg = llm_chain.invoke(input_, config=config)
tool_msgs = payman_tool.batch(ai_msg.tool_calls, config=config)
return llm_chain.invoke({**input_, "messages": [ai_msg, *tool_msgs]}, config=config)


response = tool_chain.invoke("Send $10 to payee123.")
print(response)```



You can find full API documentation for PaymanAI at:

- [Python reference](https://python.langchain.com/v0.2/api_reference/community/tools/langchain_community.tools.langchain_payman_tool.tool.PaymanAI.html)
- (Any other relevant references or doc links)



- Tool [conceptual guide](/docs/concepts/tools)
- Tool [how-to guides](/docs/how_to/

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4