mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 15:48:29 +00:00
fix linter and types
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
from crewai.tools.base_tool import BaseTool
|
from crewai.tools.base_tool import BaseTool
|
||||||
from crewai.utilities import I18N
|
from crewai.utilities import I18N
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
i18n = I18N()
|
i18n = I18N()
|
||||||
|
|
||||||
class AddImageToolSchema(BaseModel):
|
class AddImageToolSchema(BaseModel):
|
||||||
image_url: str = Field(..., description="The URL or path of the image to add")
|
image_url: str = Field(..., description="The URL or path of the image to add")
|
||||||
action: str = Field(
|
action: Optional[str] = Field(
|
||||||
default=None,
|
default=None,
|
||||||
description="Optional context or question about the image"
|
description="Optional context or question about the image"
|
||||||
)
|
)
|
||||||
@@ -15,17 +16,17 @@ class AddImageToolSchema(BaseModel):
|
|||||||
class AddImageTool(BaseTool):
|
class AddImageTool(BaseTool):
|
||||||
"""Tool for adding images to the content"""
|
"""Tool for adding images to the content"""
|
||||||
|
|
||||||
name: str = Field(default_factory=lambda: i18n.tools("add_image")["name"])
|
name: str = Field(default_factory=lambda: i18n.tools("add_image").get("name"))
|
||||||
description: str = Field(default_factory=lambda: i18n.tools("add_image")["description"])
|
description: str = Field(default_factory=lambda: i18n.tools("add_image").get("description"))
|
||||||
args_schema: type[BaseModel] = AddImageToolSchema
|
args_schema: type[BaseModel] = AddImageToolSchema
|
||||||
|
|
||||||
def _run(
|
def _run(
|
||||||
self,
|
self,
|
||||||
image_url: str,
|
image_url: str,
|
||||||
action: str = None,
|
action: Optional[str] = None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
action = action or i18n.tools("add_image")["default_action"]
|
action = action or i18n.tools("add_image").get("default_action")
|
||||||
content = [
|
content = [
|
||||||
{"type": "text", "text": action},
|
{"type": "text", "text": action},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ from typing import List, Union
|
|||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from crewai.knowledge.source.crew_docling_source import CrewDoclingSource
|
from crewai.knowledge.source.crew_docling_source import CrewDoclingSource
|
||||||
from crewai.knowledge.source.csv_knowledge_source import CSVKnowledgeSource
|
from crewai.knowledge.source.csv_knowledge_source import CSVKnowledgeSource
|
||||||
from crewai.knowledge.source.excel_knowledge_source import ExcelKnowledgeSource
|
from crewai.knowledge.source.excel_knowledge_source import ExcelKnowledgeSource
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from crewai.task import Task
|
from crewai.task import Task
|
||||||
from crewai.tasks.task_output import TaskOutput
|
from crewai.tasks.task_output import TaskOutput
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user