Compare commits

...

3 Commits

Author SHA1 Message Date
theCyberTech
df00876f7a Linting:
- Improved code formatting for better clarity.
- These changes aim to improve maintainability and clarity of the code.
2025-01-05 11:35:58 +08:00
theCyberTech
47121316d4 Merge branch 'main' into pydantic_fixup 2025-01-05 11:27:18 +08:00
theCyberTech
79e428aff8 refactor: improve code readability and update model schema access in tool_usage.py
- Reformatted the OPENAI_BIGGER_MODELS list for better readability.
- Updated the method for accessing the model schema in ToolUsage class to use model_json_schema() instead of schema().
- Enhanced conditional formatting for clarity in the add_image tool check.

These changes aim to enhance maintainability and clarity of the code.
2025-01-05 11:04:47 +08:00

View File

@@ -19,7 +19,15 @@ try:
import agentops # type: ignore
except ImportError:
agentops = None
OPENAI_BIGGER_MODELS = ["gpt-4", "gpt-4o", "o1-preview", "o1-mini", "o1", "o3", "o3-mini"]
OPENAI_BIGGER_MODELS = [
"gpt-4",
"gpt-4o",
"o1-preview",
"o1-mini",
"o1",
"o3",
"o3-mini",
]
class ToolUsageErrorException(Exception):
@@ -104,7 +112,10 @@ class ToolUsage:
self._printer.print(content=f"\n\n{error}\n", color="red")
return error
if isinstance(tool, CrewStructuredTool) and tool.name == self._i18n.tools("add_image")["name"]: # type: ignore
if (
isinstance(tool, CrewStructuredTool)
and tool.name == self._i18n.tools("add_image")["name"]
): # type: ignore
try:
result = self._use(tool_string=tool_string, tool=tool, calling=calling)
return result
@@ -169,7 +180,9 @@ class ToolUsage:
if calling.arguments:
try:
acceptable_args = tool.args_schema.model_json_schema()["properties"].keys() # type: ignore
acceptable_args = tool.args_schema.model_json_schema()[
"properties"
].keys() # type: ignore # Item "None" of "type[BaseModel] | None" has no attribute "schema"
arguments = {
k: v
for k, v in calling.arguments.items()