Skip to content

[Playground] Refactoring OpenAIApiClient #163 #314

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
merged 14 commits into from
Oct 6, 2024

Conversation

5jisoo
Copy link
Contributor

@5jisoo 5jisoo commented Sep 11, 2024

작업중인 이슈

작업 내용

  1. Program.cs에서 AzureOpenAIClient 싱글톤 등록
    • api key는 임의의 문자열 값으로 설정해두었습니다.
  2. OpenAIApiClient으로 AzureOpenAIClient을 주입
  3. OpenAIApiClientOptions에서 apikey, endpoint 삭제
  4. ChatWindowComponent에서 불필요한 요소 정리

궁금한 점

  1. 지난번 유튜브 요약 실습에서 https+http://apiapp 를 HttpClient의 BaseAddress로 지정해주었던 것과 동일한 방식으로 AzureOpenAIClient의 endpoint를 설정하였는데, 이게 올바른 방향이 맞는지 궁금합니다.
  2. 리팩토링도 테스트 코드가 따로 필요한지 궁금합니다.

Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

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

ChatWndowComponent.razor가 들어있는 Home.razor 파일을 로컬에서 테스트 돌리면 잘 돌아가는지만 확인해 보시지요. 통합테스트 부분은 나중에 따로 처리해야 할 듯.

@justinyoo
Copy link
Contributor

@5jisoo 컨플릭 먼저 해결해 보시구요, 이제부터는 플레이그라운드 페이지에 직접 적용을 시켜볼까요?

@5jisoo
Copy link
Contributor Author

5jisoo commented Sep 13, 2024

작업 내용

  1. Program.cs에서 OpenAIApiClientOptions의 endpoint값을 세팅하여 인젝션하였습니다.
  2. OpenAIApiClient의 CompleteChatAsync에 잠깐 테스트 값 넣어서 돌려봤는데
Unhandled exception rendering component: The 'https+http' scheme is not supported.

다음과 같은 에러가 발생하였고, 아마 Program.cs에서 설정해준 Endpoint 값( https+http://apiapp )에 문제가 있지 않을까 추측해보았지만,, 어떻게 해결할 수 있을지 감이 잡히질 않습니다..

https://apiapp 으로 설정했을 경우엔 다음과 같은 에러가 발생합니다.

System.ClientModel.ClientResultException: nodename nor servname provided, or not known (apiapp:443)

저는 Aspire에서 ApiApp 프로젝트를 등록하면서 https+http://apiapp 으로 엔드포인트를 설정하면 자동으로 ApiApp 프로젝트의 주소로 변경되는 것으로 이해했는데, 아니라면.. 참고할만한 사이트 알려주시면 다시 작업해보겠습니다

@5jisoo
Copy link
Contributor Author

5jisoo commented Sep 22, 2024

일단 수정 사항은 전부 고쳤습니다!
첨부해주신 공식문서 읽어보았는데, Named endpoints쪽이 아직 동일한 에러가 발생하고 있습니다.
계속 찾아보고는 있는데 쉽지 않네요🥲

@justinyoo
Copy link
Contributor

일단 수정 사항은 전부 고쳤습니다! 첨부해주신 공식문서 읽어보았는데, Named endpoints쪽이 아직 동일한 에러가 발생하고 있습니다. 계속 찾아보고는 있는데 쉽지 않네요🥲

정 안되면 HttpClient 인스턴스를 인젝션하고 거기서 BaseUri 값을 받아오는 식의 꼼수를 써야 할 수도 있을 듯 해요.

Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

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

대략의 의견을 남겨봤어요

@5jisoo
Copy link
Contributor Author

5jisoo commented Sep 23, 2024

.... 이렇게 바꾸어도 동일한 에러가 발생합니다

@justinyoo
Copy link
Contributor

.... 이렇게 바꾸어도 동일한 에러가 발생합니다

지수님 리포로 PR 하나 날렸어요: 5jisoo#1

한 번 확인해 보시고, 적용시켜 보세요.

@justinyoo
Copy link
Contributor

지금 OpenAI SDK 가장 최신 버전이 2.1.0-beta.1 입니다. 그거 기준으로 가시지요.

https://www.nuget.org/packages/Azure.AI.OpenAI/2.1.0-beta.1

@justinyoo
Copy link
Contributor

제가 main 브랜치 업데이트해서 컨플릭 날 거예요 @5jisoo 확인해 보시고, 반영시켜 주세요

Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

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

일단 테스트 코드 없이 가 봅시다

@justinyoo justinyoo merged commit 5c99af6 into aliencube:main Oct 6, 2024
1 check passed
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.

[Playground] Refactoring OpenAIApiClient
3 participants