fix: type checking issues

This commit is contained in:
Eduardo Chiarotti
2024-08-14 17:30:32 -03:00
parent afc5800d4f
commit 299283648c
3 changed files with 7 additions and 7 deletions

View File

@@ -51,7 +51,7 @@ from crewai.utilities.training_handler import CrewTrainingHandler
agentops = None agentops = None
if os.environ.get("AGENTOPS_API_KEY"): if os.environ.get("AGENTOPS_API_KEY"):
try: try:
import agentops import agentops # type: ignore
except ImportError: except ImportError:
pass pass

View File

@@ -295,7 +295,7 @@ class Telemetry:
pass pass
def individual_test_result_span( def individual_test_result_span(
self, crew: Crew, quality: int, exec_time: int, model_name: str self, crew: Crew, quality: float, exec_time: int, model_name: str
): ):
if self.ready: if self.ready:
try: try:

View File

@@ -1,6 +1,6 @@
import ast import ast
from difflib import SequenceMatcher
import os import os
from difflib import SequenceMatcher
from textwrap import dedent from textwrap import dedent
from typing import Any, List, Union from typing import Any, List, Union
@@ -15,7 +15,7 @@ from crewai.utilities import I18N, Converter, ConverterError, Printer
agentops = None agentops = None
if os.environ.get("AGENTOPS_API_KEY"): if os.environ.get("AGENTOPS_API_KEY"):
try: try:
import agentops import agentops # type: ignore
except ImportError: except ImportError:
pass pass
@@ -71,14 +71,14 @@ class ToolUsage:
self.task = task self.task = task
self.action = action self.action = action
self.function_calling_llm = function_calling_llm self.function_calling_llm = function_calling_llm
# Handling bug (see https://github.com/langchain-ai/langchain/pull/16395): raise an error if tools_names have space for ChatOpenAI # Handling bug (see https://github.com/langchain-ai/langchain/pull/16395): raise an error if tools_names have space for ChatOpenAI
if isinstance(self.function_calling_llm, ChatOpenAI): if isinstance(self.function_calling_llm, ChatOpenAI):
if " " in self.tools_names: if " " in self.tools_names:
raise Exception( raise Exception(
"Tools names should not have spaces for ChatOpenAI models." "Tools names should not have spaces for ChatOpenAI models."
) )
# Set the maximum parsing attempts for bigger models # Set the maximum parsing attempts for bigger models
if (isinstance(self.function_calling_llm, ChatOpenAI)) and ( if (isinstance(self.function_calling_llm, ChatOpenAI)) and (
self.function_calling_llm.openai_api_base is None self.function_calling_llm.openai_api_base is None
@@ -118,7 +118,7 @@ class ToolUsage:
tool: BaseTool, tool: BaseTool,
calling: Union[ToolCalling, InstructorToolCalling], calling: Union[ToolCalling, InstructorToolCalling],
) -> str: # TODO: Fix this return type ) -> str: # TODO: Fix this return type
tool_event = agentops.ToolEvent(name=calling.tool_name) if agentops else None tool_event = agentops.ToolEvent(name=calling.tool_name) if agentops else None # type: ignore
if self._check_tool_repeated_usage(calling=calling): # type: ignore # _check_tool_repeated_usage of "ToolUsage" does not return a value (it only ever returns None) if self._check_tool_repeated_usage(calling=calling): # type: ignore # _check_tool_repeated_usage of "ToolUsage" does not return a value (it only ever returns None)
try: try:
result = self._i18n.errors("task_repeated_usage").format( result = self._i18n.errors("task_repeated_usage").format(