twibiral / obsidian-execute-code

Obsidian Plugin to execute code in a note.
MIT License
1.06k stars 67 forks source link

Plugin breaks docstring parsing #313

Open bitnom opened 9 months ago

bitnom commented 9 months ago

I think this plugin is breaking docstring parsing. The following code will produce an error that it shouldn't:

import lmql

@lmql.query
def chain_of_thought(question):
    '''lmql
    # Q&A prompt template
    "Q: {question}\n"
    "A: Let's think step by step.\n"
    "[REASONING]"
    "Thus, the answer is:[ANSWER]."

    # return just the ANSWER to the caller
    return ANSWER
    '''

print(chain_of_thought('Today is the 12th of June, what day was it 1 week ago?'))

produces:

  File "/home/user/.pyenv/versions/3.11.6/lib/python3.11/inspect.py", line 1081, in findsource
    raise OSError('could not get source code')
OSError: could not get source code
Failed to parse docstring of query function as LMQL code: