mirror of
https://github.com/kennethreitz/instructor.git
synced 2026-06-05 22:50:18 +00:00
clean up
This commit is contained in:
@@ -27,16 +27,6 @@ from typing import Any, Callable
|
||||
from pydantic import BaseModel, create_model, validate_arguments
|
||||
|
||||
|
||||
def _remove_a_key(d, remove_key) -> None:
|
||||
"""Remove a key from a dictionary recursively"""
|
||||
if isinstance(d, dict):
|
||||
for key in list(d.keys()):
|
||||
if key == remove_key and "type" in d.keys():
|
||||
del d[key]
|
||||
else:
|
||||
_remove_a_key(d[key], remove_key)
|
||||
|
||||
|
||||
class openai_function:
|
||||
"""
|
||||
Decorator to convert a function into an OpenAI function.
|
||||
@@ -82,8 +72,6 @@ class openai_function:
|
||||
parameters["required"] = sorted(
|
||||
k for k, v in parameters["properties"].items() if not "default" in v
|
||||
)
|
||||
_remove_a_key(parameters, "additionalProperties")
|
||||
_remove_a_key(parameters, "title")
|
||||
self.openai_schema = {
|
||||
"name": self.func.__name__,
|
||||
"description": self.docstring.short_description,
|
||||
|
||||
Reference in New Issue
Block a user