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:
KyrianC
2024-07-25 21:19:14 +02:00
committed by GitHub
parent 871bf5a841
commit 0fdbaf4a8d
10 changed files with 55 additions and 14 deletions

View File

@@ -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, HttpUrl
from langchain_community.tools.edenai.edenai_base_tool import EdenaiTool
logger = logging.getLogger(__name__)
class InvoiceParsingInput(BaseModel):
query: HttpUrl = Field(description="url of the document to parse")
class EdenAiParsingInvoiceTool(EdenaiTool):
"""Tool that queries the Eden AI Invoice parsing API.
@@ -23,7 +28,6 @@ class EdenAiParsingInvoiceTool(EdenaiTool):
"""
name: str = "edenai_invoice_parsing"
description: str = (
"A wrapper around edenai Services invoice parsing. "
"""Useful for when you have to extract information from
@@ -33,6 +37,7 @@ class EdenAiParsingInvoiceTool(EdenaiTool):
in a structured format to automate the invoice processing """
"Input should be the string url of the document to parse."
)
args_schema: Type[BaseModel] = InvoiceParsingInput
language: Optional[str] = None
"""