mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-09 06:53:59 +00:00
community: fix ChatEdenAI + EdenAI Tools (#23715)
Fixes for Eden AI Custom tools and ChatEdenAI: - add missing import in __init__ of chat_models - add `args_schema` to custom tools. otherwise '__arg1' would sometimes be passed to the `run` method - fix IndexError when no human msg is added in ChatEdenAI
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
from typing import Optional, Type
|
||||
|
||||
from langchain_core.callbacks import CallbackManagerForToolRun
|
||||
from langchain_core.pydantic_v1 import BaseModel, Field
|
||||
|
||||
from langchain_community.tools.edenai.edenai_base_tool import EdenaiTool
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TextModerationInput(BaseModel):
|
||||
query: str = Field(description="Text to moderate")
|
||||
|
||||
|
||||
class EdenAiTextModerationTool(EdenaiTool):
|
||||
"""Tool that queries the Eden AI Explicit text detection.
|
||||
|
||||
@@ -23,7 +28,6 @@ class EdenAiTextModerationTool(EdenaiTool):
|
||||
"""
|
||||
|
||||
name: str = "edenai_explicit_content_detection_text"
|
||||
|
||||
description: str = (
|
||||
"A wrapper around edenai Services explicit content detection for text. "
|
||||
"""Useful for when you have to scan text for offensive,
|
||||
@@ -44,6 +48,7 @@ class EdenAiTextModerationTool(EdenaiTool):
|
||||
"""
|
||||
"Input should be a string."
|
||||
)
|
||||
args_schema: Type[BaseModel] = TextModerationInput
|
||||
|
||||
language: str
|
||||
|
||||
|
Reference in New Issue
Block a user