playing with tril api

This commit is contained in:
2024-11-12 15:59:59 +10:00
parent bf40e4a3ca
commit 72a8428271
7 changed files with 73 additions and 13 deletions
+8
View File
@@ -1,5 +1,13 @@
from ollama import Client
import trilium.notes as tn
tril = tn.TrilumNotes()
tril_notes = tril.get_new_notes()
for note in tril_notes:
print(note)
client = Client(host='http://192.168.178.45:11434')
user_prompt = input("Ask mistral-nemo a question: ")
-8
View File
@@ -1,8 +0,0 @@
from trilium_py.client import ETAPI
import os
server_url = f'{os.environ['TRILIUM_PROTOCOL']}://{os.environ['TRILIUM_HOST']}:{os.environ['TRILIUM_PORT']}'
password = os.environ['TRILIUM_PASS']
ea = ETAPI(server_url)
token = ea.login(password)
print(token)
+36
View File
@@ -0,0 +1,36 @@
from trilium_py.client import ETAPI
import os
class TrilumNotes:
def __init__(self):
self.protocol = os.environ.get('TRILUM_PROTOCOL')
self.host = os.environ.get('TRILIUM_HOST')
self.port = os.environ.get('TRILIUM_PORT')
self.tril_pass = os.environ.get('TRILIUM_PASS')
self.token = os.environ.get('TRILIUM_TOKEN')
if not all([self.protocol, self.host, self.port, self.tril_pass]):
print("One or more required environment variables not found. Have you set a .env?")
self.server_url = f'{self.protocol}://{self.host}:{self.port}'
if not self.token:
print("Please run get_token and set your token")
else:
self.ea = ETAPI(self.server_url, self.token)
def get_token(self):
ea = ETAPI(self.server_url)
token = ea.login(self.tril_pass)
print(token)
print("I would recomend you update the env file with this tootsweet!")
def get_new_notes(self):
notes = self.ea.search_note(
search="#ai_blog #blog_written=false",
ancestorNoteId="kYZXOUVabB7s",
fastSearch=False,
limit=10
)
self.new_notes = notes
return notes