From aa8891f0522b6b000025ab4d5f214f38c2cc627b Mon Sep 17 00:00:00 2001 From: Gavin Hayes Date: Fri, 20 Dec 2024 17:57:11 -0500 Subject: [PATCH] chore: fix description, add http logging --- servlets/obsidian/plugin/__init__.py | 1 - servlets/obsidian/plugin/plugin.py | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/servlets/obsidian/plugin/__init__.py b/servlets/obsidian/plugin/__init__.py index 085e746..292f8fa 100755 --- a/servlets/obsidian/plugin/__init__.py +++ b/servlets/obsidian/plugin/__init__.py @@ -31,7 +31,6 @@ # If you support multiple tools, you must switch on the input.params.name to detect which tool is being called. @extism.plugin_fn def call(): - extism.log(extism.LogLevel.Error, "beginning of call") data = json.loads(extism.input_str()) res = plugin.call(data) extism.output(res) diff --git a/servlets/obsidian/plugin/plugin.py b/servlets/obsidian/plugin/plugin.py index 7190930..89bce43 100755 --- a/servlets/obsidian/plugin/plugin.py +++ b/servlets/obsidian/plugin/plugin.py @@ -27,11 +27,21 @@ def __init__(self): self.headers = {"Authorization": f"Bearer {api_key}"} def get(self, path): - return extism.Http.request(f"{self.host}{path}", 'GET', None, self.headers).data_str() + extism.log(extism.LogLevel.Info, f"get {self.host}{path}") + res = extism.Http.request(f"{self.host}{path}", 'GET', None, self.headers) + extism.log(extism.LogLevel.Info, f"-> {res.status_code}") + resres = res.data_str() + extism.log(extism.LogLevel.Debug, f"-> {resres}") + return resres def post(self, path, body = None, extraheaders = {}): headers = self.headers | extraheaders - return extism.Http.request(f"{self.host}{path}", 'POST', body, headers).data_str() + extism.log(extism.LogLevel.Info, f"post {self.host}{path}") + res = extism.Http.request(f"{self.host}{path}", 'POST', body, headers) + extism.log(extism.LogLevel.Info, f"-> {res.status_code}") + resres = res.data_str() + extism.log(extism.LogLevel.Debug, f"-> {resres}") + return resres def list_files_in_vault(self): return self.get('/vault/') @@ -164,8 +174,6 @@ def describe() -> ListToolsResult: description="Lists all files and directories in the root directory of your Obsidian vault.", inputSchema={ "type": "object", - "properties": {}, - "required": [], }, ), ToolDescription( @@ -274,8 +282,7 @@ def describe() -> ListToolsResult: description="""Complex search for documents using a JsonLogic query. Supports standard JsonLogic operators plus 'glob' and 'regexp' for pattern matching. Results must be non-falsy. - Use this tool when you want to do a complex search, e.g. for all documents with certain tags etc. - """, + Use this tool when you want to do a complex search, e.g. for all documents with certain tags etc.""", inputSchema={ "type": "object", "properties": {