-
Notifications
You must be signed in to change notification settings - Fork 18
Add support for bidirectional streaming within eval service. #370
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
erinlimbogoogle
wants to merge
3
commits into
main
Choose a base branch
from
erinbranch
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import json | ||
| import copy | ||
|
|
||
|
|
||
| class EvalCortadoRequest: | ||
| def __init__(self, raw_dict: dict, job_id: str = "", trace_id: str = ""): | ||
| """ | ||
| Initializes an EvalCortadoRequest from a parsed JSON dictionary. | ||
| """ | ||
| # Store the raw dictionary so process_scenario can read max_turns and the plan | ||
| self.scenario = raw_dict | ||
|
|
||
| # Extract top-level identification | ||
| self.id = str(raw_dict.get("id", "-1")) | ||
| self.job_id = job_id | ||
| self.trace_id = trace_id | ||
|
|
||
| # Evalbench core routing needs these to match the YAML | ||
| self.dialect = raw_dict.get("dialect", "") | ||
| self.dialects = [self.dialect] | ||
| self.database = raw_dict.get("database", "") | ||
| self.nl_prompt = raw_dict.get("starting_prompt", "") | ||
|
|
||
| # Ensure the stringified payload is ready for the gRPC Proxy | ||
| self.payload_str = json.dumps(raw_dict) | ||
| self.payload = self.payload_str | ||
|
|
||
| self.agent_results = [] | ||
| self.scoring_results = [] | ||
|
|
||
| @classmethod | ||
| def init_from_proto(cls, proto): | ||
| """Unpacks the Protobuf from Google3 back into the object.""" | ||
| payload_str = getattr(proto, "payload", "{}") | ||
| try: | ||
| raw_dict = json.loads(payload_str) | ||
| except json.JSONDecodeError: | ||
| raw_dict = {} | ||
|
|
||
| raw_dict["id"] = str(getattr(proto, "id", "-1")) | ||
|
|
||
| return cls( | ||
| raw_dict=raw_dict, | ||
| job_id=getattr(proto, "job_id", ""), | ||
| trace_id=getattr(proto, "trace_id", ""), | ||
| ) | ||
|
|
||
| def to_proto(self): | ||
| """Packs the object into the Protobuf to send to Google3.""" | ||
| # Note: You must import eval_request_pb2 here to prevent circular dependencies | ||
| from evalproto import eval_request_pb2 | ||
|
|
||
| return eval_request_pb2.EvalInputRequest( | ||
| id=int(self.id) if self.id.isdigit() else 0, | ||
| payload=self.payload_str, | ||
| # We map starting_prompt to nl_prompt for backwards compatibility | ||
| nl_prompt=self.nl_prompt | ||
| ) | ||
|
|
||
| def copy(self): | ||
| return copy.deepcopy(self) |
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 |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ message DialectBasedSQLStatements { | |
|
|
||
| message EvalInputRequest { | ||
| int64 id = 1; | ||
| string conversation_id = 18; | ||
|
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. should be sorted by id |
||
| string nl_prompt = 2; | ||
| string query_type = 3; | ||
| string database = 4; | ||
|
|
@@ -29,6 +30,7 @@ message EvalInputRequest { | |
| string sql_generator_error = 12; | ||
| float sql_generator_time = 13; | ||
| string generated_sql = 14; | ||
| string generated_nl_response = 19; | ||
|
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. same |
||
| string job_id = 15; | ||
| string trace_id = 16; | ||
| string payload = 17; | ||
|
|
||
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
Oops, something went wrong.
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.
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.
If a client connection drops forcefully or hangs, and the Interact RPC does not hit its finally block cleanup (or if the thread hangs indefinitely
blocked on inbound_response = thread_inbox.get(block=True, timeout=300.0) ), then that entry in PROXY_QUEUES will leak and remain in memory even
after the background reaper deletes the session from Disk/SessionManager!
we should clear it when the session gets deleted.