mirror of
https://github.com/lfnovo/open-notebook.git
synced 2026-04-28 19:40:50 +00:00
model manager
This commit is contained in:
parent
3b7dd5f25f
commit
a9ac4a6dc8
6 changed files with 141 additions and 43 deletions
|
|
@ -9,14 +9,13 @@ from open_notebook.database.repository import (
|
|||
repo_query,
|
||||
)
|
||||
from open_notebook.domain.base import ObjectModel
|
||||
from open_notebook.domain.models import DefaultModels
|
||||
from open_notebook.exceptions import (
|
||||
DatabaseOperationError,
|
||||
InvalidInputError,
|
||||
)
|
||||
|
||||
# from temp.recursive_toc import graph as toc_graph
|
||||
from open_notebook.models import get_model
|
||||
from open_notebook.models import model_manager
|
||||
from open_notebook.utils import split_text, surreal_clean
|
||||
|
||||
|
||||
|
|
@ -140,8 +139,7 @@ class Source(ObjectModel):
|
|||
raise DatabaseOperationError(e)
|
||||
|
||||
def vectorize(self) -> None:
|
||||
DEFAULT_MODELS = DefaultModels.load()
|
||||
EMBEDDING_MODEL = get_model(DEFAULT_MODELS.default_embedding_model)
|
||||
EMBEDDING_MODEL = model_manager.get_default_model("embedding")
|
||||
|
||||
try:
|
||||
if not self.full_text:
|
||||
|
|
@ -192,8 +190,7 @@ class Source(ObjectModel):
|
|||
raise DatabaseOperationError("Failed to search sources")
|
||||
|
||||
def add_insight(self, insight_type: str, content: str) -> Any:
|
||||
DEFAULT_MODELS = DefaultModels.load()
|
||||
EMBEDDING_MODEL = get_model(DEFAULT_MODELS.default_embedding_model)
|
||||
EMBEDDING_MODEL = model_manager.get_default_model("embedding")
|
||||
|
||||
if not insight_type or not content:
|
||||
raise InvalidInputError("Insight type and content must be provided")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue