tril now gives me back a title and content of blogs

This commit is contained in:
Andrew Ridgway 2024-11-12 23:29:11 +10:00
parent 72a8428271
commit 858f7c8d0a
2 changed files with 18 additions and 3 deletions

View File

@ -4,10 +4,12 @@ import trilium.notes as tn
tril = tn.TrilumNotes() tril = tn.TrilumNotes()
tril_notes = tril.get_new_notes() tril.get_new_notes()
tril_notes = tril.get_notes_content()
for note in tril_notes: for note in tril_notes:
print(note) print(tril_notes[note]['title'])
print(tril_notes[note]['content'])
client = Client(host='http://192.168.178.45:11434') client = Client(host='http://192.168.178.45:11434')
user_prompt = input("Ask mistral-nemo a question: ") user_prompt = input("Ask mistral-nemo a question: ")

View File

@ -4,7 +4,7 @@ import os
class TrilumNotes: class TrilumNotes:
def __init__(self): def __init__(self):
self.protocol = os.environ.get('TRILUM_PROTOCOL') self.protocol = os.environ.get('TRILIUM_PROTOCOL')
self.host = os.environ.get('TRILIUM_HOST') self.host = os.environ.get('TRILIUM_HOST')
self.port = os.environ.get('TRILIUM_PORT') self.port = os.environ.get('TRILIUM_PORT')
self.tril_pass = os.environ.get('TRILIUM_PASS') self.tril_pass = os.environ.get('TRILIUM_PASS')
@ -34,3 +34,16 @@ class TrilumNotes:
) )
self.new_notes = notes self.new_notes = notes
return notes return notes
def _get_content(self, note_id):
return self.ea.get_note_content(note_id)
def get_notes_content(self):
content_dict = {}
for note in self.new_notes['results']:
content_dict[note['noteId']] = {"title" : f"{note['title']}",
"content" : f"{self._get_content(note['noteId'])}"
}
self.note_content = content_dict
return content_dict