> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ko/llms.txt # AI 채용 담당자 구축 이 가이드에서는 Mastra가 LLM을 사용하여 Workflow를 구축하는 데 어떻게 도움이 되는지 알아봅니다. 후보자의 이력서에서 정보를 수집한 다음 후보자의 프로필을 기반으로 기술 또는 행동 질문으로 분기하는 Workflow를 만듭니다. 그 과정에서 Workflow 단계를 구성하고, 분기를 처리하고, LLM 호출을 통합하는 방법을 알게 됩니다. ## 전제조건 - Node.js`v22.13.0` or later installed - 지원되는 API 키[Model Provider](https://mastra.zisheng.pro/ko/models) - 기존 Mastra 프로젝트(다음을 따르세요.[installation guide](https://mastra.zisheng.pro/ko/guides/getting-started/quickstart) to set up a new project) ## Workflow 구축 Workflow를 설정하고, 후보 데이터를 추출 및 분류하는 단계를 정의한 후 적절한 후속 질문을 하세요. 1. 새 파일 만들기`src/mastra/workflows/candidate-workflow.ts` and define your workflow: ```ts import { createWorkflow, createStep } from '@mastra/core/workflows' import { z } from 'zod' export const candidateWorkflow = createWorkflow({ id: 'candidate-workflow', inputSchema: z.object({ resumeText: z.string(), }), outputSchema: z.object({ askAboutSpecialty: z.object({ question: z.string(), }), askAboutRole: z.object({ question: z.string(), }), }), }).commit() ``` 2. 이력서 텍스트에서 후보자 세부 정보를 추출하고 해당 사람을 "기술적" 또는 "비기술적"으로 분류하려고 합니다. 이 단계에서는 LLM을 호출하여 이력서를 구문 분석하고 이름, 기술 상태, 전문 분야 및 원래 이력서 텍스트를 포함하여 구조화된 JSON을 반환합니다. 을 통해 정의`inputSchema` you get access to the `resumeText` inside `execute()`. 이를 사용해 LLM에 Prompt를 전달하고 구조화된 필드를 반환합니다. 기존에`src/mastra/workflows/candidate-workflow.ts` file add the following: ```ts import { Agent } from '@mastra/core/agent' const recruiter = new Agent({ id: 'recruiter-agent', name: 'Recruiter Agent', instructions: `You are a recruiter.`, model: 'openai/gpt-5.6-sol', }) const gatherCandidateInfo = createStep({ id: 'gatherCandidateInfo', inputSchema: z.object({ resumeText: z.string(), }), outputSchema: z.object({ candidateName: z.string(), isTechnical: z.boolean(), specialty: z.string(), resumeText: z.string(), }), execute: async ({ inputData }) => { const resumeText = inputData?.resumeText const prompt = `Extract details from the resume text: "${resumeText}"` const res = await recruiter.generate(prompt, { structuredOutput: { schema: z.object({ candidateName: z.string(), isTechnical: z.boolean(), specialty: z.string(), resumeText: z.string(), }), }, }) return res.object }, }) ``` 내부에서 채용 Agent를 사용하고 있기 때문에`execute()` 을 사용하려면 step 위에 정의하고 필요한 import를 추가해야 합니다. 3. 이 단계에서는 "기술적"으로 식별된 후보자에게 자신의 전문 분야에 어떻게 진출했는지에 대한 자세한 정보를 요청합니다. LLM이 관련 후속 질문을 작성할 수 있도록 전체 이력서 텍스트를 사용합니다. 기존에`src/mastra/workflows/candidate-workflow.ts` file add the following: ```ts const askAboutSpecialty = createStep({ id: 'askAboutSpecialty', inputSchema: z.object({ candidateName: z.string(), isTechnical: z.boolean(), specialty: z.string(), resumeText: z.string(), }), outputSchema: z.object({ question: z.string(), }), execute: async ({ inputData: candidateInfo }) => { const prompt = `You are a recruiter. Given the resume below, craft a short question for ${candidateInfo?.candidateName} about how they got into "${candidateInfo?.specialty}". Resume: ${candidateInfo?.resumeText}` const res = await recruiter.generate(prompt) return { question: res?.text?.trim() || '' } }, }) ``` 4. 후보자가 "비기술적"인 경우 다른 후속 질문을 원합니다. 이 단계에서는 전체 이력서 텍스트를 다시 참조하여 해당 역할에 대해 가장 관심 있는 것이 무엇인지 묻습니다. 그만큼`execute()` 함수는 LLM에 특정 역할에 초점을 맞춘 쿼리를 요청합니다. 기존에`src/mastra/workflows/candidate-workflow.ts` file add the following: ```ts const askAboutRole = createStep({ id: 'askAboutRole', inputSchema: z.object({ candidateName: z.string(), isTechnical: z.boolean(), specialty: z.string(), resumeText: z.string(), }), outputSchema: z.object({ question: z.string(), }), execute: async ({ inputData: candidateInfo }) => { const prompt = `You are a recruiter. Given the resume below, craft a short question for ${candidateInfo?.candidateName} asking what interests them most about this role. Resume: ${candidateInfo?.resumeText}` const res = await recruiter.generate(prompt) return { question: res?.text?.trim() || '' } }, }) ``` 5. 이제 후보자의 기술 상태에 따라 분기 논리를 구현하는 단계를 결합합니다. Workflow는 먼저 후보자 데이터를 수집한 다음, 상황에 따라 전문성이나 역할에 대해 묻습니다.`isTechnical`. This is done by chaining `gatherCandidateInfo` with `askAboutSpecialty` and `askAboutRole`. 기존에`src/mastra/workflows/candidate-workflow.ts` file change the `candidateWorkflow` like so: ```ts export const candidateWorkflow = createWorkflow({ id: 'candidate-workflow', inputSchema: z.object({ resumeText: z.string(), }), outputSchema: z.object({ askAboutSpecialty: z.object({ question: z.string(), }), askAboutRole: z.object({ question: z.string(), }), }), }) .then(gatherCandidateInfo) .branch([ [async ({ inputData: { isTechnical } }) => isTechnical, askAboutSpecialty], [async ({ inputData: { isTechnical } }) => !isTechnical, askAboutRole], ]) .commit() ``` 6. 당신의`src/mastra/index.ts` file, register the workflow: ```ts import { Mastra } from '@mastra/core' import { candidateWorkflow } from './workflows/candidate-workflow' export const mastra = new Mastra({ workflows: { candidateWorkflow }, }) ``` ## Workflow 테스트 내부에서 작업 흐름을 테스트할 수 있습니다.[Studio](https://mastra.zisheng.pro/ko/docs/studio/overview) by starting the development server: ```bash mastra dev ``` 사이드바에서 다음으로 이동합니다.**Workflows** and select **candidate-workflow**. 중앙에는 Workflow의 그래프 보기가 표시되고 오른쪽 사이드바에는 **Run** 탭이 기본적으로 선택되어 있습니다. 이 탭에서 다음과 같은 이력서 텍스트를 입력할 수 있습니다: ```text Knowledgeable Software Engineer with more than 10 years of experience in software development. Proven expertise in the design and development of software databases and optimization of user interfaces. ``` 이력서 내용을 입력한 후**Run** button. You should now see two status boxes (`GatherCandidateInfo` and `AskAboutSpecialty`)에는 Workflow step의 출력이 포함됩니다. 호출하여 프로그래밍 방식으로 Workflow를 테스트할 수도 있습니다.[`.createRun()`](https://mastra.zisheng.pro/ko/reference/workflows/workflow-methods/create-run) and [`.start()`](https://mastra.zisheng.pro/ko/reference/workflows/run-methods/start). Create a new file `src/test-workflow.ts` and add the following: ```ts import { mastra } from './mastra' const run = await mastra.getWorkflow('candidateWorkflow').createRun() const res = await run.start({ inputData: { resumeText: 'Knowledgeable Software Engineer with more than 10 years of experience in software development. Proven expertise in the design and development of software databases and optimization of user interfaces.', }, }) // Dump the complete workflow result (includes status, steps and result) console.log(JSON.stringify(res, null, 2)) // Get the workflow output value if (res.status === 'success') { const question = res.result.askAboutRole?.question ?? res.result.askAboutSpecialty?.question console.log(`Output value: ${question}`) } ``` 이제 Workflow를 실행하고 터미널에 출력을 가져옵니다. ```bash npx tsx src/test-workflow.ts ``` 이력서를 분석하고 후보자의 기술적 능력에 따라 어떤 질문을 할지 결정하는 Workflow를 구축했습니다. 축하하고 즐거운 해킹되세요!