Skip to content

Commit

Permalink
Eval qr json lines now has context from both turns and category if it…
Browse files Browse the repository at this point in the history
… exists (#38199)

* Update task_query_response.prompty

remove required keys

* Update task_simulate.prompty

* Update task_query_response.prompty

* Update task_simulate.prompty

* Fix the api_key needed

* Update for release

* Black fix for file

* Add original text in global context

* Update test

* Update the indirect attack simulator

* Black suggested fixes

* Update simulator prompty

* Update adversarial scenario enum to exclude XPIA

* Update changelog

* Black fixes

* Remove duplicate import

* Fix the mypy error

* Mypy please be happy

* Updates to non adv simulator

* accept context from assistant messages, exclude them when using them for conversation

* update changelog

* pylint fixes

* pylint fixes

* remove redundant quotes

* Fix typo

* pylint fix

* Update broken tests

* Include the grounding json in the manifest

* Fix typo

* Come on package

* Release 1.0.0b5

* Notice from Chang

* Remove adv_conv template parameters from the outputs

* Update chanagelog

* Experimental tags on adv scenarios

* Readme fix onbreaking change

* Add the category and both user and assistant context to the response of qr_json_lines

* Update changelog

---------

Co-authored-by: Nagkumar Arkalgud <[email protected]>
Co-authored-by: Nagkumar Arkalgud <[email protected]>
Co-authored-by: Nagkumar Arkalgud <[email protected]>
  • Loading branch information
4 people authored Oct 30, 2024
1 parent 0bd332e commit 0029c5e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions sdk/evaluation/azure-ai-evaluation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Breaking Changes

### Bugs Fixed
- Output of adversarial simulators are of type `JsonLineList` and the helper function `to_eval_qr_json_lines` now outputs context from both user and assistant turns along with `category` if it exists in the conversation

### Other Changes
- Refined error messages for serviced-based evaluators and simulators.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,41 @@ def to_eval_qr_json_lines(self):
for item in self:
user_message = None
assistant_message = None
context = None
user_context = None
assistant_context = None
template_parameters = item.get("template_parameters", {})
category = template_parameters.get("category", None)
for message in item["messages"]:
if message["role"] == "user":
user_message = message["content"]
user_context = message.get("context", "")
elif message["role"] == "assistant":
assistant_message = message["content"]
if "context" in message:
context = message.get("context", None)
assistant_context = message.get("context", "")
if user_message and assistant_message:
if context:
if user_context or assistant_context:
json_lines += (
json.dumps({"query": user_message, "response": assistant_message, "context": context})
json.dumps(
{
"query": user_message,
"response": assistant_message,
"context": str(
{
"user_context": user_context,
"assistant_context": assistant_context,
}
),
"category": category,
}
)
+ "\n"
)
user_message = assistant_message = context = None
user_message = assistant_message = None
else:
json_lines += json.dumps({"query": user_message, "response": assistant_message}) + "\n"
json_lines += (
json.dumps({"query": user_message, "response": assistant_message, "category": category})
+ "\n"
)
user_message = assistant_message = None

return json_lines
Expand Down

0 comments on commit 0029c5e

Please sign in to comment.