Skip to content

Conversation serialization ambiguity #2284

@jucor

Description

@jucor

The Conversation class in Delphi has two export methods: get_full_data() , and to_dict() which exports more content but also renames the fields to match the Clojure old export (e.g. attribute conversation_id is renamed to zid) ? The latter renames to zid, but its unit test test_conversation.py still checks for conversation_id and thus fails.

Note: get_full_data() does not have tests. But is used in the code and the notebooks. In particular, get_full_data() is user-facing via the route /api/v3/conversations/{conversation_id}

On the other hand to_dict() (the one with the Clojure-compatible renaming) is used in all the tests, and by the ConversationManager serialization tool, and its internal saving tool (when it stores a json to the data_dir -- and I'm unsure where those files are then used).

Thickening the plot, while to_dict() renames conversation_id to zid, from_dict() expects a conversation_id, not a zid .... So I'm not sure if from_dict() is supposed to be callable with the output of get_full_data(), as its use of conversation_id seems to indicate, or that of to_dict(), as its function name seems to indict.

It would be clearer to:

  • Have only one export method, if possible -- I guess it depends on the downstream uses?
  • Or if not possible, at least factorize the duplicate code, and fix the tests for to_dict() and from_dict() and add similar tests for get_full_data() and for the serialization

As a temporary (😅 ) fix, I can try to modify from_dict() so it accepts both conversation_id and zid, as long as only one is present, or as long as both agree if both are present. If neither is present or if they disagree, default to the current default behaviour of empty conversation name 🤷 (ideally I'd raise an error if both are present and disagree, but I'm not sure how robust are the callers and wouldn't want to break the server...).

I'll do the same for any other similar fields which store the exact same content but go by two distinct names (i.e. new name vs renamed to old Clojure's name).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions