Open dokluch opened 1 year ago
facing the same issue with text-davinci as well, it says
"""openAI dose not support creating assert not pattern, "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
."
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
."""
This pattern of generation is only supported when using guidance.llms.Transformers
see the notebook
facing the same issue with text-davinci as well, it says
"""openAI dose not support creating assert not pattern, "The OpenAI API does not support Guidance pattern controls! Please either switch to an endpoint that does, or don't use the
pattern
argument togen
." AssertionError: The OpenAI API does not support Guidance pattern controls! Please either switch to an endpoint that does, or don't use thepattern
argument togen
."""
For this case, I had to remove the pattern argument (as suggested in the error msg) in the handlebar to generate the json output. Seems like we have to rely on OpenAI model to deduce the right pattern for each field.
As a workaround, I've followed the prompt from here with a parser function (below) to just get the json object, just in case there are still explanations around the JSON. This seems to work pretty reliably.
def get_json(text):
pattern = regex.compile(r'\{(?:[^{}]|(?R))*\}')
return pattern.findall(text)[0]
Looks like OpenAI released function calling yesterday in their latest gpt-3.5-turbo-0613 which allows native JSON rendering. Here's a good writeup about using it.
The bug Chat models seemingly can't generate JSON as output.
To Reproduce I am using the same schema as with text-davinci, but wrapping it with the assistant role:
The error I get is:
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.
It works without JSON, though.
System info (please complete the following information):