mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-19 00:58:32 +00:00
Add SceneXplain Tool (#3752)
This commit is contained in:
@@ -26,6 +26,7 @@ from langchain.tools.playwright import (
|
||||
NavigateTool,
|
||||
)
|
||||
from langchain.tools.plugin import AIPluginTool
|
||||
from langchain.tools.scenexplain.tool import SceneXplainTool
|
||||
from langchain.tools.shell.tool import ShellTool
|
||||
|
||||
__all__ = [
|
||||
@@ -59,4 +60,6 @@ __all__ = [
|
||||
"ReadFileTool",
|
||||
"ShellTool",
|
||||
"WriteFileTool",
|
||||
"BaseTool",
|
||||
"SceneXplainTool",
|
||||
]
|
||||
|
1
langchain/tools/scenexplain/__init__.py
Normal file
1
langchain/tools/scenexplain/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""SceneXplain API toolkit."""
|
26
langchain/tools/scenexplain/tool.py
Normal file
26
langchain/tools/scenexplain/tool.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Tool for the SceneXplain API."""
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from langchain.tools.base import BaseTool
|
||||
from langchain.utilities.scenexplain import SceneXplainAPIWrapper
|
||||
|
||||
|
||||
class SceneXplainTool(BaseTool):
|
||||
"""Tool that adds the capability to explain images."""
|
||||
|
||||
name = "Image Explainer"
|
||||
description = (
|
||||
"An Image Captioning Tool: Use this tool to generate a detailed caption "
|
||||
"for an image. The input can be an image file of any format, and "
|
||||
"the output will be a text description that covers every detail of the image."
|
||||
)
|
||||
api_wrapper: SceneXplainAPIWrapper = Field(default_factory=SceneXplainAPIWrapper)
|
||||
|
||||
def _run(self, query: str) -> str:
|
||||
"""Use the tool."""
|
||||
return self.api_wrapper.run(query)
|
||||
|
||||
async def _arun(self, query: str) -> str:
|
||||
"""Use the tool asynchronously."""
|
||||
raise NotImplementedError("SceneXplainTool does not support async")
|
Reference in New Issue
Block a user