-
Notifications
You must be signed in to change notification settings - Fork 22
Feature/235 connector implementation inheritance upstage #463
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
base: main
Are you sure you want to change the base?
Feature/235 connector implementation inheritance upstage #463
Conversation
- Add UpstageConnector class inheriting from LanguageModelConnector - Implement EnsureLanguageModelSettingsValid() with BaseUrl, ApiKey, Model validation - Implement GetChatClientAsync() using OpenAI SDK with custom endpoint for Upstage API - Add Upstage case to LanguageModelConnector.CreateChatClientAsync() factory method - Leverage OpenAI SDK compatibility since Upstage API follows OpenAI format - Enable connection to Upstage Solar AI models through the application Partially resolves aliencube#235
- Added test/OpenChat.PlaygroundApp.Tests/Connectors/UpstageConnectorTests.cs - Covers configuration validation, error handling, and ChatClient creation for Upstage connector - Ensures reliability and correct behavior for Upstage integration
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.
- 일단 Connector와 테스트 코드 먼저 리뷰하겠습니다.
- 테스트가 더 추가돼야 합니다.
UpstageConnector
가LanguageModelConnector
를 상속하는지에 대한 테스트- 테스트해야 하는 메소드는 총 3개입니다.
EnsureLanguageModelSettingsValid()
GetChatClientAsync()
LanguageModelConnector.CreateChatClientAsync()
이 내용 한 번 봐보시죠.
#447 (comment)
test/OpenChat.PlaygroundApp.Tests/Connectors/UpstageConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/UpstageConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/UpstageConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/UpstageConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/UpstageConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/UpstageConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/UpstageConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/UpstageConnectorTests.cs
Outdated
Show resolved
Hide resolved
…rTests - Add private const fields for BaseUrl, ApiKey, and Model - Replace hardcoded strings in BuildAppSettings method with constants - Improve code maintainability and consistency
…ouldly pattern - Replace Assert.Throws<T>() with Action.ShouldThrow<T>() for sync methods - Replace Assert.ThrowsAsync<T>() with Func<Task>.ShouldThrow<T>() for async methods - Remove async/await keywords from test methods using Shouldly pattern - Improve test readability with fluent API and method chaining - Ensure tests actually execute methods instead of just checking exceptions This addresses the bug where tests were not properly testing method execution and aligns with best practices for exception testing using Shouldly framework.
…ance-upstage - Merge latest changes from upstream repository - Includes HuggingFace connector implementation - UI improvements for ChatInput and ChatMessageItem components - Documentation updates and new connector guides - E2E tests for ChatInput IME functionality - Infrastructure updates for Azure deployment
- Add test to verify UpstageConnector inherits from LanguageModelConnector - Add using statement for OpenChat.PlaygroundApp.Abstractions namespace - Implement Theory test with InlineData for both inheritance directions: - LanguageModelConnector.IsAssignableFrom(UpstageConnector) should be true - UpstageConnector.IsAssignableFrom(LanguageModelConnector) should be false - Ensures proper polymorphism and type safety in connector architecture - Validates adherence to Liskov Substitution Principle
UpstageConnector가 LanguageModelConnector를 상속하는지에 대한 테스트가 ae18a9b에서 추가되었습니다 |
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.
Exception 테스트 관련 수정 내용을 봤는데, Act & Assert
로 묶은 이유가 있나요?
아래 처럼 분리할 수 있을 것 같은데요.
// Act
Action action = () => MethodToTest();
// Assert
action.ShouldThrow<SomethingException>()
.Message.ShouldContain("something message");
이 부분도 더 보완돼야 합니다. |
@sikutisa 기간이 지나서 없어졌는데 appsettings쪽 변수명 settings로 되어 있는건 그대로 유지하면 되는건가요? |
네. 일단 다른 커넥터랑 맞추시죠. |
- Add test for GetChatClientAsync() with null settings scenario - Add test for LanguageModelConnector.CreateChatClientAsync() success case - Add test for LanguageModelConnector.CreateChatClientAsync() failure case - Complete test coverage for all public methods: * EnsureLanguageModelSettingsValid() - 5 test cases * GetChatClientAsync() - 5 test cases * CreateChatClientAsync() - 2 test cases * Inheritance relationship - 1 test case - Ensure proper exception handling and validation logic - Use Shouldly pattern for consistent and readable assertions
…ions - Separate combined '// Act & Assert' comments into individual sections - Improve test readability following AAA (Arrange-Act-Assert) pattern - Apply changes to 9 test methods across all test categories: * EnsureLanguageModelSettingsValid() tests (4 methods) * GetChatClientAsync() tests (4 methods) * CreateChatClientAsync() tests (1 method) - Maintain existing test logic while enhancing code structure - Better alignment with unit testing best practices
넵 분리하였습니다 |
…nException - Change expected exception type from NullReferenceException to InvalidOperationException in GetChatClientAsync test - Fix test to match actual exception behavior when Upstage settings is null - All UpstageConnector tests now pass (23/23 successful)
UpstageConnector 테스트 케이스 정리 (총 13개)1. 상속 관계 테스트 (1개)
2.
|
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.
같은 메소드에 대한 테스트끼리 모아 놓는 게 좋을 것 같습니다.
올려주신 댓글 순서대로 맞춰도 될 것 같은데요?
test/OpenChat.PlaygroundApp.Tests/Connectors/UpstageConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/UpstageConnectorTests.cs
Outdated
Show resolved
Hide resolved
…lity - Group GetChatClient related tests together in logical sections - Maintain all existing test functionality and coverage - Improve test file structure and maintainability - No changes to test logic or assertions
- Convert single Fact test to Theory with multiple test cases - Add comprehensive validation for all required settings: ApiKey, BaseUrl, Model - Test null value handling for each parameter individually - Ensure proper InvalidOperationException thrown with specific error messages - Improve test coverage from 1 to 3 validation scenarios Changes: - Replace Given_Invalid_Settings_When_CreateChatClientAsync_Invoked_Then_It_Should_Throw Fact with Theory - Add InlineData for apiKey, baseUrl, and model null validation - Use switch expression for dynamic AppSettings creation - Verify exception type and message content for each case
…attern - Update exception message validation to match OpenAI connector format - Change "Upstage" to "Missing configuration: Upstage." for EnsureLanguageModelSettingsValid - Add specific message validation "Missing configuration: Upstage:ApiKey." for GetChatClientAsync null settings - Improve consistency across connector error messages - Enhance test robustness by validating both exception type and specific message content Benefits: - Consistent error message format across all connectors - More descriptive error messages for better debugging - Follows established OpenAI connector pattern - Better test coverage with message content validation
…entAsync - Expand test coverage from 3 to 12 test cases for CreateChatClientAsync validation - Add empty string ("") validation for all parameters (apiKey, baseUrl, model) - Add whitespace validation (" ") for all parameters - Add mixed whitespace validation ("\t\n\r") for all parameters - Ensure robust handling of null, empty, and whitespace-only values - Maintain consistent InvalidOperationException with specific error messages Enhanced test scenarios: - apiKey: null, "", " ", "\t\n\r" → InvalidOperationException: "Upstage:ApiKey" - baseUrl: null, "", " ", "\t\n\r" → InvalidOperationException: "Upstage:BaseUrl" - model: null, "", " ", "\t\n\r" → InvalidOperationException: "Upstage:Model" Benefits: - Comprehensive validation coverage for all invalid input types - Better protection against configuration errors in production - Consistent with other connector validation patterns
- Change nullValue to invalidValue in CreateChatClientAsync test method - Better reflects comprehensive test coverage including null, empty strings, and whitespace variations - Improves code clarity and test intent documentation
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.
이제 Bicep 작업 시작하시면 될 것 같습니다!
Purpose
Does this introduce a breaking change?
Pull Request Type
What kind of change does this Pull Request introduce?
README updated?
The top-level readme for this repo contains a link to each sample in the repo. If you're adding a new sample did you update the readme?
How to Test
What to Check
Other Information
Resolves #235