안녕하세요, 즐로그 운영자입니다!
이번 포스트에서는 실무자 입장에서 자주 쓰이는 AI·자동화 도구들의 핵심 사용 가이드와 즉시 활용 가능한 코드 스니펫을 한 번에 모아봤습니다.
“어디서부터 손대야 할지” 막막할 때, 여기 있는 예제를 복사해 붙여넣기만 하면 바로 테스트해볼 수 있어요~ 😉
⸻
📋 목차
1. ChatGPT API 기본 호출 가이드
2. Vertex AI AutoML 빠른 시작
3. Azure Form Recognizer OCR 활용
4. UiPath RPA 스크립트 예제
5. Python 모니터링 에이전트
⸻
1️⃣ ChatGPT API 기본 호출 가이드
목적: ChatGPT 모델에 프롬프트 보내고 응답 받기
• 환경: Python 3.8+, openai 패키지
import os
import openai
# 1) 환경 변수 세팅 (bash)
# export OPENAI_API_KEY="YOUR_KEY"
# 2) 클라이언트 초기화
openai.api_key = os.getenv("OPENAI_API_KEY")
# 3) 간단 채팅 요청
response = openai.ChatCompletion.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "안녕하세요, 오늘 뉴욕 날씨 어때요?"}
],
max_tokens=100,
temperature=0.7
)
# 4) 응답 출력
print(response.choices[0].message.content)
Tip:
• temperature 0.0–1.0 조정으로 응답 창의성 제어
• max_tokens로 토큰 사용량 제한
⸻
2️⃣ Vertex AI AutoML 빠른 시작
목적: CSV 데이터로 분류 모델 학습→엔드포인트 배포
• 환경: Python 3.8+, google-cloud-aiplatform
from google.cloud import aiplatform
# 1) 초기화
aiplatform.init(project="프로젝트ID", location="us-central1")
# 2) 데이터셋 생성
ds = aiplatform.TabularDataset.create(
display_name="churn_ds",
gcs_source=["gs://버킷/churn.csv"]
)
# 3) AutoML 분류 작업
job = aiplatform.AutoMLTabularTrainingJob(
display_name="churn_job",
optimization_prediction_type="classification",
optimization_objective="roc_auc"
)
model = job.run(
dataset=ds,
target_column="churned",
training_fraction_split=0.8,
validation_fraction_split=0.1,
test_fraction_split=0.1,
budget_milli_node_hours=800
)
# 4) 엔드포인트 배포
endpoint = model.deploy(machine_type="n1-standard-4", min_replica_count=1)
print("엔드포인트 URL:", endpoint.resource_name)
Tip:
• budget_milli_node_hours로 학습 예산 조절
• optimization_objective를 업무 KPI에 맞춰 설정
⸻
3️⃣ Azure Form Recognizer OCR 활용
목적: 스캔된 문서(PDF/JPG)에서 텍스트 추출
• 환경: Python 3.8+, azure-ai-formrecognizer
from azure.ai.formrecognizer import DocumentAnalysisClient
from azure.core.credentials import AzureKeyCredential
# 1) 클라이언트 설정
endpoint = "https://<리전>.api.cognitive.microsoft.com/"
credential = AzureKeyCredential("<YOUR_KEY>")
client = DocumentAnalysisClient(endpoint, credential)
# 2) 문서 분석 시작
poller = client.begin_analyze_document(
"prebuilt-document",
{"url": "https://example.com/invoice.pdf"}
)
result = poller.result()
# 3) 텍스트 라인 출력
for page in result.pages:
for line in page.lines:
print(line.content)
Tip:
• prebuilt-invoice 등 특정 문서 유형 지정 가능
• PDF 내 표·테이블 추출도 지원
⸻
4️⃣ UiPath RPA 스크립트 예제
목적: 웹 로그인→데이터 추출→엑셀 저장
• 환경: UiPath Studio, UiPath Robot
<!-- 워크플로우 예시 (XAML) -->
<Activity mc:Ignorable="sap sap2010" ...>
<Sequence DisplayName="WebToExcel">
<!-- 1. 브라우저 열기 -->
<OpenBrowser Url="https://example.com/login" BrowserType="Chrome" />
<!-- 2. 입력 필드에 자격증명 입력 -->
<TypeInto Selector="username_input" Text="[아이디]" />
<TypeInto Selector="password_input" Text="[비밀번호]" />
<Click Selector="login_button" />
<!-- 3. 데이터 테이블 추출 -->
<ExtractStructuredData Selector="table_selector" OutputDataTable="dt" />
<!-- 4. 엑셀에 쓰기 -->
<ExcelApplicationScope FilePath="output.xlsx">
<WriteRange DataTable="dt" SheetName="Sheet1" />
</ExcelApplicationScope>
</Sequence>
</Activity>
Tip:
• Retry Scope 액티비티로 네트워크 오류 대비
• Queue 와 Transaction 개념 적용해 대량 작업 확장
⸻
5️⃣ Python 모니터링 에이전트
목적: 서비스 헬스체크→자동 재시작→알림
• 환경: Python 3.8+, requests, 시스템 서비스
import time, requests, subprocess, logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
HEALTH_URL = "http://localhost:8000/health"
RETRY_MAX = 3
def monitor():
for i in range(1, RETRY_MAX+1):
try:
r = requests.get(HEALTH_URL, timeout=3)
if r.status_code == 200:
logging.info("서비스 정상")
return
except Exception as e:
logging.warning(f"헬스체크 실패#{i}: {e}")
time.sleep(2**i)
logging.error("자동 복구 실행")
subprocess.run(["systemctl", "restart", "my-service"])
if __name__ == "__main__":
while True:
monitor()
time.sleep(60)
Tip:
• 2**i 식 지수 백오프로 과도 호출 방지
• 복구 실패 시 Slack·메일 연동 알림 추가
⸻
🎉 마무리
지금까지 실무자 관점에서 자주 쓰이는 5가지 AI·자동화 도구의
“핵심 사용 가이드 + 코드 스니펫”을 정리했습니다.
각 예제를 그대로 복사·붙여넣어 즉시 실험해보시고,
필요에 맞게 파라미터만 수정해 활용해보세요!
즐거운 개발·자동화 되시길 바랍니다~ 👋
'IT & Tech 정보' 카테고리의 다른 글
🚀 비동기 작업 큐 처리: Python + Celery + RabbitMQ (0) | 2025.05.25 |
---|---|
🚀 REST API 인증·권한 관리: Node.js + Express + JWT (0) | 2025.05.25 |
🚀 RPA 고도화: 에러 복구·셀프 모니터링 설계 (0) | 2025.05.25 |
OCR·NLP·CV 서비스: Azure vs GCP 활용법 (0) | 2025.05.25 |
AutoML 플랫폼: Vertex AI vs SageMaker 실전 데모 (0) | 2025.05.25 |