Note the "Sign in with Hugging Face" button that is added with my page, can I just auto --- Now I would also like the text generator to produce a JSON object based on the monster concept. This will be created with the following schema: - name: string - description: string - rarity: likert (very-low, low, medium, high, very-high) - HP: likert - defence: likert - attack: likert - speed: likert - special ability: string (passive trait that gives the monster a unique advantage in battle) - attack action description: string (deals damage) - boost action description: string (buff monsters own stats/status) - disparage action description: string (lowers enemy stats/status) - special action description: string (powerful action with single use per battle) Also update the DB to use this JSON data in its schema. --- ```python import json from pydantic import BaseModel STRUCTURED_OUTPUT_FORMAT_INSTRUCTIONS = """The output should be formatted as a JSON instance that conforms to the JSON schema below. As an example, for the schema {{"properties": {{"foo": {{"title": "Foo", "description": "a list of strings", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}} the object {{"foo": ["bar", "baz"]}} is a well-formatted instance of the schema. The object {{"properties": {{"foo": ["bar", "baz"]}}}} is not well-formatted. Here is the output schema: ``` {schema} ```""" class StructuredOutputParser(BaseModel): pydantic_class: type[BaseModel] def get_schema(self, indent: int = 2) -> str: # Copy schema to avoid altering original Pydantic schema. schema = self.pydantic_class.model_json_schema() # Iterate over fields to remove from the schema for field_name in ["title", "type"]: if field_name in schema: schema.pop(field_name) return json.dumps(schema, indent=indent, ensure_ascii=False) def get_format_instructions(self) -> str: schema_str = self.get_schema() # Ensure json in context is well-formed with double quotes. return STRUCTURED_OUTPUT_FORMAT_INSTRUCTIONS.format(schema=schema_str) def parse(self, json_string: str) -> BaseModel: return self.pydantic_class.model_validate_json(json_string) ```