시작하기무료로 시작하기

순차 체인을 위한 프롬프트 만들기

다음 몇 가지 연습 문제에서는 사람들이 새로운 기술을 학습하도록 돕는 시스템을 만들어요. 이 시스템은 학습자가 자신의 선호와 제약에 따라 계획을 수정할 수 있도록 순차적으로 구축되어야 합니다. LangChain LCEL 역량을 활용해 이 시스템을 위한 순차 체인을 만들 것이고, 첫 단계는 이 시스템에서 사용할 프롬프트 템플릿을 설계하는 것입니다.

이 연습은 강의의 일부입니다

LangChain으로 LLM 애플리케이션 개발하기

강의 보기

연습 안내

  • "activity" 입력을 받아 학습 계획을 만드는 learning_prompt라는 프롬프트 템플릿을 만드세요.
  • "learning_plan" 입력을 받아 이를 일주일 안에 맞도록 수정하는 time_prompt라는 프롬프트 템플릿을 만드세요.
  • 원하는 활동으로 learning_prompt를 호출하세요(아이디어가 떠오르지 않으면 "play golf"를 사용해 보세요).

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Create a prompt template that takes an input activity
learning_prompt = PromptTemplate(
    input_variables=["____"],
    template="I want to learn how to {activity}. Can you suggest how I can learn this step-by-step?"
)

# Create a prompt template that places a time constraint on the output
time_prompt = PromptTemplate(
    ____,
    template="I only have one week. Can you create a plan to help me hit this goal: {learning_plan}."
)

# Invoke the learning_prompt with an activity
print(learning_prompt.____({"activity": "____"}))
코드 편집 및 실행