-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add Google Vertex AI connector implementation #454
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?
feat: add Google Vertex AI connector implementation #454
Conversation
@hxcva1 |
네 감사합니다! 주말 간에는 작업이 어려울 것 같아 다음주 중으로 Readme 제외한 부분 작업해서 리뷰 받도록 하겠습니다 |
저도 확인한 내용을 공유드립니다. 저희가 사용하는 패키지는 다음과 같이 크게 세 가지 방식으로 구글 AI를 사용할 수 있습니다. // GeminiClient 사용
IChatClient chatClient = new GeminiChatClient(settings!.ApiKey!, settings!.Model!);
return await Task.FromResult(chatClient).ConfigureAwait(false);
// VertexAI 사용
var vertexAI = new VertexAI(projectId: settings!.ProjectId!, region: settings!.Region!);
var model = vertexAI.GenerativeModel(model: settings!.Model!);
model.AccessToken = settings!.AccessToken!;
return await Task.FromResult(model.AsIChatClient()).ConfigureAwait(false);
// GoogleAI 사용
var googleAI = new GoogleAI(accessToken: settings!.AccessToken!);
var model = googleAI.GenerativeModel(model: settings.Model!);
return await Task.FromResult(model.AsIChatClient()).ConfigureAwait(false); 인증방식도 ApiKey, AccessToken, OAuth 다양한 방식이 있었는데, 개인적으로 지난 래블업 발표를 준비하며 이 Google VertexAI Connector가 가장 어려웠습니다. 제가 참고한 문서들은 다음과 같습니다.
이만 물러갑니다. 화이팅 !! |
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.
- 일단
GeminiChatClient
사용하는 것으로 작업하시면 됩니다. 이러면 GCP에서 Google Vertex AI가 아니라 Google Gemini API 로 연결 될 거에요. - 테스트가 더 추가돼야 합니다.
GoogleVertexAIConnector
가LanguageModelConnector
를 상속하는지에 대한 테스트- 테스트해야 하는 메소드는 총 3개입니다.
EnsureLanguageModelSettingsValid()
GetChatClientAsync()
LanguageModelConnector.CreateChatClientAsync()
이 내용 한 번 봐보시죠.
#447 (comment)
{ | ||
ConnectorType.GitHubModels => new GitHubModelsConnector(settings), | ||
ConnectorType.OpenAI => new OpenAIConnector(settings), | ||
ConnectorType.GoogleVertexAI => new GoogleVertexAIConnector(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 순서로 맞추는 게 맞는 것 같습니다.
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.
수정했습니다!
|
||
public class GoogleVertexAIConnectorTests | ||
{ | ||
private static AppSettings BuildAppSettings(string? apiKey = "AIzaSyA1234567890abcdefgHIJKLMNOpqrstuv", string? model = "test-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.
이거 apiKey 실제 키는 아니죠?
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.
그리고 magic string은 상수 처리하는 게 괜찮아 보이네요.
private const string ApiKey
private const string 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.
실제 apiKey는 아닙니다. 상수 처리했습니다!
var ex = Assert.Throws(expectedType, () => connector.EnsureLanguageModelSettingsValid()); | ||
|
||
// Assert | ||
ex.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.
얘도 #451 참고해보시죠
var ex = Assert.Throws(expectedType, () => connector.EnsureLanguageModelSettingsValid()); | ||
|
||
// Assert | ||
ex.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.
얘도 #451 참고해보시죠
var ex = Assert.Throws<InvalidOperationException>(() => connector.EnsureLanguageModelSettingsValid()); | ||
|
||
// Assert | ||
ex.Message.ShouldContain("GoogleVertexAI"); |
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.
#451 내용 보시고 수정하는 건 어떨까요?
var ex = await Assert.ThrowsAsync(expected, connector.GetChatClientAsync); | ||
|
||
ex.Message.ShouldContain(message); |
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.
얘도 #451 참고해보시죠
var ex = await Assert.ThrowsAsync(expected, connector.GetChatClientAsync); | ||
|
||
ex.Message.ShouldContain(message); |
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.
얘도 #451 참고해보시죠
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