Infix notation and elif
now supported
#243
slundberg
announced in
Announcements
Replies: 2 comments 1 reply
-
I'm excited to see pyparsing is playing a key role in your project! Version 3.1.0 is just finishing beta (no further issues raised in the past few weeks), and it will include a fix to railroad diagrams. If you install the 3.1.0b2 version of pyparsing, you can add this code at the botton of _grammar.py to generate a mostly helpful railroad diagram (there are still a few empty blocks that come through that I haven't debugged yet): if __name__ == '__main__':
pp.autoname_elements()
program.create_diagram("guidance_grammar.html", show_results_names=True) |
Beta Was this translation helpful? Give feedback.
1 reply
-
Bug: {{elif}} not excute the condition statement |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Guidance has a new parser and now supports a much richer syntax, including infix notation. While Handlebars was designed to be "logicless", Guidance is designed to give you clear logical control of your LLMs as they unroll, so extending Handlebars syntax to make that easier makes sense.
Infix notation makes it easier and cleaner to write simple comparisons. So
becomes
And you can now add
elif
clausesGuidance extends Handlebars by making it more like Python, while retaining backward compatibility (meaning most Handlebars templates should work in Guidance unchanged). In addition to infix notation function calls now follow a more python syntax of
func(arg1, arg2)
but you can still omit the parenthesis and commas when you are inside an enclosed block (like{{func arg1 arg2}}
or(func arg1 arg2)
) so you can keep the clean Handlebars type syntax for most calls.Beta Was this translation helpful? Give feedback.
All reactions