Skip to content

Conversation

hxcva1
Copy link
Contributor

@hxcva1 hxcva1 commented Sep 16, 2025

Purpose

  • ...

Does this introduce a breaking change?

[ ] Yes
[ ] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[ ] New feature
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

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?

[ ] Yes
[ ] No
[ ] N/A

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
  • Test the code

What to Check

Verify that the following are valid

  • ...

Other Information

@sikutisa
Copy link
Contributor

@hxcva1
작업 다 끝나시면 Ready for review로 전환해주시면 되고, 지금 다른 유사한 이슈들 보면 Readme 작업이 병목지점인 것 같습니다.
일단 코드 로직이랑 bicep 먼저 리뷰하고, 그 이후에 Readme 작업하는게 좋을 것 같아요.

@hxcva1
Copy link
Contributor Author

hxcva1 commented Sep 19, 2025

네 감사합니다! 주말 간에는 작업이 어려울 것 같아 다음주 중으로 Readme 제외한 부분 작업해서 리뷰 받도록 하겠습니다

@hxcva1 hxcva1 marked this pull request as ready for review September 23, 2025 11:42
@tae0y
Copy link
Member

tae0y commented Sep 25, 2025

저도 확인한 내용을 공유드립니다.

저희가 사용하는 패키지는 다음과 같이 크게 세 가지 방식으로 구글 AI를 사용할 수 있습니다.
이중에 VertexAI 클래스를 사용하면 Google Vertex AI로 요청이 잘 들어가고,
그외 클래스 경우 VertexAI는 아니고 다른 Google의 서비스를 사용합니다.

// 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 다양한 방식이 있었는데,
저는 그중에 ApiKey(위 패키지에서는 사용이 막힘)와 AccessToken(1시간 동안 유효)을 사용해보았습니다.
revoke하기 전까지 유효한 인증키를 만들려면 OAuth가 필요한 것 같은데 관련 문서를 찾아봐야할 것 같아요.

개인적으로 지난 래블업 발표를 준비하며 이 Google VertexAI Connector가 가장 어려웠습니다.
Google쪽 어떤 설정을 해줘야할지, 설정 방법은 어떻고, 리전별 실제 사용가능한 모델 목록은 어떤건지..
하나하나 문서를 찾는게 참 어렵더라구요.

제가 참고한 문서들은 다음과 같습니다.

이만 물러갑니다. 화이팅 !!

Copy link
Contributor

@sikutisa sikutisa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 일단 GeminiChatClient 사용하는 것으로 작업하시면 됩니다. 이러면 GCP에서 Google Vertex AI가 아니라 Google Gemini API 로 연결 될 거에요.
  2. 테스트가 더 추가돼야 합니다.
  • GoogleVertexAIConnectorLanguageModelConnector를 상속하는지에 대한 테스트
  • 테스트해야 하는 메소드는 총 3개입니다.
    • EnsureLanguageModelSettingsValid()
    • GetChatClientAsync()
    • LanguageModelConnector.CreateChatClientAsync()

이 내용 한 번 봐보시죠.
#447 (comment)

{
ConnectorType.GitHubModels => new GitHubModelsConnector(settings),
ConnectorType.OpenAI => new OpenAIConnector(settings),
ConnectorType.GoogleVertexAI => new GoogleVertexAIConnector(settings),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#155 순서로 맞추는 게 맞는 것 같습니다.

Copy link
Contributor Author

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 apiKey 실제 키는 아니죠?

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

실제 apiKey는 아닙니다. 상수 처리했습니다!

Comment on lines +48 to +51
var ex = Assert.Throws(expectedType, () => connector.EnsureLanguageModelSettingsValid());

// Assert
ex.Message.ShouldContain(expectedMessage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

얘도 #451 참고해보시죠

Comment on lines +66 to +69
var ex = Assert.Throws(expectedType, () => connector.EnsureLanguageModelSettingsValid());

// Assert
ex.Message.ShouldContain(expectedMessage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

얘도 #451 참고해보시죠

Comment on lines +30 to +33
var ex = Assert.Throws<InvalidOperationException>(() => connector.EnsureLanguageModelSettingsValid());

// Assert
ex.Message.ShouldContain("GoogleVertexAI");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#451 내용 보시고 수정하는 건 어떨까요?

Comment on lines +107 to +109
var ex = await Assert.ThrowsAsync(expected, connector.GetChatClientAsync);

ex.Message.ShouldContain(message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

얘도 #451 참고해보시죠

Comment on lines +120 to +122
var ex = await Assert.ThrowsAsync(expected, connector.GetChatClientAsync);

ex.Message.ShouldContain(message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

얘도 #451 참고해보시죠

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connector Implementation & Inheritance: Google Vertex AI
3 participants