Display title where appropriate in cli
This commit is contained in:
parent
4077e3ecb2
commit
2c1e81dc6e
4 changed files with 18 additions and 2 deletions
|
|
@ -252,8 +252,16 @@ class HaikuRAGApp:
|
||||||
content = Markdown(content)
|
content = Markdown(content)
|
||||||
else:
|
else:
|
||||||
content = Markdown(doc.content)
|
content = Markdown(doc.content)
|
||||||
|
title_part = (
|
||||||
|
f" [repr.attrib_name]title[/repr.attrib_name]: {doc.title}"
|
||||||
|
if doc.title
|
||||||
|
else ""
|
||||||
|
)
|
||||||
self.console.print(
|
self.console.print(
|
||||||
f"[repr.attrib_name]id[/repr.attrib_name]: {doc.id} [repr.attrib_name]uri[/repr.attrib_name]: {doc.uri} [repr.attrib_name]meta[/repr.attrib_name]: {doc.metadata}"
|
f"[repr.attrib_name]id[/repr.attrib_name]: {doc.id} "
|
||||||
|
f"[repr.attrib_name]uri[/repr.attrib_name]: {doc.uri}"
|
||||||
|
+ title_part
|
||||||
|
+ f" [repr.attrib_name]meta[/repr.attrib_name]: {doc.metadata}"
|
||||||
)
|
)
|
||||||
self.console.print(
|
self.console.print(
|
||||||
f"[repr.attrib_name]created at[/repr.attrib_name]: {doc.created_at} [repr.attrib_name]updated at[/repr.attrib_name]: {doc.updated_at}"
|
f"[repr.attrib_name]created at[/repr.attrib_name]: {doc.created_at} [repr.attrib_name]updated at[/repr.attrib_name]: {doc.updated_at}"
|
||||||
|
|
@ -272,6 +280,9 @@ class HaikuRAGApp:
|
||||||
if chunk.document_uri:
|
if chunk.document_uri:
|
||||||
self.console.print("[repr.attrib_name]document uri[/repr.attrib_name]:")
|
self.console.print("[repr.attrib_name]document uri[/repr.attrib_name]:")
|
||||||
self.console.print(chunk.document_uri)
|
self.console.print(chunk.document_uri)
|
||||||
|
if chunk.document_title:
|
||||||
|
self.console.print("[repr.attrib_name]document title[/repr.attrib_name]:")
|
||||||
|
self.console.print(chunk.document_title)
|
||||||
if chunk.document_meta:
|
if chunk.document_meta:
|
||||||
self.console.print("[repr.attrib_name]document meta[/repr.attrib_name]:")
|
self.console.print("[repr.attrib_name]document meta[/repr.attrib_name]:")
|
||||||
self.console.print(chunk.document_meta)
|
self.console.print(chunk.document_meta)
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,6 @@ class Chunk(BaseModel):
|
||||||
metadata: dict = {}
|
metadata: dict = {}
|
||||||
order: int = 0
|
order: int = 0
|
||||||
document_uri: str | None = None
|
document_uri: str | None = None
|
||||||
|
document_title: str | None = None
|
||||||
document_meta: dict = {}
|
document_meta: dict = {}
|
||||||
embedding: list[float] | None = None
|
embedding: list[float] | None = None
|
||||||
|
|
|
||||||
|
|
@ -317,6 +317,7 @@ class ChunkRepository:
|
||||||
)
|
)
|
||||||
|
|
||||||
doc_uri = doc_results[0].uri if doc_results else None
|
doc_uri = doc_results[0].uri if doc_results else None
|
||||||
|
doc_title = doc_results[0].title if doc_results else None
|
||||||
doc_meta = doc_results[0].metadata if doc_results else "{}"
|
doc_meta = doc_results[0].metadata if doc_results else "{}"
|
||||||
|
|
||||||
chunks: list[Chunk] = []
|
chunks: list[Chunk] = []
|
||||||
|
|
@ -330,6 +331,7 @@ class ChunkRepository:
|
||||||
metadata=md,
|
metadata=md,
|
||||||
order=rec.order,
|
order=rec.order,
|
||||||
document_uri=doc_uri,
|
document_uri=doc_uri,
|
||||||
|
document_title=doc_title,
|
||||||
document_meta=json.loads(doc_meta),
|
document_meta=json.loads(doc_meta),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -398,6 +400,7 @@ class ChunkRepository:
|
||||||
# Get document info from pre-fetched map
|
# Get document info from pre-fetched map
|
||||||
doc = documents_map.get(chunk_record.document_id)
|
doc = documents_map.get(chunk_record.document_id)
|
||||||
doc_uri = doc.uri if doc else None
|
doc_uri = doc.uri if doc else None
|
||||||
|
doc_title = doc.title if doc else None
|
||||||
doc_meta = doc.metadata if doc else "{}"
|
doc_meta = doc.metadata if doc else "{}"
|
||||||
|
|
||||||
md = json.loads(chunk_record.metadata)
|
md = json.loads(chunk_record.metadata)
|
||||||
|
|
@ -409,6 +412,7 @@ class ChunkRepository:
|
||||||
metadata=md,
|
metadata=md,
|
||||||
order=chunk_record.order,
|
order=chunk_record.order,
|
||||||
document_uri=doc_uri,
|
document_uri=doc_uri,
|
||||||
|
document_title=doc_title,
|
||||||
document_meta=json.loads(doc_meta),
|
document_meta=json.loads(doc_meta),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class DocumentRepository:
|
||||||
id=record.id,
|
id=record.id,
|
||||||
content=record.content,
|
content=record.content,
|
||||||
uri=record.uri,
|
uri=record.uri,
|
||||||
title=getattr(record, "title", None),
|
title=record.title,
|
||||||
metadata=json.loads(record.metadata),
|
metadata=json.loads(record.metadata),
|
||||||
created_at=datetime.fromisoformat(record.created_at)
|
created_at=datetime.fromisoformat(record.created_at)
|
||||||
if record.created_at
|
if record.created_at
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue