If/else and how to select multiple without specifying amount? #109
Unanswered
ShaneWikerSWE
asked this question in
Q&A
Replies: 2 comments
-
An example I came up with myself: n = None
def set_bool_var(is_enabled):
global n
n = is_enabled == "true"
def my_cond():
return n
prompt = """
JSON: { "enable": {{#select 'bool_var'}}true{{or}}false{{/select}} }{{set_bool_var bool_var}}
Result is {{#if my_cond}}True{{else}}False{{/if}}
"""
prog = guidance(prompt)
prog(set_bool_var=set_bool_var, my_cond=my_cond) Some reference materials in the guidance/library/_if.py file might be helpful. Based on the comments, it appears that "else if" is currently not supported. |
Beta Was this translation helpful? Give feedback.
0 replies
-
guidance("""<items>{{#geneach 'selected_items' stop="</items>"~}}
<item>{{select 'this' options=all_options}}</item>{{/geneach}}</items>""") |
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
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to find how to do if x = 6, else if, etc.
Also how to have multiple selections of an array or object, without specifying how many to choose.
Like I may ask to select all of the items in an array being referenced or talked about, but without knowing exactly how many there are.
Is there a way to do that? The documentation and examples are limited so I haven't been able to figure it out
Beta Was this translation helpful? Give feedback.
All reactions