mirror of
https://github.com/lfnovo/open-notebook.git
synced 2026-04-30 04:20:02 +00:00
enable use without optional models, adds warning
This commit is contained in:
parent
cd3ad2e9fa
commit
c8b5d422ae
12 changed files with 108 additions and 44 deletions
|
|
@ -110,7 +110,6 @@ class ObjectModel(BaseModel):
|
|||
|
||||
def save(self) -> None:
|
||||
from open_notebook.domain.models import model_manager
|
||||
from open_notebook.models import EmbeddingModel
|
||||
|
||||
try:
|
||||
self.model_validate(self.model_dump(), strict=True)
|
||||
|
|
@ -120,8 +119,16 @@ class ObjectModel(BaseModel):
|
|||
if self.needs_embedding():
|
||||
embedding_content = self.get_embedding_content()
|
||||
if embedding_content:
|
||||
EMBEDDING_MODEL: EmbeddingModel = model_manager.embedding_model
|
||||
data["embedding"] = EMBEDDING_MODEL.embed(embedding_content)
|
||||
EMBEDDING_MODEL = model_manager.embedding_model
|
||||
if not EMBEDDING_MODEL:
|
||||
logger.warning(
|
||||
"No embedding model found. Content will not be searchable."
|
||||
)
|
||||
data["embedding"] = (
|
||||
EMBEDDING_MODEL.embed(embedding_content)
|
||||
if EMBEDDING_MODEL
|
||||
else []
|
||||
)
|
||||
|
||||
if self.id is None:
|
||||
data["created"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue