Skip to content

Commit

Permalink
chore: fix description, add http logging
Browse files Browse the repository at this point in the history
  • Loading branch information
G4Vi committed Dec 20, 2024
1 parent 6b5b589 commit 16dabe8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion servlets/obsidian/plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 13 additions & 6 deletions servlets/obsidian/plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/')
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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": {
Expand Down

0 comments on commit 16dabe8

Please sign in to comment.