Skip to content

Commit d857ac4

Browse files
authored
DOC: Guidance for serializing model metadata (#2435)
Copilot-Session: 9b95a2c8-cdc2-4e94-9776-cbea2a2b41ff
1 parent d65ed40 commit d857ac4

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

doc/code/framework.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ The below talks about responsibilities of most modules in the PyRIT library
309309
- Models includes `identifiers` which are descriptions of the core components. And along with the registry, can often recreate those components.
310310
- Models includes types passed around between components, and should be prefered in REST
311311
- models should never depend on anything except lightweight Python (the standard library and pydantic) and pyrit.common
312+
- Store metadata on the narrowest model that owns it (for example, request or response data belongs on `MessagePiece`, not `Message`). Use explicit typed fields for stable, core, or independently queried data.
313+
- For shared metadata, define a lightweight value object in `pyrit.models` that owns its keys and provides symmetric `to_metadata()` and `from_metadata()` methods. Use `JsonResponseConfig` as the pattern for data stored in `MessagePiece.prompt_metadata`.
312314

313315
## [Normalizers](./targets/11_message_normalizer)
314316

0 commit comments

Comments
 (0)