Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/paperoni/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from google.genai import types
from paperazzi.platforms.utils import Message
from paperazzi.utils import _make_key as paperazzi_make_key, disk_cache, disk_store
from serieux.features.comment import CommentProxy
from serieux.features.comment import CommentProxy, comment_field
from serieux.features.encrypt import Secret

_JSON_SCHEMA_TYPES = {
Expand Down Expand Up @@ -108,16 +108,16 @@ def load(self, file_obj: BinaryIO) -> types.GenerateContentResponse:
else:
metadata_type = PromptMetadata

data = dict(data)
comment = data.pop(comment_field, {})
with SERIEUX_LOCK:
response = serieux.deserialize(
serieux.Comment[serieux.JSON, metadata_type], data
response: types.GenerateContentResponse = (
types.GenerateContentResponse.model_validate(data)
)
response: types.GenerateContentResponse = CommentProxy(
types.GenerateContentResponse.model_validate(response), response._
)
# response.parsed is reset to a generic Pydantic BaseModel. Restore the
# parsed value.
response.parsed = data["parsed"]

comment = serieux.deserialize(metadata_type, comment)
response = CommentProxy(response, comment)
response.parsed = comment.parsed
Comment on lines -112 to +120
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only serieux.deserialize needs to be protected by with SERIEUX_LOCK: but it's not such a big deal


return response

Expand Down
Loading