Google Cloud 에서 Duet AI 사용해 보기

Duet AI

Duet AI는 Google에서 개발한 생성형 AI 도구로, 다양한 사용자 그룹에게 맞춤형 AI 기능을 제공합니다. 개발자, 데이터 과학자, 운영자 등 Google Cloud의 AI 기반 협업을 지원하며, 이 글에서는 Qwiklab에서 제공하는 “Duet AI in Google Cloud” 실습을 통해 Duet AI의 핵심 기능들을 탐구하고, 그 가격 및 다양한 활용 사례들을 살펴볼 것입니다. 관심 있는 분들은 글의 마지막 부분에서 실습 링크를 찾으실 수 있습니다.

가능한 활용 사례

  1. 채팅(자연어)을 통해 관련 문서와 CLI 명령어 그리고 아키텍쳐에 대한 도움을 받을 수 있습니다.
  2. Cloud Logging 에서 메트릭 찾기
  3. BigQuery에 자연어로 SQL 완성
  4. Google Colab(jupiter notebook)에서 소스코드 추천 및 데이터 분석 가능
  5. 개발자의 경우 copilot 처럼 IDE 에서 AI 코드 추천 및 자동완성 assistant 기능을 지원합니다.

사전 작업 및 실습 예제

Duet AI 활성화

Google Cloud 의 오른쪽 위에 “Open Duet AI” 아이콘을 클릭합니다.

이때 오른쪽에 Duet AI 패널이 열리는데 ENBLE 을 클릭해 주시면 Deut AI 를 사용할 준비가 완료됩니다.


API 활성 (Option)
위에서 ENABLE 만으로 사용이 가능했으나, 아래와 같이 Cloud Shell에서 활성화하셔도 됩니다.

duet ai api 활성화 (Enable the Cloud AI Companion API for Duet AI)

gcloud services enable cloudaicompanion.googleapis.com --project ${PROJECT_ID}

Service Account 에 IAM 권한 부여 (Option)

gcloud projects add-iam-policy-binding ${PROJECT_ID} --member user:${USER} --role=roles/cloudaicompanion.user
gcloud projects add-iam-policy-binding ${PROJECT_ID} --member user:${USER} --role=roles/serviceusage.serviceUsageViewer

1. 문서 및 가이드 도움

채팅을 통해 공식 가이드 문서를 안내 해달라고 하거나, 리소스 생성/수정/삭제/조회 CLI 명령어를 알려달라고 하여 도움을 받을 수 있습니다.

아래에 실습에 있는 예제로 GKE(Google kubernetes Engine)을 어떻게 만들고 kubernetes를 잘 몰라도 예제 pod들을 어떻게 배포하고 서비스할 수 있는지 kubectl 명령어를 알려주어 실제로 전문가가 아니여도 어플리케이션을 Google Cloud를 통해 애플리케이션을 잘 배포할 수 있도록 도와줍니다.

(공식 문서 예시)
채팅창에 GKE를 만들기 위해서 아래처럼 질문하고 GKE를 어떻게 만드는지 도움을 얻을 수 있습니다.
이때 공식문서를 알려달라고 하면 링크를 줍니다.

deut ai 의 ui에서 프롬프트를 통해 채팅으로 GKE를 어떻게 생성하는지 물어보면 Web Console 화면의 UI를 통한 방법을 안내해 줍니다.

How can I run Kubernetes on Google Cloud without having to own management of nodes and the control plane?

Network, GKE, VM , 보안등 Chat GPT 에게 물어보듯이 물어보며 Google Cloud 안에서 활용할 수 있습니다.
한국어로 물어보아도 한국어로 잘 답변해 줍니다.

(CLI 명령어를 통한 GKE 생성)
이번엔 GKE를 생성하는 CLI 를 물어보고 Gcloud SDK 명령어를 안내받았으며, 클릭한번으로 Cloud Shell에서 실행할 수 있게 자동으로 입력해 줍니다.

Kubernetes를 잘 몰라도 pod을 어떻게 배포하는지, 서비스하는지 kubectl 명령어를 알려줍니다.
(질문)

Can you give me a gcloud command to create my first Cloud Build private pool?

(답변)

Sure. To create a Cloud Build private pool, run the following gcloud command: gcloud builds worker-pools create PRIVATEPOOL_ID --config-from-file PRIVATEPOOL_CONFIG_FILE --region REGION where: • PRIVATEPOOL_ID is a unique identifier for your private pool. • PRIVATEPOOL_CONFIG_FILE is the name of your private pool config file. • REGION is the region where you want to create your private pool.

이외에도 Deploy, Service 등을 물어보면서 Google Cloud의 서비스를 Duet AI와 대화를 통해서 구축 할 수 있습니다. 

2. Cloud Logging에서 검색할 메트릭 찾기

Cloud Logging에서 log를 검색할 때도 Duet AI를 통해서 도움을 받을 수 있습니다. MQL(Monitoring Query Language)에 익숙하지 않으신 분들이라면 log 확인 조차 어려울 수 있습니다. Duet AI를 통해서 MQL을 안내 받을 수 있습니다.

What is a Logs Explorer query to search for logs from Pods in a namespace called "default" in a GKE cluster named "test"?

GKE 중에서 namespace 가 default이면서 cluster이름에 test 인 log들을 찾는다고 물어보면 아래와 어떻게 MQL 해야 할지 안내해 줍니다.

resource.type="k8s_container"
resource.labels.namespace_name="default"
resource.labels.cluster_name="test"

MQL로 원하는 Logs Explorer에서 Logging을 볼 수 있습니다.

3. SQL 자동 완성 도움

자연어로 SQL를 완성할 수 있으며, SQL에 블록을 지정하고 Duet AI에게 설명을 요청할 수 있습니다.
Generate a SQL query with help from Duet AI

 SELECT SUM(PRICE_PER_UNIT * QUANTITY_SOLD_AUG_5) AS total_aug_5 FROM `Google Cloud Project ID.cymbal_sales.cymbalsalestable`;

의 Query 에서 아래 처럼 입력하면 사용자가 원하는 SQL를 제공합니다.

# Get sales total_aug_12

4. Colab(Notebook)에서 사용

dataframe의 10행까지 보여 달라고 자연어로 prompt 에 입력을 해서 결과를 얻을 수도 있습니다.

산점도 (Scatter plot) 그래프를 그려달라고 말할수도 있습니다.

prompt 엔지니어링을 통해서 원하는 결과를 얻을 수 있습니다.

#prompt:  Use the Vertex AI language_models API to call the PaLM2 text-bison model and generate a marketing campaign using the variable prompt. Use the following model settings: max_output_tokens=1024, temperature=0.4

model = TextGenerationModel.from_pretrained("text-bison")
response = model.predict(prompt, max_output_tokens=1024, temperature=0.4)
print(response.text)

(output)

Cluster 1:
Title: "The Occasional Shoppers"
Persona: These customers are likely to be sporadic shoppers who make infrequent purchases. They may be attracted to discounts or promotions, and they may be more likely to purchase items that are on sale.
Next marketing step: Offer discounts or promotions to entice these customers to make more frequent purchases.


Cluster 2:
Title: "The Loyal Customers"
Persona: These customers are likely to be loyal to your brand and make repeat purchases. They may be more likely to spend more money on each purchase and be less likely to be swayed by competitors' offerings.
Next marketing step: Reward these customers for their loyalty with a loyalty program or exclusive discounts.


Cluster 3:
Title: "The Lapsed Customers"
Persona: These customers have not made a purchase in a long time. They may have been lost to a competitor or simply lost interest in your brand.
Next marketing step: Reach out to these customers with a special offer or promotion to win them back.


Cluster 4:
Title: "The Bargain Hunters"
Persona: These customers are likely to be motivated by price and are more likely to purchase items that are on sale. They may be less loyal to your brand and more likely to switch to a competitor if they find a better deal.
Next marketing step: Offer discounts or promotions to entice these customers to make more frequent purchases.


Cluster 5:
Title: "The Power Buyers"
Persona: These customers are likely to be your most valuable customers. They spend the most money and make the most frequent purchases. They may be more likely to be brand advocates and refer your brand to others.
Next marketing step: Reward these customers for their loyalty with a loyalty program or exclusive discounts. Additionally, ask them to refer your brand to their friends and family.

5. 구글 Cloud Workstation 에서 IDE 생성

Duet AI for Developers는 copilot처럼 주석을 통해 소스 코드를 구현할 수 있으며, 대화를 통해서 개발 보조도구 및 배포까지 사용할 수 있습니다.
IDE를 사용하시려면 “Cloud Workstation”를 생성하셔야 합니다. 생성방법은 Google Cloud 콘솔에서 Cloud Workstations 메뉴로 진입하셔서 아래의 순서로 생성합니다. 2024년 2월 1일까지 무료인데 너무 늦게 알아버렸습니다.

1. Create a workstation configuration
2. Create a workstation
IDE 설정에서 Duet AI를 활성화 해주고 Google Cloud 와 연동을 설정을 해주어야 합니다.

왼쪽 하단의 duet AI 아이콘을 누르시고 Cloud Run 과 Cloud Function 을 비교해달라고 했는데 표로 잘 보여 줍니다.
편집기에서 소스코드에 드래그해서 explain을 누르면 설명해줍니다

duet AI를 통해서 JSON을 만들어 달라고 한 뒤 “+”을 누르면 에디터 창으로 바로 입력됩니다.

IDE의 장점은 작성한 코드를 바로 Cloud Run에 바로 배포 할 수 있다는 점입니다.
바로 빌드하면 배포된 public 주소를 얻을 수 있습니다.

Duet AI 장점

Google Cloud 내부에서 private 하게 대화형 AI라서 아래와 같은 장점이 있습니다. 구글에서 만든 제품이라서 Google Cloud 의 최신 공식문서나 아키텍쳐등을 도움 받을 수 있습니다.

  • 실수로 내부 ip등 정보를 입력 할 경우에 유출된 가능성이 없습니다.
  • 버튼을 통해 쉽게 접근 가능합니다.
  • 비용 (개발자를 위한 Duet AI외에는 대화형 AI 는 무료로 유지할 가능성이 높아 보입니다)
  • Google Cloud 내부에 있기 때문에 Cloud Run등 으로 APP 배포가 용이합니다.

실습가능한 skill boost (Qwiklab)

아래의 링크에서 Duet AI를 실습할 수 있습니다. 마지막 실습 Duet AI for end-to-end SDLC 에는 종합적인 실습이 다 들어가 있습니다.
실습을 통해서 AI의 도움을 받아 어떻게 우리의 업무를 편하게 운영하고 서비스를 이용할 수 있을지 경험해 보시면 좋을 것 같습니다.

https://www.cloudskillsboost.google/paths/236 (Duet AI in Google Cloud)

  • Duet AI for Application Developers
  • Duet AI for Cloud Architects
  • Duet AI for Data Scientists and Analysts
  • Duet AI for Network Engineers
  • Duet AI for Security Engineers
  • Duet AI for DevOps Engineers
  • Duet AI for end-to-end SDLC (software development lifecycle)

참고링크

https://cloud.google.com/duet-ai/?hl=ko#ai-assisted-application-development

https://cloud.google.com/blog/ko/products/application-modernization/introducing-duet-ai-for-google-cloud

가격

Google Cloud (Web Console)에 사용하는 prompt 까지도 유료가 되는지는 확실하지 않지만 Duet AI UI에서 Enable 만 하면 되는 것으로 봐서 Duet ai를 이용한 자연어 채팅은 당분간 무료가 되지 않을까 추측합니다.

Duet AI for Developers는 현재 사용이 되어 무료인 줄 알았는데 2월 1일까지 프로모션 기간으로 무료로 사용가능하며 개발자용 Duet AI 는 1년 약정시에 매월 $19 입니다.
IDE를 Google Cloud 내부에서 사용할 경우 Cloud Workstation을 구성해야 하기 때문인것 같습니다.

더 자세한 정보는 참고 링크에서 확인 할 수 있습니다.
참고 링크 : https://cloud.google.com/duet-ai/pricing?hl=ko

총평

Google Cloud 에서 운영을 할 때 메뉴얼을 찾는 시간과 gcloud sdk 명령어 작성시간이 줄 것 같습니다.
저는 작년에 gcloud sdk 명령어를 쉽게 만들어 주는 Tools을 colab에서 만든 적이 있습니다. 리소스 관리 (생성 / 조회 / 삭제 / 수정) 등을 보다 쉽게 작성 할 수 있을것 같습니다. 이 글에는 다루지 않았지만 보안적인 것도 Duet AI에게 물어보면 GKE 에서 control plane authorized 를 사용하라고 권장도 해줍니다. 그리고 Network 아키텍쳐나 방화벽적인 부분에서도 도움을 주는 실습이 있습니다.

운영하는 분들이나 처음 접하시는 분들도 Duet AI의 도움을 받는다면 개발자는 개발에 집중을 , 분석가는 분석에 집중을 할 수 있고 DevOps 엔지니어들은 GPT 보다 내부 IP , 네이밍정보등을 실수로 입력 하더라도 안전할 것이며 Google Cloud 를 위해서 만들었기 때문에 다른 타사 제품들 보다 정확도가 높을 것입니다.

주의 할 점은 Duet AI를 통해서 얻은 Query 라던지 CLI 명령어등은 한번 더 확인하고 실행하는 습관이 필요합니다.
긴글 읽어주셔서 감사드립니다.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top