-
Notifications
You must be signed in to change notification settings - Fork 21
Connector Implementation & Inheritance: LG AI EXAONE #465
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?
Conversation
test/OpenChat.PlaygroundApp.Tests/Connectors/LGConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/LGConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/LGConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/LGConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/LGConnectorTests.cs
Outdated
Show resolved
Hide resolved
test/OpenChat.PlaygroundApp.Tests/Connectors/LGConnectorTests.cs
Outdated
Show resolved
Hide resolved
@jh941213 머지 컨플릭도 해소해 주세요. 이번에는 리베이스 하다 망하지 마시고 차근차근... |
453 브랜치 생성을 못하고 시작 해서, 그부분은 컨플릭트 수정하고, 이 이슈까진 253 사용하고 인지하고 있겠습니다 |
LanguageModelConnector connector = settings.ConnectorType switch | ||
{ | ||
ConnectorType.GitHubModels => new GitHubModelsConnector(settings), | ||
ConnectorType.LG => new LGConnector(settings), |
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.
#155 보시고 순서 맞춰 넣어주세요.
ConnectorType.GitHubModels => new GitHubModelsConnector(settings), | ||
ConnectorType.LG => new LGConnector(settings), | ||
ConnectorType.HuggingFace => new HuggingFaceConnector(settings), | ||
|
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.
여기에는 빈 줄이 필요 없습니다.
// Validate LG model format: should be HuggingFace format, LG model, or GGUF format | ||
var model = settings.Model.Trim(); | ||
var isHuggingFaceFormat = model.StartsWith("hf.co/") || model.Contains("/"); | ||
var isLGModel = model.ToLowerInvariant().Contains("exaone") || model.ToLowerInvariant().Contains("lg"); | ||
var isGGUFFormat = model.ToLowerInvariant().EndsWith(".gguf") || model.ToLowerInvariant().Contains("gguf"); | ||
|
||
if (!isHuggingFaceFormat && !isLGModel && !isGGUFFormat) | ||
{ | ||
throw new InvalidOperationException("Invalid LG model format. Model should be HuggingFace format (hf.co/...), LG model (containing 'exaone' or 'lg'), or GGUF format (containing 'gguf')."); | ||
} |
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.
이 메소드 하나에서 이 모든 것을 다 validation 하는 것이 좋을까요, 아니면 이 로직은 별도의 private bool
메소드로 빼는 것이 좋을까요? 허깅페이스 커넥터 로직 한 번 보실랍니까?
open-chat-playground/src/OpenChat.PlaygroundApp/Connectors/HuggingFaceConnector.cs
Lines 65 to 85 in b6ec80b
private static bool IsValidModel(string model) | |
{ | |
var segments = model.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); | |
if (segments.Length != 3) | |
{ | |
return false; | |
} | |
if (segments.First().Equals(HuggingFaceHost, StringComparison.InvariantCultureIgnoreCase) == false) | |
{ | |
return false; | |
} | |
if (segments.Last().EndsWith(ModelSuffix, StringComparison.InvariantCultureIgnoreCase) == false) | |
{ | |
return false; | |
} | |
return true; | |
} |
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.
비효율적인거 같습니다 참고하겠습니다
[InlineData("hf.co/LGAI-EXAONE/EXAONE-4.0-1.2B-GGUF")] | ||
[InlineData("LGAI-EXAONE/EXAONE-4.0-1.2B")] | ||
[InlineData("lg-exaone-model")] | ||
[InlineData("exaone-3.0")] | ||
[InlineData("model.gguf")] | ||
[InlineData("exaone-gguf-model")] |
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.
여기 있는 모델들이 다 LG 모델 맞나요?
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.
[Fact] 를 활용해서 단일 엘지 커넥트로 수정하겠습니다
[Trait("Category", "UnitTest")] | ||
[Theory] | ||
[InlineData(null, typeof(NullReferenceException), "Object reference not set to an instance of an object")] | ||
[InlineData("", typeof(InvalidOperationException), "LG:Model")] | ||
[InlineData(" ", typeof(InvalidOperationException), "LG:Model")] | ||
public void Given_Invalid_Model_When_EnsureLanguageModelSettingsValid_Invoked_Then_It_Should_Throw(string? model, Type expectedType, string expectedMessage) | ||
{ | ||
// Arrange | ||
var appSettings = BuildAppSettings(model: model); | ||
var connector = new LGConnector(appSettings); | ||
|
||
// Act | ||
Action action = () => connector.EnsureLanguageModelSettingsValid(); | ||
|
||
// Assert | ||
action.ShouldThrow(expectedType) | ||
.Message.ShouldContain(expectedMessage); | ||
} | ||
|
||
[Trait("Category", "UnitTest")] | ||
[Theory] | ||
[InlineData("invalid-model", typeof(InvalidOperationException), "Invalid LG model format")] | ||
[InlineData("random-name", typeof(InvalidOperationException), "Invalid LG model format")] | ||
[InlineData("test-model", typeof(InvalidOperationException), "Invalid LG model format")] | ||
public void Given_Invalid_Model_Format_When_EnsureLanguageModelSettingsValid_Invoked_Then_It_Should_Throw(string model, Type expectedType, string expectedMessage) | ||
{ | ||
// Arrange | ||
var appSettings = BuildAppSettings(model: model); | ||
var connector = new LGConnector(appSettings); | ||
|
||
// Act | ||
Action action = () => connector.EnsureLanguageModelSettingsValid(); | ||
|
||
// Assert | ||
action.ShouldThrow(expectedType) | ||
.Message.ShouldContain(expectedMessage); | ||
} |
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.
이 테스트 두 개를 따로 놓는 대신 합치면 안되나요?
[Trait("Category", "UnitTest")] | ||
[Theory] | ||
[InlineData(null, typeof(ArgumentNullException))] | ||
[InlineData("", typeof(UriFormatException))] | ||
public void Given_Missing_BaseUrl_When_GetChatClient_Invoked_Then_It_Should_Throw(string? baseUrl, Type expected) | ||
{ | ||
// Arrange | ||
var settings = BuildAppSettings(baseUrl: baseUrl); | ||
var connector = new LGConnector(settings); | ||
|
||
// Act | ||
Func<Task> func = async () => await connector.GetChatClientAsync(); | ||
|
||
// Assert | ||
func.ShouldThrow(expected); | ||
} |
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.
Base URL 값만 테스트했는데, 모델 값도 테스트를 추가해야 합니다.
[Trait("Category", "UnitTest")] | ||
[Fact] | ||
public void Given_Invalid_Settings_When_CreateChatClientAsync_Invoked_Then_It_Should_Throw() | ||
{ | ||
// Arrange | ||
var settings = new AppSettings | ||
{ | ||
ConnectorType = ConnectorType.LG, | ||
LG = new LGSettings | ||
{ | ||
BaseUrl = null, | ||
Model = "lg-exaone-model" | ||
} | ||
}; | ||
|
||
// Act | ||
Func<Task> func = async () => await LanguageModelConnector.CreateChatClientAsync(settings); | ||
|
||
// Assert | ||
func.ShouldThrow<NullReferenceException>(); | ||
} |
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.
invalid 세팅을 테스트하는데, base URL 값과 모델 값을 테스트하려면 [Fact]
대신 [Theory]
를 써서 [InlineData(...)]
를 추가해 보세요.
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
Verify that the following are valid
Other Information
This implementation follows the same pattern as Ollama connector implementation, using OllamaSharp library for LG AI EXAONE integration. The connector:
Key components added:
LGConnector.cs
- Main connector implementationLGConnectorTests.cs
- Comprehensive unit testsLanguageModelConnector.cs
to include LG case in factory methodThe implementation enables users to run LG AI EXAONE models through the OpenChat Playground interface using the same infrastructure as other supported connectors.