-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
В продолжение issue - #40
Сейчас при работе с json_schema при методе format_instructions, формат и описания из json_schema не берутся. Необходимо добавить функционал генерации инструкции по формату подобно pydantic модели.
Из схемы, генерации подсказки по формату выполняется так (PydanticOutputParser.get_format_instructions):
def get_format_instructions(self) -> str:
"""Return the format instructions for the JSON output.
Returns:
The format instructions for the JSON output.
"""
# Copy schema to avoid altering original Pydantic schema.
schema = dict(self.pydantic_object.model_json_schema().items())
# Remove extraneous fields.
reduced_schema = schema
if "title" in reduced_schema:
del reduced_schema["title"]
if "type" in reduced_schema:
del reduced_schema["type"]
# Ensure json in context is well-formed with double quotes.
schema_str = json.dumps(reduced_schema, ensure_ascii=False)
return _PYDANTIC_FORMAT_INSTRUCTIONS.format(schema=schema_str)Rai220
Metadata
Metadata
Assignees
Labels
No labels