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
17 changes: 16 additions & 1 deletion dsms/knowledge/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING, Generator, List, Union

import oyaml as yaml
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, model_serializer

from dsms.core.session import Session

Expand Down Expand Up @@ -41,6 +41,21 @@ def __repr__(self):
"""Pretty print the KItemSearchResult"""
return str(self)

@model_serializer()
def serialze_results(self):
"""
Custom model serializer.

Needs to be added since the `model_dump` was only
serializing the compact model, not the full representation.
"""
return {
key: (
value.model_dump() if isinstance(value, BaseModel) else value
)
for key, value in self
}


class SearchResult(BaseModel):
"""DSMS search result"""
Expand Down