fix bug with empty default models
This commit is contained in:
parent
b1e0e8ad99
commit
bcef4ed46f
2 changed files with 19 additions and 19 deletions
|
|
@ -253,19 +253,19 @@ class RecordModel(BaseModel):
|
||||||
# Load data from DB first
|
# Load data from DB first
|
||||||
result = repo_query(f"SELECT * FROM {self.record_id};")
|
result = repo_query(f"SELECT * FROM {self.record_id};")
|
||||||
|
|
||||||
# Initialize empty object with None for all non-ClassVar fields
|
|
||||||
db_data = {
|
|
||||||
field_name: None
|
|
||||||
for field_name, field_info in self.model_fields.items()
|
|
||||||
if not str(field_info.annotation).startswith("typing.ClassVar")
|
|
||||||
}
|
|
||||||
|
|
||||||
# Update with DB data if it exists
|
|
||||||
if result:
|
|
||||||
db_data.update(result[0])
|
|
||||||
|
|
||||||
# Initialize with DB data and any overrides
|
# Initialize with DB data and any overrides
|
||||||
super().__init__(**{**db_data, **kwargs})
|
init_data = {}
|
||||||
|
if result and result[0]:
|
||||||
|
init_data.update(result[0])
|
||||||
|
|
||||||
|
# Override with any provided kwargs
|
||||||
|
if kwargs:
|
||||||
|
init_data.update(kwargs)
|
||||||
|
|
||||||
|
# Initialize base model first
|
||||||
|
super().__init__(**init_data)
|
||||||
|
|
||||||
|
# Mark as initialized
|
||||||
object.__setattr__(self, "_initialized", True)
|
object.__setattr__(self, "_initialized", True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,14 @@ class Model(ObjectModel):
|
||||||
|
|
||||||
class DefaultModels(RecordModel):
|
class DefaultModels(RecordModel):
|
||||||
record_id: ClassVar[str] = "open_notebook:default_models"
|
record_id: ClassVar[str] = "open_notebook:default_models"
|
||||||
default_chat_model: Optional[str]
|
default_chat_model: Optional[str] = None
|
||||||
default_transformation_model: Optional[str]
|
default_transformation_model: Optional[str] = None
|
||||||
large_context_model: Optional[str]
|
large_context_model: Optional[str] = None
|
||||||
default_text_to_speech_model: Optional[str]
|
default_text_to_speech_model: Optional[str] = None
|
||||||
default_speech_to_text_model: Optional[str]
|
default_speech_to_text_model: Optional[str] = None
|
||||||
# default_vision_model: Optional[str]
|
# default_vision_model: Optional[str]
|
||||||
default_embedding_model: Optional[str]
|
default_embedding_model: Optional[str] = None
|
||||||
default_tools_model: Optional[str]
|
default_tools_model: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
class ModelManager:
|
class ModelManager:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue