Cortex Code CLI 워크플로 예제

이 항목에서는 Cortex Code CLI를 최대한 활용하는 데 도움이 되는 일반적인 작업에 대한 워크플로 예제를 제공합니다. 데이터 검색, 합성 데이터 생성, 대시보드 구축, Cortex Agent 생성에 대해 다룹니다.

사용 사례: 데이터 검색 및 쿼리

이 섹션에서는 합성 데이터 세트를 만들고 기본 분석을 수행하여 대시보드를 생성하는 방법을 안내합니다.

Snowflake 계정에 연결

cortex -c <your-demo-account>
Copy

또는 대화형으로 연결합니다.

> connect to <my demo account>
Copy

데이터 검색 및 탐색

데이터 카탈로그를 검색하고, 계보를 이해하고, 관련 테이블을 찾습니다.

> Find all tables related to customers that I have write access to
Copy

올바른 권한이 있는 올바른 역할이 있는지 확인

> What privileges does my role have on this database?
Copy

액세스 문제를 진단하고 역할 권한을 이해합니다.

> Why am I getting a permissions error?
Copy

합성 데이터 생성

다음은 다양한 사용 사례에 대한 합성 데이터를 생성하는 몇 가지 예제입니다.

핀테크 회사의 사기 분석:

> Generate realistic looking synthetic data into <database name>. Create a table of 10000
  financial transactions where ~0.5% of them are fraudulent. Include Amount, Location,
  Merchant, and Time. Make the fraudulent ones look suspicious based on location or amount.
Copy

제약 실험 데이터:

> Make a dummy dataset for a clinical trial of a new blood pressure medication. List 100
  patients, their age, their dosage group (Placebo vs. 10mg), and their blood pressure
  readings over 4 weeks.
Copy

고객 이탈 데이터:

> Create a customer churn dataset for a telecom company showing customer usage for 100000
  customers. Include basic demographic data such as fake names, phone numbers, US city and
  state. Also include data usage (GB), call minutes, contract length, and whether they
  cancelled their service (churn). Ensure there's a customer_id column that's unique.
  Create the data locally and then upload it to Snowflake.
Copy

이 데이터에 대한 기본 쿼리 수행

> Calculate the Churn Rate grouped by state and contract length. Order the results by the
  highest churn rate first so I can see the most risky regions and contract types.
Copy
> I want to identify the heaviest data users who are also churning.
Copy

대화형 대시보드 빌드

차트, 필터, 상호 작용 기능을 사용하여 Streamlit 앱을 만들고 배포합니다.

원하는 대시보드 예제를 열고(또는 온라인에서 찾아서) 클립보드에 복사합니다. 이미지를 디자인 참조로 Cortex Code(Ctrl+V)에 직접 붙여넣을 수 있습니다.

> Build an interactive Streamlit dashboard on this data with state filters and use the
  conversation so far for examples of the kinds of charts to show. Use the attached image
  as a template for visuals and branding.
Copy

대시보드가 작동하고 보기에 좋은지 확인한 후 Snowflake에 업로드합니다.

> Ensure that the Streamlit app will work with Snowflake and upload it to Snowflake.
  Give me a link to access the dashboard when it's done.
Copy

축하합니다! 이제 생성한 데이터 세트를 표시하는 작동하는 Streamlit 대시보드를 생성했습니다.

사용 사례: Cortex Agent 빌드하기

이 섹션에서는 Snowflake Intelligence의 데이터에 대한 질문에 답변하기 위해 Cortex Agent를 생성하는 과정을 안내합니다. 고객 통화 스크립트로 기존 합성 데이터를 보강합니다.

Cortex Analyst용 의미 체계 모델 생성

해당 데이터에 Cortex Analyst를 사용할 수 있도록 의미 체계 뷰를 생성합니다. 모든 질문에 기본값을 사용합니다.

> Write a Semantic View named DEMO_TELECOM_CHURN_ANALYTICS for Cortex Analyst based on
  this data. Use the semantic-view optimization skill.
Copy

Cortex Search Service 생성

먼저, 고객 서비스 호출이 포함된 합성 데이터를 생성합니다.

> Generate a new table called customer_call_logs. Generate 50 realistic customer service
  transcripts (2-3 sentences each) as PDF files. Some should be angry complaints about
  coverage, others should be questions about billing. Then use the AI_PARSE_DOCUMENT
  function to extract the text and layout information from the PDFs into the TRANSCRIPT_TEXT
  column. Split text into chunks for better search quality.
Copy

그런 다음, 스크립트를 인덱싱하는 Cortex Search Service를 생성합니다.

> Create a Cortex Search Service named CALL_LOGS_SEARCH that indexes these transcripts.
  It should index the TRANSCRIPT_TEXT column and filter by CUSTOMER_ID.
Copy

Cortex 에이전트 생성

Analyst 및 Search 서비스를 모두 사용하는 Cortex Agent를 빌드합니다.

> Build a Cortex Agent that has access to two tools:
  - cortex_analyst: For querying the TELECOM_CUSTOMERS SQL table.
  - cortex_search: For searching the CALL_LOGS_SEARCH service.

  Write a system prompt for this agent:
  - Persona: You are a Senior Retention Specialist.
  - Routing Logic: If the user asks for 'metrics', 'counts', or 'averages', use the
    Analyst tool. If the user asks for 'sentiment', 'reasons', or 'summaries of calls',
    use the Search tool.
  - Output Format: Always verify the customer ID before answering. If the risk score is
    high, end the response with a recommended retention offer (e.g., 'Offer 10% discount').
  - Constraint: Never reveal the raw CHURN_RISK_SCORE to the user; interpret it as 'Low',
    'Medium', or 'High'.
Copy

Snowflake Intelligence에 추가

Snowflake Intelligence에 에이전트를 배포합니다.

> Let's deploy this agent to Snowflake Intelligence.
Copy

축하합니다! Snowflake Intelligence 에이전트를 생성하고 배포했습니다.

이제 Snowflake Intelligence에서 이 에이전트에 액세스하여 다음과 같은 질문을 할 수 있습니다.

  • “고객이 통화 중에 무엇에 대해 불평해?”

  • “월 요금이 $100를 초과하는 고위험 고객을 보여줘”

참고 항목

Cortex Code CLI

설치 및 첫 번째 프롬프트 시작하기

스킬

의미 체계 모델, 에이전트 및 문서에 대한 전문 스킬

Cortex Analyst

Cortex Analyst 설명서