-
-
Notifications
You must be signed in to change notification settings - Fork 647
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
feat: implement jinja templating and rename kwarg to context
#1011
Conversation
Deploying instructor with Cloudflare Pages
|
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.
👍 Looks good to me! Reviewed everything up to a03109c in 57 seconds
More details
- Looked at
1168
lines of code in9
files - Skipped
0
files when reviewing. - Skipped posting
10
drafted comments based on config settings.
1. instructor/function_calls.py:108
- Draft comment:
The parametervalidation_context
is still being used here without handling its deprecation. Consider using thehandle_context
function to manage the transition fromvalidation_context
tocontext
. - Reason this comment was not posted:
Confidence changes required:80%
The PR introduces a newcontext
parameter and deprecatesvalidation_context
. However, there are still instances wherevalidation_context
is used without a deprecation warning or handling. This should be addressed to ensure consistency and proper deprecation handling.
2. instructor/process_response.py:106
- Draft comment:
The parametervalidation_context
is still being used here without handling its deprecation. Consider using thehandle_context
function to manage the transition fromvalidation_context
tocontext
. - Reason this comment was not posted:
Confidence changes required:80%
The PR introduces a newcontext
parameter and deprecatesvalidation_context
. However, there are still instances wherevalidation_context
is used without a deprecation warning or handling. This should be addressed to ensure consistency and proper deprecation handling.
3. instructor/retry.py:187
- Draft comment:
The parametervalidation_context
is still being used here without handling its deprecation. Consider using thehandle_context
function to manage the transition fromvalidation_context
tocontext
. - Reason this comment was not posted:
Confidence changes required:80%
The PR introduces a newcontext
parameter and deprecatesvalidation_context
. However, there are still instances wherevalidation_context
is used without a deprecation warning or handling. This should be addressed to ensure consistency and proper deprecation handling.
4. instructor/retry.py:266
- Draft comment:
The parametervalidation_context
is still being used here without handling its deprecation. Consider using thehandle_context
function to manage the transition fromvalidation_context
tocontext
. - Reason this comment was not posted:
Confidence changes required:80%
The PR introduces a newcontext
parameter and deprecatesvalidation_context
. However, there are still instances wherevalidation_context
is used without a deprecation warning or handling. This should be addressed to ensure consistency and proper deprecation handling.
5. docs/blog/posts/jinja-proposal.md:1
- Draft comment:
The newjinja-proposal.md
file should be added to themkdocs.yml
to ensure it is included in the documentation. - Reason this comment was not posted:
Confidence changes required:80%
The newjinja-proposal.md
file should be added to themkdocs.yml
to ensure it is included in the documentation.
6. instructor/client.py:65
- Draft comment:
Thevalidation_context
parameter is deprecated. Consider updating to usecontext
instead. This applies to other overloads in this file as well. - Reason this comment was not posted:
Confidence changes required:80%
Thecreate
method ininstructor/client.py
has multiple overloads with thevalidation_context
parameter, which is deprecated. It should be updated to usecontext
instead.
7. instructor/function_calls.py:108
- Draft comment:
Thevalidation_context
parameter is deprecated. Consider updating to usecontext
instead. - Reason this comment was not posted:
Confidence changes required:80%
Thevalidation_context
parameter is deprecated and should be updated to usecontext
instead in thefrom_response
method.
8. instructor/patch.py:55
- Draft comment:
Ensure that thehandle_context
function reflects the deprecation ofvalidation_context
. - Reason this comment was not posted:
Confidence changes required:80%
Thehandle_context
function ininstructor/patch.py
is handling bothcontext
andvalidation_context
. Sincevalidation_context
is deprecated, ensure that the function is updated to reflect this change.
9. instructor/process_response.py:106
- Draft comment:
Thevalidation_context
parameter is deprecated. Consider updating to usecontext
instead. This applies to other functions in this file as well. - Reason this comment was not posted:
Confidence changes required:80%
Theprocess_response
function ininstructor/process_response.py
usesvalidation_context
, which is deprecated. It should be updated to usecontext
instead.
10. instructor/retry.py:187
- Draft comment:
Thevalidation_context
parameter is deprecated. Consider updating to usecontext
instead. This applies to other functions in this file as well. - Reason this comment was not posted:
Confidence changes required:80%
Theretry_sync
function ininstructor/retry.py
usesvalidation_context
, which is deprecated. It should be updated to usecontext
instead.
Workflow ID: wflow_vHNotWBouDNKSyNt
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 6c85df2 in 35 seconds
More details
- Looked at
38
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. instructor/patch.py:163
- Draft comment:
validation_context
is deprecated. Consider updating to usecontext
instead, as per the PR description. - Reason this comment was not posted:
Confidence changes required:80%
The PR description mentions deprecatingvalidation_context
in favor ofcontext
. However, theprocess_response_async
andprocess_response
functions still usevalidation_context
. This should be updated to reflect the newcontext
parameter.
2. instructor/process_response.py:22
- Draft comment:
Thevalidation_context
parameter is deprecated. Consider updating this to usecontext
instead, and handle the deprecation accordingly. - Reason this comment was not posted:
Confidence changes required:80%
Thevalidation_context
parameter is deprecated and replaced bycontext
. However, theprocess_response_async
andprocess_response
functions still usevalidation_context
without any deprecation warning or handling. This should be updated to reflect the changes made in the PR.
Workflow ID: wflow_KAxgf7KCOfDN24nj
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
@ivanleomk oh man can you help take a look at some of these errors? |
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.
👍 Looks good to me! Incremental review on 69cec4d in 22 seconds
More details
- Looked at
10
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. .github/workflows/pyright.yml:47
- Draft comment:
Consider specifying the version forjakebailey/pyright-action
to ensure consistent behavior across runs. - Reason this comment was not posted:
Confidence changes required:80%
The removal of the 'version' key in the pyright-action step might lead to using the latest version by default, which could introduce unexpected changes or incompatibilities. It's generally a good practice to specify the version to ensure consistent behavior.
2. .github/workflows/pyright.yml:47
- Draft comment:
Consider specifying a version forjakebailey/pyright-action
to ensure consistent behavior. - Reason this comment was not posted:
Confidence changes required:50%
The version specification for the pyright-action has been removed, which might affect the consistency of the action's behavior.
Workflow ID: wflow_aZBYjWcEJp4ME82j
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 2f967ff in 22 seconds
More details
- Looked at
10
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. .github/workflows/pyright.yml:49
- Draft comment:
Ensure that the specified Pyright version (1.1.373) is compatible with the current setup and dependencies. This is crucial for maintaining consistency and avoiding potential issues. - Reason this comment was not posted:
Confidence changes required:50%
The version of Pyright is being set in the workflow file, which is a good practice for consistency. However, it's important to ensure that this version is compatible with the rest of the setup.
2. .github/workflows/pyright.yml:49
- Draft comment:
If the pyright-action version is updated, ensure the documentation reflects this change. - Reason this comment was not posted:
Confidence changes required:80%
The version update for the pyright-action should be documented.
Workflow ID: wflow_Kqfa5ZbtcP8G8YNN
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on d7e7baa in 27 seconds
More details
- Looked at
34
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. instructor/client_cohere.py:64
- Draft comment:
Thevalidation_context
parameter is deprecated and should be removed from the function signature. Update the function to rely solely on thecontext
parameter. - Reason this comment was not posted:
Comment was on unchanged code.
Workflow ID: wflow_V3uJzjSWdQ20yZw8
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on a274ef2 in 27 seconds
More details
- Looked at
18
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. instructor/patch.py:123
- Draft comment:
Avoid using# type:ignore
unless necessary. It can hide potential type errors. This comment is also applicable on lines 124 and 126. - Reason this comment was not posted:
Confidence changes required:50%
The use of# type:ignore
is unnecessary and should be avoided unless absolutely necessary. It can hide potential type errors.
Workflow ID: wflow_FtGMHaYENG821DZ5
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 65d178f in 21 seconds
More details
- Looked at
13
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. instructor/patch.py:245
- Draft comment:
Avoid using# type: ignore
unless absolutely necessary. It can hide potential type issues. Consider addressing the root cause of the type warning instead. - Reason this comment was not posted:
Confidence changes required:80%
The use of# type: ignore
should be minimized as it can hide potential type issues. It's better to address the root cause of the type warning.
2. instructor/patch.py:246
- Draft comment:
The# type: ignore
comment on the return statement might indicate a potential issue. Ensure this is necessary and document why it's ignored. - Reason this comment was not posted:
Confidence changes required:50%
The return statement innew_create_sync
has a# type: ignore
comment, which might indicate a potential issue that should be addressed or documented properly.
Workflow ID: wflow_QlIygFyLipo4i9G7
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on b55e0db in 40 seconds
More details
- Looked at
138
lines of code in3
files - Skipped
0
files when reviewing. - Skipped posting
4
drafted comments based on config settings.
1. instructor/client_cohere.py:13
- Draft comment:
handle_cohere_templating
is imported but not used in the visible changes. Ensure that its usage is correctly implemented or remove the import if unnecessary. - Reason this comment was not posted:
Confidence changes required:50%
The import statement forhandle_cohere_templating
was added, but the function is not used in the visible diff. This might indicate an incomplete change or a missing usage.
2. instructor/patch.py:80
- Draft comment:
Consider creating a copy ofnew_kwargs
before modifying it to avoid side effects:
new_kwargs = new_kwargs.copy()
- Reason this comment was not posted:
Confidence changes required:50%
Thehandle_cohere_templating
function is modifyingnew_kwargs
directly, which could lead to unexpected side effects ifnew_kwargs
is used elsewhere. It's better to create a copy ofnew_kwargs
before modifying it.
3. instructor/patch.py:98
- Draft comment:
Consider creating a copy ofmessages
before modifying it to avoid side effects:
messages = [message.copy() for message in messages]
- Reason this comment was not posted:
Confidence changes required:50%
Thehandle_templating
function is modifying themessages
list in place, which could lead to unexpected side effects ifmessages
is used elsewhere. It's better to create a copy ofmessages
before modifying it.
4. tests/llm/test_cohere/test_json_schema.py:100
- Draft comment:
Assertions should include error messages for clarity. This applies to all assertions in this file. - Reason this comment was not posted:
Confidence changes required:80%
The assertion statements in the test cases lack error messages, which are important for debugging when tests fail.
Workflow ID: wflow_hbFDuSTOwnXiKBuE
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on d889b15 in 33 seconds
More details
- Looked at
36
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. tests/test_formatting.py:3
- Draft comment:
Consider importingpytest
at the top of the file to maintain consistency and avoid potential issues ifpytest
is used in the future. - Reason this comment was not posted:
Confidence changes required:50%
The test filetest_formatting.py
is missing an import statement forpytest
, which is used in the test filetest_validation_context.py
. This could lead to issues ifpytest
is used intest_formatting.py
in the future.
2. tests/test_formatting.py:1
- Draft comment:
Addimport pytest
at the top of the file to ensure the tests can be run using pytest. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable:
The comment suggests addingimport pytest
, but the test functions do not seem to use any pytest-specific features. The removal ofimport pytest
might be intentional if the tests can run without it. The comment does not provide strong evidence that addingimport pytest
is necessary.
I might be missing the context of how these tests are executed. If they are part of a larger suite that uses pytest, the import might be necessary for consistency or future use.
The tests do not currently use pytest-specific features, so the import is not strictly necessary. If future changes require pytest, the import can be added then.
The comment should be deleted because there is no strong evidence thatimport pytest
is necessary for the current test functions.
Workflow ID: wflow_zrUoQR3LtF8lcVmg
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
|
||
if "messages" in new_kwargs: | ||
new_kwargs["messages"] = handle_templating(new_kwargs["messages"], context) | ||
elif "message" in new_kwargs and "chat_history" in new_kwargs: |
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.
@jxnl , Cohere client seems to have a separate async method in its definition, that's why we only modify the sync here.
Thoughts on this approach to help support cohere messages?
@@ -30,6 +30,25 @@ def test_parse_user_sync(client, mode): | |||
assert resp.age == 27 | |||
|
|||
|
|||
@pytest.mark.parametrize("mode", modes) | |||
def test_parse_user_sync_jinja(client, mode): |
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.
Added some jinja tests to validate that the parsing is working too
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.
Looks good to me with the passing cohere and openai tests
Important
Integrates Jinja templating, adds
context
parameter, deprecatesvalidation_context
, and adds new tests.client.py
andpatch.py
for prompt formatting. Addscontext
parameter to methods inclient.py
. Deprecatesvalidation_context
.handle_context
andhandle_templating
inpatch.py
. Updatesfrom_response
infunction_calls.py
to usecontext
.test_validation_context.py
for context handling andtest_formatting.py
for Jinja templating.This description was created by for d889b15. It will automatically update as commits are pushed.