mirror of
https://github.com/kennethreitz/instructor.git
synced 2026-06-05 22:50:18 +00:00
@@ -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
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user