Closed hadjebi closed 11 months ago
same issue. set the api key, still getting template as output
Guidance seems to output the template whenever there's some internal error with generation - doesn't seem to pass any errors through to the user to fix. E.g.
Outputs template if
select
with chat modelsReally just seems like pretty unusable error handling 😢 Wanted to use Guidance for a project but now that seems like a bad idea
I'm going to try https://github.com/ShreyaR/guardrails for output parser
Hi, I think this is all related to errors not being surfaced in specific environments. As a short term fix, whenever the template gets returned unexecuted, you can inspect the program._exception
property to see if there are any errors.
Related thread where we're specifically discussing this issue: https://github.com/guidance-ai/guidance/issues/353
I have tried Guardrails. The idea behind Guidance is nicer but looks like it's not compatible with the new OpenAI models.
Facing similar errors. program._exception
reports:
AssertionError("The OpenAI API does not support Guidance pattern controls! Please either switch to an endpoint that does, or don't use the `pattern` argument to `gen`.")
I've also got a similar issue. In VSCode, trying to run the very first example of ~gen in tutorial.ipynb, the template is returned.
Mac OS Ventura 13.5.1 Python 3.9.6 Guidance 0.0.64
I'm using an Azure OpenAI model that I've set up as instructed here. Everything runs without throwing errors, program._exception is empty and program.log reports:
No exception occured.
I have this error: AssertionError('When calling OpenAI chat models you must generate only directly inside the assistant role! The OpenAI API does not currently support partial assistant prompting.') my code is :
import guidance
guidance.llm = guidance.llms.OpenAI("gpt-3.5-turbo", api_key="somekey")
options = ['Yes', 'No', 'Maybe']
program = guidance('''Is the following sentence offensive?
Sentence: {{example}}
Answer: {{select "answer" options=options}}''')
executed_program = program(example='I hate your tacos', options=options)
executed_program._exception
I have got same error, it maybe because of current default open ai model is chat model.
you can change model like this, it will work. https://github.com/guidance-ai/guidance#rich-output-structure-example-notebook
# set the default language model used to execute guidance programs
guidance.llm = guidance.llms.OpenAI("text-davinci-003")
it looks like this is caused by gen not being able to figure out the proper stop word anymore, see #360
Hey! thought this would be helpful.
Ran into the same issue as everyone here. The solution was to add the api key. Attaching a screenshot to show what to add.
If you don't have an API key already, get one from this link: https://platform.openai.com/account/api-keys
Hey, sorry, we had a lot of bugs everywhere. Hopefully this one is fixed in the new release. Sorry it took us so long to get to it!
The bug A lot of example notebooks don't work properly
To Reproduce
Just running the sample notebooks. A lot of them don't work properly. Am I missing something?
As an example, notebook guaranteeing_valid_syntax.ipynb doesn't work. When I run this cell:
we can pre-define valid option sets
valid_weapons = ["sword", "axe", "mace", "spear", "bow", "crossbow"]
define the prompt
program = guidance("""The following is a character profile for an RPG game in JSON format.