Better default descriptions (#62)

* better desc

* add better dsc test
This commit is contained in:
Jason Liu
2023-07-17 17:13:46 +08:00
committed by GitHub
parent df21691317
commit 5d7b1a4ee0
3 changed files with 18 additions and 2 deletions
+6
View File
@@ -133,6 +133,12 @@ class OpenAISchema(BaseModel):
}
parameters["required"] = sorted(parameters["properties"])
_remove_a_key(parameters, "title")
if "description" not in schema:
schema[
"description"
] = f"Correctly extracted `{cls.__name__}` with all the required parameters with correct types"
return {
"name": schema["title"],
"description": schema["description"],
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openai-function-call"
version = "0.1.1"
version = "0.1.2"
description = "Helper functions that allow us to improve openai's function_call ergonomics"
authors = ["Jason <jason@jxnl.co>"]
license = "MIT"
+11 -1
View File
@@ -1,7 +1,7 @@
import pytest
from pydantic import BaseModel
from openai_function_call import openai_schema
from openai_function_call import openai_schema, OpenAISchema
def test_openai_schema():
@@ -30,3 +30,13 @@ def test_openai_schema_raises_error():
@openai_schema
class Dummy:
pass
def test_no_docstring():
class Dummy(OpenAISchema):
attr: str
assert (
Dummy.openai_schema["description"]
== "Correctly extracted `Dummy` with all the required parameters with correct types"
)