mirror of
https://github.com/stripe/ai.git
synced 2026-09-14 18:39:59 +08:00
31 lines
664 B
Python
31 lines
664 B
Python
"""
|
|
This tool allows agents to interact with the Stripe API.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Optional, Type
|
|
from pydantic import BaseModel
|
|
|
|
from langchain.tools import BaseTool
|
|
|
|
from ..api import StripeAPI
|
|
|
|
|
|
class StripeTool(BaseTool):
|
|
"""Tool for interacting with the Stripe API."""
|
|
|
|
stripe_api: StripeAPI
|
|
method: str
|
|
name: str = ""
|
|
description: str = ""
|
|
args_schema: Optional[Type[BaseModel]] = None
|
|
|
|
def _run(
|
|
self,
|
|
*args: Any,
|
|
**kwargs: Any,
|
|
) -> str:
|
|
"""Use the Stripe API to run an operation."""
|
|
return self.stripe_api.run(self.method, *args, **kwargs)
|