[Evals API][5/n] fixes to generate openapi spec (#323)

* generate openapi

* typing comment, dataset -> dataset_id
This commit is contained in:
Xi Yan 2024-10-25 13:00:40 -07:00 committed by GitHub
parent d95bef7f2e
commit 4e2870445b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 2866 additions and 1229 deletions

View file

@ -4,7 +4,7 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import Dict, List, Literal, Union
from typing import Literal, Union
from pydantic import BaseModel, Field
from typing_extensions import Annotated
@ -24,12 +24,10 @@ class BooleanType(BaseModel):
class ArrayType(BaseModel):
type: Literal["array"] = "array"
items: "ParamType"
class ObjectType(BaseModel):
type: Literal["object"] = "object"
properties: Dict[str, "ParamType"] = Field(default_factory=dict)
class JsonType(BaseModel):
@ -38,12 +36,6 @@ class JsonType(BaseModel):
class UnionType(BaseModel):
type: Literal["union"] = "union"
options: List["ParamType"] = Field(default_factory=list)
class CustomType(BaseModel):
type: Literal["custom"] = "custom"
validator_class: str
class ChatCompletionInputType(BaseModel):
@ -78,6 +70,15 @@ ParamType = Annotated[
Field(discriminator="type"),
]
ArrayType.model_rebuild()
ObjectType.model_rebuild()
UnionType.model_rebuild()
# TODO: recursive definition of ParamType in these containers
# will cause infinite recursion in OpenAPI generation script
# since we are going with ChatCompletionInputType and CompletionInputType
# we don't need to worry about ArrayType/ObjectType/UnionType for now
# ArrayType.model_rebuild()
# ObjectType.model_rebuild()
# UnionType.model_rebuild()
# class CustomType(BaseModel):
# type: Literal["custom"] = "custom"
# validator_class: str