-
Notifications
You must be signed in to change notification settings - Fork 1
fix: fix response class strictness #146
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
Open
OscarDDD
wants to merge
17
commits into
main
Choose a base branch
from
fix-response-class-strictness
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b6779c9
fix: add reasoning_content field to fix pydantic validation error
mwien 9204c29
add minimal unit testing
mwien 1d4197d
Merge branch 'main' into orchestration-reasoning-content
yamaceay ea1e013
Merge branch 'main' into orchestration-reasoning-content
yamaceay f89a04a
add reasoning block to related model class.
OscarDDD 4798b3d
add minimal unit tests
OscarDDD 8d7c747
Merge branch 'main' into fix-response-class-strictness
OscarDDD 438805c
allow all response related class to accept extra classes.
OscarDDD 8581e15
cleaning
OscarDDD 9971fc3
fix the ci checks
OscarDDD fe31698
use ResponseBaseModel for embeddings response classes
OscarDDD a4e0f3d
Merge branch 'main' into fix-response-class-strictness
OscarDDD 91c12c3
Merge branch 'orchestration-reasoning-content' into fix-response-clas…
OscarDDD 61d757e
set ResponseBaseModel to AssistantMessage
OscarDDD f084a7a
fix the test code style
OscarDDD 38c7859
fix the typo
OscarDDD a452d8d
switch AssistantMessage back to BaseModel
OscarDDD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import unittest | ||
|
|
||
| from gen_ai_hub.orchestration_v2.models.message import ( | ||
| AssistantMessage, | ||
| ReasoningBlock, | ||
| ResponseChatMessage, | ||
| ) | ||
|
|
||
|
|
||
| class TestResponseChatMessageValidation(unittest.TestCase): | ||
|
|
||
| def test_reasoning_content_deserialized_from_dict(self): | ||
| msg = ResponseChatMessage.model_validate({ | ||
| "role": "assistant", | ||
| "content": "Hello", | ||
| "reasoning_content": [{"content": "I think...", "signature": "sig123"}], | ||
| }) | ||
| self.assertIsNotNone(msg.reasoning_content) | ||
| self.assertIsInstance(msg.reasoning_content[0], ReasoningBlock) | ||
|
|
||
| def test_reasoning_content_optional(self): | ||
| msg = ResponseChatMessage.model_validate({"role": "assistant", "content": "Hello"}) | ||
| self.assertIsNone(msg.reasoning_content) | ||
|
|
||
|
|
||
| class TestAssistantMessageValidation(unittest.TestCase): | ||
|
|
||
| def test_reasoning_content_deserialized_from_dict(self): | ||
| msg = AssistantMessage.model_validate({ | ||
| "role": "assistant", | ||
| "content": "Paris", | ||
| "reasoning_content": [{"content": "France's capital is Paris.", "signature": "sig"}], | ||
| }) | ||
| self.assertIsNotNone(msg.reasoning_content) | ||
| self.assertIsInstance(msg.reasoning_content[0], ReasoningBlock) | ||
| self.assertEqual(msg.reasoning_content[0].content, "France's capital is Paris.") | ||
| self.assertEqual(msg.reasoning_content[0].signature, "sig") | ||
|
|
||
| def test_reasoning_content_optional(self): | ||
| msg = AssistantMessage.model_validate({"role": "assistant", "content": "Hello"}) | ||
| self.assertIsNone(msg.reasoning_content) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import unittest | ||
|
|
||
| from gen_ai_hub.orchestration_v2.models.message import ReasoningBlock | ||
| from gen_ai_hub.orchestration_v2.models.response import StreamDelta | ||
|
|
||
|
|
||
| class TestStreamDeltaValidation(unittest.TestCase): | ||
|
|
||
| def test_reasoning_content_deserialized_from_dict(self): | ||
| delta = StreamDelta.model_validate({ | ||
| "content": "", | ||
| "reasoning_content": [{"content": "I should respond politely.", "signature": ""}], | ||
| }) | ||
| self.assertIsNotNone(delta.reasoning_content) | ||
| self.assertIsInstance(delta.reasoning_content[0], ReasoningBlock) | ||
| self.assertEqual(delta.reasoning_content[0].content, "I should respond politely.") | ||
|
|
||
| def test_reasoning_content_optional(self): | ||
| delta = StreamDelta.model_validate({"content": "Hello"}) | ||
| self.assertIsNone(delta.reasoning_content) | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.