Conditional Looping in Guidance Program #191
-
I am implementing a ReAct style Guidance program that calls out to my Tools for search, math, etc. I'm able to successfully call tools (functions) now during a chain-of-thought process in the program; however, since the program flows linearly to the end, and my prompts are created in the User prompt space and generation must take place in Assistant for GPT models, how can I put the program into a loop to call as many tool functions as needed, until it reaches its "Final Answer"? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I think you can try using a geneach block with a stop parameter set to "Final Answer". Although you can try to handle control flow using guidance, I have found it best to write control flow in python and use partials if possible. You can refer to this article written by QuangBK A Simple Agent With Guidance and Local LLM |
Beta Was this translation helpful? Give feedback.
-
The above is a great example, but here is some code to save people time and effort searching for answers.
You can use a |
Beta Was this translation helpful? Give feedback.
The above is a great example, but here is some code to save people time and effort searching for answers.
You can use a
geneach
to continuously loop until your condition is met. Once met, you can use the break provided by guidance to break from the loop. This will then go ahead and execute the rest of your prompt as expected.