-
Notifications
You must be signed in to change notification settings - Fork 25
fix: decouple mocking from evals #1148
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
Merged
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,9 @@ | |
| from datetime import datetime | ||
| from typing import Any | ||
|
|
||
| from uipath._cli._evals._models._evaluation_set import EvaluationItem | ||
| from uipath._cli._evals.mocks.types import ( | ||
| InputMockingStrategy, | ||
| ) | ||
| from uipath.platform import UiPath | ||
| from uipath.tracing import traced | ||
|
|
||
|
|
@@ -54,8 +56,10 @@ def get_input_mocking_prompt( | |
|
|
||
| @traced(name="__mocker__", recording=False) | ||
| async def generate_llm_input( | ||
| evaluation_item: EvaluationItem, | ||
| mocking_strategy: InputMockingStrategy, | ||
| input_schema: dict[str, Any], | ||
| expected_behavior: str, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make this |
||
| expected_output: dict[str, Any], | ||
| ) -> dict[str, Any]: | ||
| """Generate synthetic input using an LLM based on the evaluation context.""" | ||
| from .mocks import cache_manager_context | ||
|
|
@@ -68,18 +72,12 @@ async def generate_llm_input( | |
| if "additionalProperties" not in input_schema: | ||
| input_schema["additionalProperties"] = False | ||
|
|
||
| expected_output = ( | ||
| getattr(evaluation_item, "evaluation_criterias", None) | ||
| or getattr(evaluation_item, "expected_output", None) | ||
| or {} | ||
| ) | ||
|
|
||
| prompt_generation_args = { | ||
| "input_schema": json.dumps(input_schema), | ||
| "input_generation_instructions": evaluation_item.input_mocking_strategy.prompt | ||
| if evaluation_item.input_mocking_strategy | ||
| "input_generation_instructions": mocking_strategy.prompt | ||
| if mocking_strategy | ||
| else "", | ||
| "expected_behavior": evaluation_item.expected_agent_behavior or "", | ||
| "expected_behavior": expected_behavior or "", | ||
| "expected_output": json.dumps(expected_output), | ||
| } | ||
|
|
||
|
|
@@ -94,11 +92,7 @@ async def generate_llm_input( | |
| }, | ||
| } | ||
|
|
||
| model_parameters = ( | ||
| evaluation_item.input_mocking_strategy.model | ||
| if evaluation_item.input_mocking_strategy | ||
| else None | ||
| ) | ||
| model_parameters = mocking_strategy.model if mocking_strategy else None | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line can be removed -- mocking_strategy cannot be |
||
| completion_kwargs = ( | ||
| model_parameters.model_dump(by_alias=False, exclude_none=True) | ||
| if model_parameters | ||
|
|
||
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 |
|---|---|---|
| @@ -1,25 +1,25 @@ | ||
| """Mocker Factory.""" | ||
|
|
||
| from uipath._cli._evals._models._evaluation_set import ( | ||
| EvaluationItem, | ||
| LLMMockingStrategy, | ||
| MockitoMockingStrategy, | ||
| ) | ||
| from uipath._cli._evals.mocks.llm_mocker import LLMMocker | ||
| from uipath._cli._evals.mocks.mocker import Mocker | ||
| from uipath._cli._evals.mocks.mockito_mocker import MockitoMocker | ||
| from uipath._cli._evals.mocks.types import ( | ||
| LLMMockingStrategy, | ||
| MockingContext, | ||
| MockitoMockingStrategy, | ||
| ) | ||
|
|
||
|
|
||
| class MockerFactory: | ||
| """Mocker factory.""" | ||
|
|
||
| @staticmethod | ||
| def create(evaluation_item: EvaluationItem) -> Mocker: | ||
| def create(context: MockingContext) -> Mocker: | ||
| """Create a mocker instance.""" | ||
| match evaluation_item.mocking_strategy: | ||
| match context.strategy: | ||
| case LLMMockingStrategy(): | ||
| return LLMMocker(evaluation_item) | ||
| return LLMMocker(context) | ||
| case MockitoMockingStrategy(): | ||
| return MockitoMocker(evaluation_item) | ||
| return MockitoMocker(context) | ||
| case _: | ||
| raise ValueError("Unknown mocking strategy") |
Oops, something went wrong.
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.