mirror of
https://github.com/lfnovo/open-notebook.git
synced 2026-04-29 03:50:04 +00:00
improve citations and add object page
This commit is contained in:
parent
35c68dff11
commit
3ea4e41a78
14 changed files with 362 additions and 138 deletions
|
|
@ -93,10 +93,42 @@ class Asset(BaseModel):
|
|||
url: Optional[str] = None
|
||||
|
||||
|
||||
class SourceEmbedding(ObjectModel):
|
||||
table_name: ClassVar[str] = "source_embedding"
|
||||
content: str
|
||||
|
||||
@property
|
||||
def source(self) -> "Source":
|
||||
try:
|
||||
src = repo_query(f"""
|
||||
select source.* from {self.id} fetch source
|
||||
|
||||
""")
|
||||
return Source(**src[0]["source"])
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching source for embedding {self.id}: {str(e)}")
|
||||
logger.exception(e)
|
||||
raise DatabaseOperationError(e)
|
||||
|
||||
|
||||
class SourceInsight(ObjectModel):
|
||||
table_name: ClassVar[str] = "source_insight"
|
||||
insight_type: str
|
||||
content: str
|
||||
|
||||
@property
|
||||
def source(self) -> "Source":
|
||||
try:
|
||||
src = repo_query(f"""
|
||||
select source.* from {self.id} fetch source
|
||||
|
||||
""")
|
||||
return Source(**src[0]["source"])
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching source for insight {self.id}: {str(e)}")
|
||||
logger.exception(e)
|
||||
raise DatabaseOperationError(e)
|
||||
|
||||
|
||||
class Source(ObjectModel):
|
||||
table_name: ClassVar[str] = "source"
|
||||
|
|
@ -112,7 +144,7 @@ class Source(ObjectModel):
|
|||
return dict(
|
||||
id=self.id,
|
||||
title=self.title,
|
||||
insights=self.insights,
|
||||
insights=[insight.model_dump() for insight in self.insights],
|
||||
full_text=self.full_text,
|
||||
)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue