지난 우먼 잇츠 스터디 3기에 이어 4기 스터디도 신청하게 되었다. 이번에는 구글 스터디 잼 프로그램을 통해 온라인으로 Gemini, Vertex AI, 생성형 AI를 공부하고 Google Cloud를 학습하려고 한다.
Gemini for Google Cloud Learning Path
Google Cloud를 위한 Gemini 학습 과정에서는 엔지니어들이 Gemini를 활용하여 업무를 효율적으로 처리할 수 있는 방법을 실습한다. 애플리케이션 개발, API 호출, 데이터 쿼리 등의 작업을 Gemini와의 채팅을 통해 코드를 자동으로 작성하거나 코드를 설명해주거나 한다.
애플리케이션 개발자, 클라우드 아키텍처, 데이터 사이언티스트 & 애널리스트, 네트워크 엔지니어, 보안 엔지니어, DevOps 엔지니어, SDLC(Software Development Life Cycle)를 위한 Gemini 통해 다양한 분야에서 Gemini를 어떻게 사용하는지 간단하게 실습해 보았다.
Develop GenAI Apps with Gemini and Streamlit
마지막 과정에서는 Gemini API를 사용하여 Text Generation를 위해 프롬프트를 입력하는 여러가지 방법과 Cloud Shell을 사용해 Streamlit 애플리케이션을 테스트하고 반복하는 방법, Streamlit 애플리케이션을 Cloud Run에 배포된 Docker 컨테이너로 패키징하는 방법을 배울 수 있다.
Develop GenAI Apps with Gemini and Streamlit: Challenge Lab
해당 과정의 챌린지 실습으로 텍스트, 오디오, 이미지, 동영상을 생성하는 멀티모달 모델인 Gemini의 기능을 활용하여 고객을 위한 식단 추천을 생성하는 애플리케이션을 빌드해야 한다. 고객의 음식 선호도, 식이 제한사항, 식품 알레르기, 주로 집에 있는 재료 또는 식료품점에서 구매할 수 있는 재료를 기반으로 레시피를 생성하는 AI 기반 셰프 앱을 만든다고 가정을 하고, Gemini 모델, Streamlit 프레임워크, Cloud Run을 기반으로 빌드된 이 셰프 앱의 개념 증명(PoC)을 빌드, 테스트, 배포해야한다.
수행해야 할 작업으로는 다음과 같다.
- cURL을 사용하여 API로 프롬프트 테스트
- Streamlit 프레임워크를 작성하고 chef.py를 완성하도록 Python 코드 프롬프트 입력
- 애플리케이션 테스트
- Dockerfile 수정 및 Artifact Registry로 Docker 이미지 내보내기
- Cloud Run에 애플리케이션 배포 및 테스트
Google Jam에 설명되어있지 않은 커맨드 및 실습 과정을 기록해두고자 한다.
2.6 For Project ID, use Project ID, and for Location, use Region.
2.7 Add Streamlit framework radio button option for the wine variable. Include options for Red, White and None.
2.9 Add the new Gemini prompt below in Python code.
3.1 Setup the python virtual environment and install the dependencies.
export PROJECT_ID=$(gcloud config get-value project)
gcloud storage cp chef.py gs://$PROJECT_ID-generative-ai/
cd generative-ai/gemini/sample-apps/gemini-streamlit-cloudrun
python3 -m venv gemini-streamlit
source gemini-streamlit/bin/activate
pip install -r requirements.txt
3.2 Set environment variables for PROJECT (as your Project ID) and REGION (as the region you are using in the lab environment).
PROJECT='qwiklabs-gcp-03-d83b26a201eb'
REGION='us-east4'
3.3 Run the chef.py application and test it.
streamlit run chef.py \
--browser.serverAddress=localhost \
--server.enableCORS=false \
--server.enableXsrfProtection=false \
--server.port 8080
4.1 Use the Cloud Shell editor to modify the Dockerfile to use chef.py, then save the file.
ENTRYPOINT ["streamlit", "run", "chef.py", "--server.port=8080", "--server.address=0.0.0.0"]
4.2 In Cloud Shell set the following environment variables.
AR_REPO='chef-repo'
SERVICE_NAME='chef-streamlit-app'
4.3 Create the Artifact Registry repository with the gcloud artifacts repositories create command and the following parameters.
gcloud artifacts repositories create "$AR_REPO" --location="$REGION" --repository-format=Docker
4.4 Submit the build with the gcloud builds submit command and the following parameters.
gcloud builds submit --tag "$REGION-docker.pkg.dev/$PROJECT/$AR_REPO/$SERVICE_NAME"
5.1 In Cloud Shell deploy the application (as a Docker Artifact), using gcloud run deploy command and the following parameter values
gcloud run deploy "$SERVICE_NAME" \
--port=8080 \
--image="$REGION-docker.pkg.dev/$PROJECT/$AR_REPO/$SERVICE_NAME" \
--allow-unauthenticated \
--region=$REGION \
--platform=managed \
--project=$PROJECT \
--set-env-vars=PROJECT=$PROJECT,REGION=$REGION
느낀점
기존에는 새롭거나 다른 분야의 개발을 진행할 때, 기술 문서 읽거나 튜토리얼을 통해 스킬을 습득했다면 Gemini를 통해 간편하고 빠르게 코드를 작성할 수 있다는 점이 가장 큰 장점으로 다가왔다.
뿐만 아니라, Google Workstations IDE를 통해 별도의 IDE를 설치하지 않아도 되고 Google Cloud, Gemini Code Assist 플러그인 지원으로 코드 작성과 앱 개발이 편리했다.