Closed stantonius closed 2 weeks ago
OK so I just checked and confirmed my suspicions that you can't actually do this in Python (I just assumed f-strings worked everywhere...)
However, is it anti-pattern to do something like this in dspy to the Signature class?
MyClass1.__doc__ = f"{shared_text}\n\nAdditional details for MyClass1."
Thanks for any guidance.
is it anti-pattern to do something like this
No :D
Hey - thanks for all the work on this library.
Ran into an issue where I tried to re-use text in Signature docstrings, and noticed that these do not get passed to the Modules. For example the following basic setup
generates the following template, visible in
inspect_history
:However when you try to insert dynamically into the docstring:
then the template doesn't recognize the string and uses the generic Signature docstring:
This also happens with other forms of string formatting, not just f-strings.
Come to think of it, I've never actually has dynamic text in a class docstring before so I'm not even sure this is a thing in Python. However since I am using dspy for consecutive tasks that share properties (ie. share instructions and context), I thought I would DRY by sharing text amongst signatures, but it doesn't work.