Skip to content

Commit 3e3ba60

Browse files
committed
Update
1 parent 6af70fb commit 3e3ba60

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

libs/agno/agno/api/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def create_agent(agent: AgentCreate) -> None:
6161
ApiRoutes.AGENT_CREATE,
6262
json=agent.model_dump(exclude_none=True),
6363
)
64-
64+
6565
log_debug(f"Created Agent on Platform. ID: {agent.agent_id}")
6666
except Exception as e:
6767
log_debug(f"Could not create Agent: {e}")

libs/agno/agno/models/openai/chat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def get_request_kwargs(
185185
# Add tools
186186
if tools is not None and len(tools) > 0:
187187
request_params["tools"] = tools
188-
188+
189189
if tool_choice is not None:
190190
request_params["tool_choice"] = tool_choice
191191

libs/agno/agno/utils/json_schema.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def get_json_schema_for_arg(type_hint: Any) -> Optional[Dict[str, Any]]:
143143
elif issubclass(type_hint, BaseModel):
144144
# Get the schema and inline it
145145
schema = type_hint.model_json_schema()
146-
return inline_pydantic_schema(schema)
146+
return inline_pydantic_schema(schema) # type: ignore
147147
elif hasattr(type_hint, "__dataclass_fields__"):
148148
# Convert dataclass to JSON schema
149149
properties = {}
@@ -152,21 +152,23 @@ def get_json_schema_for_arg(type_hint: Any) -> Optional[Dict[str, Any]]:
152152
for field_name, field in type_hint.__dataclass_fields__.items():
153153
field_type = field.type
154154
field_schema = get_json_schema_for_arg(field_type)
155-
156-
if "anyOf" in field_schema and any(schema["type"] == "null" for schema in field_schema["anyOf"]):
157-
field_schema["type"] = next(schema["type"] for schema in field_schema["anyOf"] if schema["type"] != "null")
155+
156+
if (
157+
field_schema
158+
and "anyOf" in field_schema
159+
and any(schema["type"] == "null" for schema in field_schema["anyOf"])
160+
):
161+
field_schema["type"] = next(
162+
schema["type"] for schema in field_schema["anyOf"] if schema["type"] != "null"
163+
)
158164
field_schema.pop("anyOf")
159165
else:
160166
required.append(field_name)
161167

162168
if field_schema:
163169
properties[field_name] = field_schema
164170

165-
arg_json_schema = {
166-
"type": "object",
167-
"properties": properties,
168-
"additionalProperties": False
169-
}
171+
arg_json_schema = {"type": "object", "properties": properties, "additionalProperties": False}
170172

171173
if required:
172174
arg_json_schema["required"] = required

libs/agno/tests/unit/utils/test_json_schema.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313

1414
# Test models and dataclasses
15-
class TestPydanticModel(BaseModel):
15+
class MockPydanticModel(BaseModel):
1616
name: str
1717
age: int
1818
is_active: bool = True
1919

2020

2121
@dataclass
22-
class TestDataclass:
22+
class MockDataclass:
2323
name: str
2424
age: int
2525
is_active: bool = True
@@ -115,7 +115,7 @@ def test_get_json_schema_for_arg_collections():
115115
def test_get_json_schema_for_arg_union():
116116
# Test Optional type (Union with None)
117117
optional_schema = get_json_schema_for_arg(Optional[str])
118-
assert optional_schema == {'anyOf': [{'type': 'string'}, {'type': 'null'}]}
118+
assert optional_schema == {"anyOf": [{"type": "string"}, {"type": "null"}]}
119119

120120
# Test Union type
121121
union_schema = get_json_schema_for_arg(Union[str, int])
@@ -146,7 +146,7 @@ def test_get_json_schema_basic():
146146

147147

148148
def test_get_json_schema_with_pydantic_model():
149-
type_hints = {"user": TestPydanticModel}
149+
type_hints = {"user": MockPydanticModel}
150150
schema = get_json_schema(type_hints)
151151
assert schema["type"] == "object"
152152
assert "properties" in schema
@@ -161,7 +161,7 @@ def test_get_json_schema_with_pydantic_model():
161161

162162

163163
def test_get_json_schema_with_dataclass():
164-
type_hints = {"user": TestDataclass}
164+
type_hints = {"user": MockDataclass}
165165
schema = get_json_schema(type_hints)
166166
assert schema["type"] == "object"
167167
assert "properties" in schema
@@ -226,7 +226,7 @@ def test_get_json_schema_with_nested_pydantic_models():
226226

227227
# Verify optional phone field
228228
assert "phone" in contact_info["properties"]
229-
assert contact_info["properties"]["phone"]["default"] == None
229+
assert contact_info["required"] == ["email", "address"]
230230

231231
# Verify preferences dictionary
232232
assert "preferences" in user_profile["properties"]

0 commit comments

Comments
 (0)