-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datatypes.Choice: If selected_key is not found, create it #123
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #123 +/- ##
==========================================
+ Coverage 77.62% 77.64% +0.01%
==========================================
Files 63 64 +1
Lines 3754 3766 +12
==========================================
+ Hits 2914 2924 +10
- Misses 840 842 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Ah my concern with this approach would be that there may be other keys in the schema that might not belong within the choice object. E.g. from #122
might have schema such as
In this case, One way to resolve this issue that doesn't run into this problem could be to add few shot examples at the end of Another option that is more involved is to generate a skeleton of what the correct structure should look like given the schema, and pass that in the prompt. |
760c02d
to
9c70ffe
Compare
Sorry for the late reply on this. <complete_json_suffix_v2>
Given below is XML that describes the information to extract from this document and the tags to extract it into.
{output_schema}
ONLY return a valid JSON object (no other text is necessary), where the key of the field in JSON is the `name` attribute of the corresponding XML, and the value is of the type specified by the corresponding XML's tag. The JSON MUST conform to the XML format, including any types and format requests e.g. requests for lists, objects and specific types. Be correct and concise.
Here are examples of simple (XML, JSON) pairs that show the expected behavior:
- `<![CDATA[<string name='foo' format='two-words lower-case' />`]]> => `{{{{'foo': 'example one'}}}}`
- `<![CDATA[<list name='bar'><string format='upper-case' /></list>]]>` => `{{{{"bar": ['STRING ONE', 'STRING TWO', etc.]}}}}`
- `<![CDATA[<object name='baz'><string name="foo" format="capitalize two-words" /><integer name="index" format="1-indexed" /></object>]]>` => `{{{{'baz': {{{{'foo': 'Some String', 'index': 1}}}}}}}}`
</complete_json_suffix_v2> The lowest hanging fruit is adding more examples for each new complex type to For now I've changed this PR to the simplest fix for the issue (avoids throwing the exception). |
9c70ffe
to
ae1b83c
Compare
Since the structure fix will be addressed by reasking according to the json skeleton (#185), my suggestion is to simply avoid throwing the exception. The check is already performed in the field validator, it's just that the datatype validator incorrectly assumes the key is present. |
91e9684
to
e5d6aaf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect!
any update on this? or its deprecated? |
Let's revisit this after the validator refactor (#228) and pydantic choice discriminator change, those both affect this greatly. |
Choice is now generated very differently, I think this fix is irrelevant. Closing for now. |
Fixes #122, fixes #186
This is my take on it, not sure if it works well for all correct uses of choice 👀