더북(TheBook)

examples/5_multiturn.py

(전략)
response1 = llm.invoke(history)
print("1번:", response1.content)
history.append(AIMessage(content=response1.content))
history.append(HumanMessage(content="더 쉽게 설명해줄 수 있어?"))
response2 = llm.invoke(history)
print("2번:", response2.content)

모델은 이전 대화 내용을 함께 전달받았기 때문에 양자컴퓨터를 기준으로 이어서 설명할 수 있습니다. 대화를 더 이어가려면 같은 방식으로 메시지를 계속 추가합니다.

examples/5_multiturn.py

(전략)
history.append(AIMessage(content=response2.content))
history.append(HumanMessage(content="현재 어느 단계까지 발전했어?"))
response3 = llm.invoke(history)
print("3번:", response3.content)