Open mondaychen opened 1 year ago
Thanks! Feel free to open a PR to fix this, it shouldn't be a big change to the current logic.
It looks like this is a feature request for Enum
and constr
prompts, and it's not entirely clear to me how we should translate those to prompts. Do we want them to take their JSON schema formats?
Hey guys, I'm about to rewrite text.prompts.parse_pydantic_schema
Based on :
class JokeType(str, Enum):
dark = "dark"
light = "light"
class Joke(BaseModel):
joke: str
type: JokeType = Field(..., description="description_value")
explanation: str
@text.prompt
def prompt_func(response_model):
"""Make a joke about c++.
RESPONSE FORMAT:
{{ response_model | schema }}
"""
prompt = prompt_func(Joke)
#Make a joke about c++.
#RESPONSE FORMAT:
#{
# "joke": "<joke>",
# "type": "description_value",
# "explanation": "<explanation>"
#}
But I have few questions of improvements, do you have a topic where you decided how "<value>"
should be displayed ?
Do we want to keep Optional[Any]
fields ?
we can loop on required
iterable display : "<[value1, ..., value_n]>"
constr : should we display "<value | **constr_kwarg>"
could pop
title
andtype
Need to check nested ones to be sure, but could pop also "required" values
add type ? "<value | type>"
handle primitive or most used/adopt by python community only
add description Field(..., description='my custom description)
-> "<value | description>"
handle Validator and transcribe into description
use transformer to explain the code within ? might be dangerous
Values will look like this in the prompt :
"<value | type | **constr_kwargs & description>"
What about it, if you have ideas or no go, let me know
Get error
KeyError: 'properties'
If remove
armor
fromCharacter
this works fine