Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
4 changes: 2 additions & 2 deletions openai_function_calling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
__all__: list[str] = [
"Function",
"FunctionDict",
"FunctionInferrer",
"JsonSchemaType",
"Parameter",
"ParameterDict",
"JsonSchemaType",
"FunctionInferrer",
]
4 changes: 1 addition & 3 deletions openai_function_calling/function_inferrer.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ def _infer_from_inspection(function_reference: Callable) -> Function:

if parameter_type == "null":
if isinstance(parameter.annotation, EnumMeta):
enum_values = list(
parameter.annotation._value2member_map_.keys() # noqa: SLF001
)
enum_values = list(parameter.annotation._value2member_map_.keys())
parameter_type = FunctionInferrer._infer_list_item_type(enum_values)
elif dataclasses.is_dataclass(parameter.annotation):
parameter_type = JsonSchemaType.OBJECT.value
Expand Down
59 changes: 30 additions & 29 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ packages = [{ include = "openai_function_calling" }]

[tool.poetry.dependencies]
python = ">=3.9, <4.0"
typing-extensions = "^4.7.1"
typing-extensions = "^4.12.2"
docstring-parser = "^0.16"

[tool.poetry.group.dev.dependencies]
openai = "^1.3.2"
pytest = "^7.4.3"
ruff = "0.3.4"
coverage = "^7.3.2"
pytest = "^8.3.5"
ruff = "0.9.9"
coverage = "^7.6.12"

[build-system]
requires = ["poetry-core"]
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ lint.fixable = [
"UP",
"YTT",
]
lint.ignore = ["D407", "D406", "D203", "ANN101", "D213", "PLR0913", "ANN401"]
lint.ignore = ["D407", "D406", "D203", "D213", "PLR0913", "ANN401"]
exclude = [
".bzr",
".direnv",
Expand Down
12 changes: 6 additions & 6 deletions tests/test_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ def test_to_json_schema_with_type_array_items_returns_expected_dict() -> None:

parameter_dict: ParameterDict = parameter.to_json_schema()

assert (
"items" in parameter_dict
), "Expected parameter dict to have 'items' property."
assert (
"type" in parameter_dict["items"]
), "Expected parameter 'items' dict to have 'type' property."
assert "items" in parameter_dict, (
"Expected parameter dict to have 'items' property."
)
assert "type" in parameter_dict["items"], (
"Expected parameter 'items' dict to have 'type' property."
)
assert isinstance(parameter_dict["items"]["type"], str)
assert parameter_dict["items"]["type"] == JsonSchemaType.STRING

Expand Down
1 change: 1 addition & 0 deletions tests/test_tool_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_from_functions_dicts_function_parameters_has_expected_type() -> None:
[get_current_weather_schema]
)[0]

assert "parameters" in tool_param["function"]
assert isinstance(tool_param["function"]["parameters"], dict)


Expand Down