-
Notifications
You must be signed in to change notification settings - Fork 1
chore(api): [GSK-4308] Rename any Conversation mention to ChatTestCase #52
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
henchaves
merged 17 commits into
main
from
feature/gsk-4308-rename-any-conversation-mention-to-chattestcase-testcase
Jun 13, 2025
Merged
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
957c5b9
Add chat test case resources and data classes using chat test case APIs
Inokinoki b39bf96
Improve code quality
Inokinoki a4879d9
Add comments to temporarily disable similarity check in conversations…
Inokinoki 89ce190
Add test to check consistency of conv and chat test case
Inokinoki ce967a1
Add @property to `chat_test_cases` in `Dataset`
Inokinoki 3998c44
Add tests for conversations in evaluations
Inokinoki 7381826
Merge branch 'main' of github.com:Giskard-AI/giskard-hub into feature…
Inokinoki c3de7cc
Remove fixme
Inokinoki d6f3a7a
Merge branch 'main' of github.com:Giskard-AI/giskard-hub into feature…
Inokinoki 6a487bb
Merge branch 'main' of github.com:Giskard-AI/giskard-hub into feature…
Inokinoki 56dca7f
Update after merging
Inokinoki 0cf674b
Move back utility functions
Inokinoki bab4a5f
Update src/giskard_hub/resources/chat_test_cases.py
Inokinoki 1ab9004
Update src/giskard_hub/resources/chat_test_cases.py
Inokinoki 9d4da28
Update src/giskard_hub/resources/chat_test_cases.py
Inokinoki 90e2ee2
Update src/giskard_hub/resources/chat_test_cases.py
Inokinoki 8b334de
Update src/giskard_hub/resources/chat_test_cases.py
henchaves 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass, field | ||
| from typing import Any, Dict, List, Optional, Union | ||
|
|
||
| from giskard_hub.data.check import CheckConfig, TestCaseCheckConfig | ||
|
|
||
| from ._entity import Entity | ||
| from .chat import ChatMessage, ChatMessageWithMetadata | ||
|
|
||
|
|
||
| def _format_checks_to_cli( | ||
| checks: List[Union[TestCaseCheckConfig, Dict[str, Any]]], | ||
| ) -> List[CheckConfig]: | ||
| if not checks: | ||
| return [] | ||
|
|
||
| checks = [check if isinstance(check, dict) else check.to_dict() for check in checks] | ||
|
|
||
| return [ | ||
| CheckConfig.from_dict( | ||
| { | ||
| "identifier": check["identifier"], | ||
| "enabled": check["enabled"], | ||
| **( | ||
| {"params": params} | ||
| if check.get("assertions") | ||
| and ( | ||
| params := { | ||
| k: v | ||
| for k, v in check["assertions"][0].items() | ||
| if k != "type" | ||
| } | ||
| ) | ||
| else {} | ||
| ), | ||
| } | ||
| ) | ||
| for check in checks | ||
| ] | ||
|
|
||
|
|
||
| @dataclass | ||
| class ChatTestCase(Entity): | ||
| """A Dataset entry representing a chat test case. | ||
|
|
||
| Attributes | ||
| ---------- | ||
| messages : List[ChatMessage] | ||
| List of messages in the chat test case. Each message is an object with a role and content attributes. | ||
| demo_output : Optional[ChatMessageWithMetadata], optional | ||
| Output of the agent for demonstration purposes. | ||
| tags : List[str], optional | ||
| List of tags for the chat test case. | ||
| checks : List[TestCaseCheckConfig], optional | ||
| List of checks to be performed on the chat test case. | ||
| """ | ||
|
|
||
| messages: List[ChatMessage] = field(default_factory=list) | ||
| demo_output: Optional[ChatMessageWithMetadata] = field(default=None) | ||
| tags: List[str] = field(default_factory=list) | ||
| checks: List[CheckConfig] = field(default_factory=list) | ||
|
|
||
| @classmethod | ||
| def from_dict(cls, data: Dict[str, Any], **kwargs) -> "ChatTestCase": | ||
| # Process messages | ||
| messages = [] | ||
| if data.get("messages"): | ||
| messages = [ChatMessage.from_dict(msg) for msg in data["messages"]] | ||
|
|
||
| # Process demo_output | ||
| demo_output = None | ||
| if data.get("demo_output"): | ||
| demo_output = ChatMessageWithMetadata.from_dict(data["demo_output"]) | ||
|
|
||
| # Process checks | ||
| checks = _format_checks_to_cli(data.get("checks", [])) | ||
|
|
||
| # Create the object with processed data | ||
| obj = super().from_dict( | ||
| { | ||
| **data, | ||
| "messages": messages, | ||
| "demo_output": demo_output, | ||
| "checks": checks, | ||
| }, | ||
| **kwargs, | ||
| ) | ||
|
|
||
| return obj | ||
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
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.