Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

anthropic supports enum #524

Merged
merged 5 commits into from
Mar 22, 2024
Merged

anthropic supports enum #524

merged 5 commits into from
Mar 22, 2024

Conversation

Cruppelt
Copy link
Contributor

@Cruppelt Cruppelt commented Mar 22, 2024

Enums were coming back wrong in most cases due to Anthropic not knowing the type and possible values. Seems to work well now.

Results before and after for response_model.anthropic_schema

Before:

<tool_description>
    <tool_name>SimpleEnum</tool_name>
    <description>This is the function that must be used to construct the response.</description>
    <parameters>
        <parameter>
            <name>language</name>
            <type>unknown</type>
            <description />
            <parameters />
        </parameter>
    </parameters>
</tool_description>

After:

<tool_description>
    <tool_name>SimpleEnum</tool_name>
    <description>This is the function that must be used to construct the response.</description>
    <parameters>
        <parameter>
            <name>language</name>
            <type>string</type>
            <description />
            <values>
                <value>python</value>
                <value>javascript</value>
                <value>typescript</value>
                <value>unknown</value>
                <value>other</value>
            </values>
        </parameter>
    </parameters>
</tool_description>
Ellipsis 馃殌 This PR description was created by Ellipsis for commit d7d2237.

Summary:

The pull request adds support for 'enum' types in the _add_params function of /instructor/anthropic_utils.py by creating a 'values' sub-element for each enum value under the 'parameter' element.

Key points:

  • Modified _add_params function in /instructor/anthropic_utils.py.
  • Added handling for 'enum' type in the reference dictionary.
  • If 'enum' is found, a 'values' sub-element is created under the 'parameter' element.
  • Each enum value is added as a 'value' sub-element under 'values'.

Generated with 鉂わ笍 by ellipsis.dev


Ellipsis 馃殌 This PR description was created by Ellipsis for commit aae13c2.

Summary:

This PR enhances the _add_params function in /instructor/anthropic_utils.py to support 'enum' types by creating a 'values' sub-element for each enum value under the 'parameter' element, and tests the changes in /tests/anthropic/test_anthropic.py.

Key points:

  • Modified _add_params function in /instructor/anthropic_utils.py to handle 'enum' types.
  • When 'enum' type is encountered, a 'values' sub-element is created under the 'parameter' element.
  • Each enum value is added as a 'value' sub-element under 'values'.
  • Changes are tested in /tests/anthropic/test_anthropic.py.

Generated with 鉂わ笍 by ellipsis.dev

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃憤 Looks good to me!

  • Reviewed the entire pull request up to d7d2237
  • Looked at 27 lines of code in 1 files
  • Took 1 minute and 15 seconds to review
More info
  • Skipped 0 files when reviewing.
  • Skipped posting 2 additional comments because they didn't meet confidence threshold of 85%.
1. instructor/anthropic_utils.py:94:
  • Assessed confidence : 66%
  • Comment:
    The continue statement here will skip the rest of the loop after processing the enum values. Please ensure that this is the intended behavior and that there are no other operations that need to be performed in the loop after this point.
  • Reasoning:
    The PR author has added a continue statement after processing the enum values. This means that the rest of the code in the loop will be skipped for this iteration. This could potentially lead to bugs if there are other important operations that need to be performed in the loop after processing the enum values.
2. instructor/anthropic_utils.py:88:
  • Assessed confidence : 100%
  • Grade: 0%
  • Comment:
    Please add a comment explaining the purpose of this new code block. It's important to document new features or changes to help other developers understand the code.
  • Reasoning:
    The PR author has added support for enum values in the _add_params function. The code looks fine, but there is no comment explaining the new code block. This could make it difficult for other developers to understand the purpose of this block.

Workflow ID: wflow_Gtnm8mODYENBTmlM


Not what you expected? You can customize the content of the reviews using rules. Learn more here.

@Cruppelt Cruppelt marked this pull request as draft March 22, 2024 09:37
@Cruppelt Cruppelt marked this pull request as ready for review March 22, 2024 09:48
@Cruppelt Cruppelt changed the title anthropic support enum anthropic supports enum Mar 22, 2024
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃憤 Looks good to me!

  • Reviewed the entire pull request up to aae13c2
  • Looked at 114 lines of code in 2 files
  • Took 59 seconds to review
More info
  • Skipped 0 files when reviewing.
  • Skipped posting 2 additional comments because they didn't meet confidence threshold of 85%.
1. instructor/anthropic_utils.py:95:
  • Assessed confidence : 50%
  • Comment:
    The 'continue' statement here might cause the function to skip processing the rest of the code for the current iteration of the loop. This could potentially lead to bugs if there are more things to process for the current 'details'. Please ensure that this is the intended behavior.
  • Reasoning:
    The changes in the PR seem to be handling the 'enum' type correctly by adding a 'values' sub-element for each enum value under the 'parameter' element. However, the 'continue' statement at line 95 in 'anthropic_utils.py' might cause the function to skip processing the rest of the code for the current iteration of the loop. This could potentially lead to bugs if there are more things to process for the current 'details'.
2. tests/anthropic/test_anthropic.py:13:
  • Assessed confidence : 100%
  • Grade: 80%
  • Comment:
    The test cases are marked as 'skip'. Please ensure that all test cases are being run to validate the functionality of the code.
  • Reasoning:
    The test cases in 'test_anthropic.py' are marked as 'skip'. This means they won't be executed during the test run. It's important to ensure that all test cases are being run to validate the functionality of the code.

Workflow ID: wflow_o3adFMSfZAAiPSVc


Not what you expected? You can customize the content of the reviews using rules. Learn more here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants