라이브러리 이용해서 템플릿 설정이 가능하다.
from langchain.prompts import PromptTemplate, ChatPromptTemplate
string_prompt = PromptTemplate.from_template("tell me a joke about {subject}")
string_prompt_value = string_prompt.format_prompt(subject="soccer")
from_template : template 설정
format_prompt : subject에 무엇이 들어갈지 설정
to_string : String 으로 변환가능
SystemMessagePromptTemplate
HumanMessagePromptTemplate
둘 다 동일하게 사용하면 됨.
Example Selecter를 활용해서 원하는 답변을 할 수 있도록 예시를 작성하고, 답변의 형태를 동적으로 형태를 바꿔서 출력할 수 있다.
옵션 설정 :
k : 예시를 몇 개 까지 출력할지
출력되는 형태를 고정할 수 있다. List, Json 형태 등.
https://www.youtube.com/watch?v=y6D5Hn_k4lE&t=4s
https://colab.research.google.com/drive/1wF8zTDDUdmq59RXYLOprje3yrpP8z9Pv?usp=sharing