| 12345678910111213141516171819202122 |
- from langchain.agents.tools import BaseTool
- from pydantic import BaseModel, Field
- from typing import Type
- class DelSubstrToolInput(BaseModel):
- text: str = Field(description="原字符串")
- content: str = Field(description="去除的内容")
- class DelSubstrTool(BaseTool):
- name: str = "remove_str"
- description: str = (
- "去除字符串的指定的内容"
- )
- args_schema: Type[BaseModel] = DelSubstrToolInput
- def _run(self, text: str, content: str):
- return text.replace(r"{content}","")
|