🔥알림🔥
① 테디노트 유튜브 - 구경하러 가기!
② LangChain 한국어 튜토리얼 바로가기 👀
③ 랭체인 노트 무료 전자책(wikidocs) 바로가기 🙌

20 분 소요

이번 포스팅에서는 랭체인(LangChain) 을 활용하여 챗(Chat) 기능 구현을 하는 방법에 대해 알아보겠습니다.

랭체인은 쉽게 대화 흐름(conversation context) 기반 챗 기능구현을 손쉽게 할 수 있는 방법을 제공합니다.


(이전글) LangChain 튜토리얼


🌱 LangChaing + Chat 구성

  • 채팅 모델(Chat Model): LLM을 활용한 대화 흐름(conversation) 을 생성할 수 있습니다.

  • 프롬프트 템플릿(Prompt Template): 프롬프트 템플릿은 기본 메시지, 사용자 입력, 채팅 기록, 문맥(context) 를 결합하여 프롬프트를 쉽게 구성할 수 있게 돕습니다.

  • 메모리(Memory): 대화 흐름에서 대화의 내용을 기록하는 용도입니다.

  • 리트리버(Retriever): 문서의 로드 및 검색을 할 때 활용할 수 있습니다.

🌱 환경설정

라이브러리 설치

# 필요한 라이브러리 설치
# pip install langchain openai 

OPENAI API KEY 를 설정합니다.

import os

os.environ['OPENAI_API_KEY'] = 'OPENAI API KEY 입력'

🔥 챗봇 생성

from langchain.schema import AIMessage, HumanMessage, SystemMessage
from langchain.chat_models import ChatOpenAI

# LLM 생성
chat = ChatOpenAI()

# 실행
chat(
    [HumanMessage(content="다음을 영어로 번역해 줘: 나는 프로그래밍을 정말 좋아해요")]
)
AIMessage(content='I really love programming.', additional_kwargs={}, example=False)

메시지 구성요소

  • SystemMessage: AI 에게 상황을 지정하거나 역할 부여

  • HumanMessage: 사용자 입력 메시기

  • AIMessage: AI 답변 메시지

messages = [
    # SystemMessage: 역할 부여
    SystemMessage(content="너는 한글을 영어로 번역해 주는 전문번역가야."),
    # 질의
    HumanMessage(content="나는 프로그래밍을 정말 좋아해요")
]

# 실행
chat(messages)
AIMessage(content='I really love programming.', additional_kwargs={}, example=False)

같은 질문이라 하더라도, SystemMessage 에 다른 역할을 부여하면 그에 걸맞는 답변을 얻습니다.

messages = [
    # SystemMessage: 역할 부여
    SystemMessage(content="너는 심리를 분석하는 심리 분석가야."),
    # 질의
    HumanMessage(content="나는 프로그래밍을 정말 좋아해요")
]

# 실행
chat(messages)
AIMessage(content='프로그래밍을 좋아하시는 분들은 주로 논리적이고 분석적인 사고력을 가지고 있습니다. 이들은 문제 해결에 대한 열정과 호기심을 가지고 있으며, 복잡한 문제를 해결하는 데에 도전하는 것을 즐깁니다. 또한, 프로그래밍은 창의력을 요구하므로, 이들은 문제에 새로운 접근법을 생각해내고 새로운 아이디어를 구현하는 데에 능숙합니다.\n\n또한, 프로그래밍은 협업이 필요한 분야이기 때문에, 소통과 협력을 잘할 수 있는 능력을 가지고 있는 경우가 많습니다. 다른 사람들과 아이디어를 공유하고 피드백을 주고 받으며, 함께 프로젝트를 완성하는 과정을 즐깁니다.\n\n프로그래밍은 자기계발에 대한 욕구를 충족시키는 분야이기도 합니다. 지속적인 학습과 스스로 개선하는 노력이 필요하기 때문에, 스스로에게 동기를 부여하고 목표를 설정하는 능력을 가지고 있습니다.\n\n이러한 특성들은 프로그래밍을 좋아하는 분들이 현실적이고 목표지향적인 성격을 가질 수 있다는 것을 보여줍니다. 하지만, 이는 개인에 따라 다를 수 있으므로 각 개인의 심리적 특성과 경험을 고려하여 상세한 분석이 필요합니다.', additional_kwargs={}, example=False)
messages = [
    # SystemMessage: 역할 부여
    SystemMessage(content="너는 MBTI 예측가야."),
    # 질의
    HumanMessage(content="나는 프로그래밍을 정말 좋아해요")
]

# 실행
chat(messages)
AIMessage(content='그렇군요! 프로그래밍을 좋아하는 사람들은 다양한 MBTI 유형일 수 있습니다. 그럼 몇 가지 질문을 통해 당신의 성향을 파악해볼까요?\n\n1. 새로운 아이디어나 프로젝트에 대해 빠르게 행동하고 적극적으로 참여하는 편인가요? (예: 새로운 프로그래밍 언어를 배우고 싶을 때, 바로 시작해보는 등)\n2. 프로그래밍을 할 때 세부 사항에 집중하며 꼼꼼하게 작업하는 편인가요? (예: 코드의 문법을 완벽하게 맞추려고 노력하는 등)\n3. 프로젝트를 진행할 때 계획을 세우고 구체적인 일정을 따라가는 편인가요? (예: 일정에 맞춰 기능을 구현하고 테스트하는 등)\n4. 다른 사람들과 협업하는 것을 즐기는 편인가요? (예: 팀 프로젝트를 할 때 다른 팀원들과 의견을 공유하고 협력하는 등)\n5. 문제가 발생했을 때 차분하게 분석하고 해결책을 찾는 편인가요? (예: 버그를 발견했을 때 원인을 파악하고 수정하는 등)\n\n이러한 질문을 통해 당신의 성향을 파악하여 MBTI 유형을 예측해볼 수 있습니다.', additional_kwargs={}, example=False)

🔥 ConversationChain

이전의 채팅 모델을 ConversationChain 으로 감쌀 수 있습니다.

ConversationChain 는 한마디로 (Chat Model + Memory) 이라 정의할 수 있습니다.

이전의 Chat Model 은 대화내용을 저장 혹은 기록하는 작업은 직접해야 합니다. 하지만 ConversationChain 을 활용하면, 자동으로 Memory 에 대화내용을 저장합니다.


즉, ConversationChain 자체가 내장 메모리 를 가지고 있습니다. 따라서, 이전의 대화내용을 기록하는 메모리에 대한 별도 작업을 생략할 수 있습니다.

from langchain.chains import ConversationChain  

# ConversationChain 객체 생성
conversation = ConversationChain(llm=chat)

# 1차 질의
print(conversation.run("다음을 영어로 번역해 줘: 나는 프로그래밍을 정말 좋아해요"))
Sure! The sentence "나는 프로그래밍을 정말 좋아해요" translates to "I really love programming" in English. Programming is a fascinating field that allows you to create and build various applications and software. It requires logical thinking, problem-solving skills, and creativity. If you have any other questions or need further assistance, feel free to ask!

2차 질의를 하면, 이전 대화내용을 바탕으로 답변을 얻습니다.

# 2차 질의
print(conversation.run("나는 운동도 정말 좋아해요"))
That's great to hear! The sentence "나는 운동도 정말 좋아해요" translates to "I also really love exercising" in English. Exercising is an excellent way to stay fit and healthy. It helps improve cardiovascular health, build muscle strength, and enhance overall physical well-being. There are many different types of exercises you can enjoy, such as running, swimming, cycling, weightlifting, and yoga. Is there a specific type of exercise you prefer or any other topic you would like to discuss?

① 템플릿으로 양식 정의

from langchain.memory import ConversationBufferMemory
from langchain.prompts import (
    ChatPromptTemplate,
    MessagesPlaceholder,
    SystemMessagePromptTemplate,
    HumanMessagePromptTemplate,
)
from langchain.chains import LLMChain


# 1) 시스템 설정: 역할부여 정의
system_template = SystemMessagePromptTemplate.from_template("너는 한글을 {language}로 번역해 주는 번역전문가야.")
system_message = system_template.format(language="영어")

# 2) ChatPromptTemplate 템플릿 정의
prompt = ChatPromptTemplate.from_messages([
    system_message,                                              # 역할부여
    MessagesPlaceholder(variable_name="chat_history"),           # 메모리 저장소 설정. ConversationBufferMemory의 memory_key 와 동일하게 설정
    HumanMessagePromptTemplate.from_template("{human_input}"),   # 사용자 메시지 injection
])


# 3) 메모리 정의
# `return_messages=True`를 사용해야 MessagesPlaceholder에 주입됨
# `chat_history`가 MessagesPlaceholder 이름과 일치해야함
memory = ConversationBufferMemory(memory_key="chat_history", 
                                  ai_prefix="번역가",
                                  human_prefix="사용자",
                                  return_messages=True)


# 4) LLM 모델 정의
llm = ChatOpenAI(model_name='gpt-3.5-turbo')

# 5) LLMChain 정의
conversation = LLMChain(
    llm=llm,       # LLM
    prompt=prompt, # Prompt
    verbose=True,  # True 로 설정시 로그 출력
    memory=memory  # 메모리
)

# 6) 실행
answer = conversation({"human_input": "나는 프로그래밍을 정말 좋아해요"})
print(answer['text'])
Entering new LLMChain chain...
Prompt after formatting:
System: 너는 한글을 영어로 번역해 주는 번역전문가야.
Human: 나는 프로그래밍을 정말 좋아해요

Finished chain.
I really love programming.
# 실행 No.2
answer = conversation({"human_input": "손흥민은 대한민국의 축구선수 입니다."})
print(answer['text'])
Entering new LLMChain chain...
Prompt after formatting:
System: 너는 한글을 영어로 번역해 주는 번역전문가야.
Human: 나는 프로그래밍을 정말 좋아해요
AI: I really love programming.
Human: 손흥민은 대한민국의 축구선수 입니다.

Finished chain.
Son Heung-min is a South Korean soccer player.

② 대화내용 초기화

  • 대화 문맥(conversation context)을 초기화 하는 방법은 간단합니다. memoryclear() 함수를 실행하여 초기화 해주면 됩니다.
# 대화목록 출력
memory.load_memory_variables({})
{'chat_history': [HumanMessage(content='나는 프로그래밍을 정말 좋아해요', additional_kwargs={}, example=False),
  AIMessage(content='I really love programming.', additional_kwargs={}, example=False),
  HumanMessage(content='손흥민은 대한민국의 축구선수 입니다.', additional_kwargs={}, example=False),
  AIMessage(content='Son Heung-min is a South Korean soccer player.', additional_kwargs={}, example=False)]}
# 대화내용 초기화
memory.clear()
# 대화목록 출력
memory.load_memory_variables({})
{'chat_history': []}

SystemMessage 는 메모리 초기화 후에도 여전히 적용됩니다.

따라서, 번역을 수행한 결과가 반환됩니다.

# 실행
answer = conversation({"human_input": "손흥민은 대한민국의 축구선수 입니다."})
print(answer['text'])
Entering new LLMChain chain...
Prompt after formatting:
System: 너는 한글을 영어로 번역해 주는 번역전문가야.
Human: 나는 프로그래밍을 정말 좋아해요
AI: I really love programming.
Human: 손흥민은 대한민국의 축구선수 입니다.
AI: Son Heung-min is a South Korean soccer player.
Human: 손흥민은 대한민국의 축구선수 입니다.

Finished chain.
Son Heung-min is a South Korean football player.

③ 대화내용 요약 메모리

ConversationSummaryBufferMemory 는최근의 대화 내용을 메모리에 저장합니다.

다만, 대화가 길어질 경우 이전 대화내용을 모두 포함할 수 없습니다. 따라서, 이전 대화 내용을 삭제하게 되는데, ConversationSummaryBufferMemory 는 완전히 삭제하기보다는 요약 정보로 만듭니다.

이전 대화내용에 대한 요약이 발동하는 시점은 대화의 interaction 횟수가 초과된 경우 혹은 토큰 길이가 초과된 경우를 기준으로 동작합니다.

from langchain.memory import ConversationSummaryBufferMemory
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler


# 1) 시스템 설정: 역할부여 정의
system_template = SystemMessagePromptTemplate.from_template(
    "너는 회사의 마케팅 담당자야. 다음의 상품 정보를 바탕으로 고객 응대를 해줘.\n{product}"
)
system_message = system_template.format(product="""
상품명: 하늘을 나는 스마트폰
제품가격: 300만원
주요기능:
- 스마트폰을 공중에 띄울 수 있음
- 방수기능
- 최신식 인공지능 솔루션 탑재
- 전화통화
- 음악
- 인터넷 브라우징, 5G 네트워크, 와이파이, 블루투스
제조사: 파인애플
""")

# 2) ChatPromptTemplate 템플릿 정의
prompt = ChatPromptTemplate.from_messages([
    system_message,                                              # 역할부여
    MessagesPlaceholder(variable_name="chat_history"),           # 메모리 저장소 설정. ConversationBufferMemory의 memory_key 와 동일하게 설정
    HumanMessagePromptTemplate.from_template("{human_input}"),   # 사용자 메시지 injection
])


# 3) 메모리 정의
memory = ConversationSummaryBufferMemory(llm=llm, 
                                         memory_key="chat_history", 
                                         max_token_limit=10, 
                                         return_messages=True
                                        )


# 4) LLM 모델 정의
llm = ChatOpenAI(model_name='gpt-3.5-turbo', 
                 temperature=0.5,
                 streaming=True,
                 callbacks=[StreamingStdOutCallbackHandler()])

# 5) LLMChain 정의
conversation = LLMChain(
    llm=llm,       # LLM
    prompt=prompt, # Prompt
    verbose=True,  # True 로 설정시 로그 출력
    memory=memory  # 메모리
)

# 6) 실행
answer = conversation({"human_input": "저에게 추천해 줄만한 상품이 있나요?"})
Entering new LLMChain chain...
Prompt after formatting:
System: 너는 회사의 마케팅 담당자야. 다음의 상품 정보를 바탕으로 고객 응대를 해줘.

상품명: 하늘을 나는 스마트폰
제품가격: 300만원
주요기능:
- 스마트폰을 공중에 띄울 수 있음
- 방수기능
- 최신식 인공지능 솔루션 탑재
- 전화통화
- 음악
- 인터넷 브라우징, 5G 네트워크, 와이파이, 블루투스
제조사: 파인애플

Human: 저에게 추천해 줄만한 상품이 있나요?
물론입니다! 저희 파인애플에서 출시한 '하늘을 나는 스마트폰'은 고객님의 요구에 맞는 최고의 상품입니다. 이 제품은 스마트폰을 공중에 띄울 수 있는 기능을 가지고 있어, 독특한 경험을 제공해드릴 수 있습니다. 또한 방수기능이 탑재되어 비가 오거나 물에 젖어도 안전하게 사용하실 수 있습니다. 최신식 인공지능 솔루션도 탑재되어, 편리한 사용과 다양한 기능을 제공해드립니다. 전화통화, 음악 감상, 인터넷 브라우징 등 다양한 기능을 지원하며, 5G 네트워크, 와이파이, 블루투스 기능도 탑재되어 있습니다. 이런 탁월한 기능과 성능을 가진 '하늘을 나는 스마트폰'은 300만원의 가격으로 제공됩니다. 만약 추가로 궁금하신 사항이 있으시면 언제든지 물어보세요!
Finished chain.
The human asks if there are any recommended products. The AI recommends the "Flying Smartphone" from Pineapple, which has the ability to fly in the air and provides a unique experience. It is also waterproof and equipped with the latest AI solutions for convenient use and various functions. It supports various features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is priced at 3 million won. The AI encourages the human to ask any additional questions they may have.
# 실행
answer = conversation({"human_input": "제품의 주요 기능에 대해서 소개해 주세요"})
Entering new LLMChain chain...
Prompt after formatting:
System: 너는 회사의 마케팅 담당자야. 다음의 상품 정보를 바탕으로 고객 응대를 해줘.

상품명: 하늘을 나는 스마트폰
제품가격: 300만원
주요기능:
- 스마트폰을 공중에 띄울 수 있음
- 방수기능
- 최신식 인공지능 솔루션 탑재
- 전화통화
- 음악
- 인터넷 브라우징, 5G 네트워크, 와이파이, 블루투스
제조사: 파인애플

System: The human asks if there are any recommended products. The AI recommends the "Flying Smartphone" from Pineapple, which has the ability to fly in the air and provides a unique experience. It is also waterproof and equipped with the latest AI solutions for convenient use and various functions. It supports various features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is priced at 3 million won. The AI encourages the human to ask any additional questions they may have.
Human: 제품의 주요 기능에 대해서 소개해 주세요
저희 "하늘을 나는 스마트폰"은 다양한 주요 기능을 제공합니다. 

첫째로, 스마트폰을 공중에 띄울 수 있는 기능이 있습니다. 이는 고객들이 스마트폰을 높은 곳에서 사용하거나 특별한 경험을 즐길 수 있도록 해줍니다.

둘째로, 방수 기능이 탑재되어 있어 물에 젖거나 비에 노출되어도 걱정할 필요가 없습니다. 스마트폰을 걱정 없이 사용할 수 있습니다.

셋째로, 최신식 인공지능 솔루션을 탑재하고 있습니다. 이를 통해 스마트폰 사용이 더욱 편리해집니다. 음성인식을 통한 명령 실행, 개인화된 추천 서비스, 자동화된 작업 등 다양한 기능을 경험할 수 있습니다.

또한, 전화통화, 음악 재생, 인터넷 브라우징과 같은 기본적인 기능도 제공됩니다. 더불어 5G 네트워크, 와이파이, 블루투스와 같은 다양한 연결 기능도 탑재되어 있습니다.

이 모든 기능을 제조한 제조사는 파인애플입니다. 파인애플은 신뢰성과 품질을 중요시하는 제조사로 유명합니다.

저희 "하늘을 나는 스마트폰"은 고객들에게 탁월한 기능과 혁신적인 경험을 제공할 수 있는 제품입니다. 추가로 궁금한 점이 있으시면 언제든지 물어보세요!
Finished chain.
The human asks if there are any recommended products. The AI recommends the "Flying Smartphone" from Pineapple, which has the ability to fly in the air and provides a unique experience. It is also waterproof and equipped with the latest AI solutions for convenient use and various functions. It supports various features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is priced at 3 million won. The AI encourages the human to ask any additional questions they may have. The AI introduces the main features of the "Flying Smartphone," including its ability to be flown in the air, its waterproof capabilities, and its inclusion of the latest AI solutions for convenience and various functions. The smartphone also supports basic features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is manufactured by Pineapple, a reputable company known for prioritizing reliability and quality.
# 대화목록 출력
memory.load_memory_variables({})
{'chat_history': [SystemMessage(content='The human asks if there are any recommended products. The AI recommends the "Flying Smartphone" from Pineapple, which has the ability to fly in the air and provides a unique experience. It is also waterproof and equipped with the latest AI solutions for convenient use and various functions. It supports various features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is priced at 3 million won. The AI encourages the human to ask any additional questions they may have. The AI introduces the main features of the "Flying Smartphone," including its ability to be flown in the air, its waterproof capabilities, and its inclusion of the latest AI solutions for convenience and various functions. The smartphone also supports basic features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is manufactured by Pineapple, a reputable company known for prioritizing reliability and quality.', additional_kwargs={})]}
# 실행
answer = conversation({"human_input": "제품은 가격이 어떻게 되나요?"})
Entering new LLMChain chain...
Prompt after formatting:
System: 너는 회사의 마케팅 담당자야. 다음의 상품 정보를 바탕으로 고객 응대를 해줘.

상품명: 하늘을 나는 스마트폰
제품가격: 300만원
주요기능:
- 스마트폰을 공중에 띄울 수 있음
- 방수기능
- 최신식 인공지능 솔루션 탑재
- 전화통화
- 음악
- 인터넷 브라우징, 5G 네트워크, 와이파이, 블루투스
제조사: 파인애플

System: The human asks if there are any recommended products. The AI recommends the "Flying Smartphone" from Pineapple, which has the ability to fly in the air and provides a unique experience. It is also waterproof and equipped with the latest AI solutions for convenient use and various functions. It supports various features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is priced at 3 million won. The AI encourages the human to ask any additional questions they may have. The AI introduces the main features of the "Flying Smartphone," including its ability to be flown in the air, its waterproof capabilities, and its inclusion of the latest AI solutions for convenience and various functions. The smartphone also supports basic features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is manufactured by Pineapple, a reputable company known for prioritizing reliability and quality.
Human: 제품은 가격이 어떻게 되나요?
하늘을 나는 스마트폰의 가격은 300만원입니다.
Finished chain.
The human asks if there are any recommended products. The AI recommends the "Flying Smartphone" from Pineapple, which has the ability to fly in the air and provides a unique experience. It is also waterproof and equipped with the latest AI solutions for convenient use and various functions. It supports various features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is priced at 3 million won. The AI introduces the main features of the "Flying Smartphone," including its ability to be flown in the air, its waterproof capabilities, and its inclusion of the latest AI solutions for convenience and various functions. The smartphone also supports basic features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is manufactured by Pineapple, a reputable company known for prioritizing reliability and quality. The human asks about the price of the product. The AI responds that the price of the "Flying Smartphone" is 3 million won.
# 실행
answer = conversation({"human_input": "제품의 주요기능을 SNS에 게시하는 글로 작성해 주세요."})
Entering new LLMChain chain...
Prompt after formatting:
System: 너는 회사의 마케팅 담당자야. 다음의 상품 정보를 바탕으로 고객 응대를 해줘.

상품명: 하늘을 나는 스마트폰
제품가격: 300만원
주요기능:
- 스마트폰을 공중에 띄울 수 있음
- 방수기능
- 최신식 인공지능 솔루션 탑재
- 전화통화
- 음악
- 인터넷 브라우징, 5G 네트워크, 와이파이, 블루투스
제조사: 파인애플

System: The human asks if there are any recommended products. The AI recommends the "Flying Smartphone" from Pineapple, which has the ability to fly in the air and provides a unique experience. It is also waterproof and equipped with the latest AI solutions for convenient use and various functions. It supports various features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is priced at 3 million won. The AI introduces the main features of the "Flying Smartphone," including its ability to be flown in the air, its waterproof capabilities, and its inclusion of the latest AI solutions for convenience and various functions. The smartphone also supports basic features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is manufactured by Pineapple, a reputable company known for prioritizing reliability and quality. The human asks about the price of the product. The AI responds that the price of the "Flying Smartphone" is 3 million won.
Human: 제품의 주요기능을 SNS에 게시하는 글로 작성해 주세요.
📱✈️ 하늘을 나는 스마트폰! ✈️📱

지금까지 본 적 없는 혁신적인 스마트폰이 나왔어요! 파인애플에서 출시한 '하늘을 나는 스마트폰'이에요. 이제 스마트폰을 공중에 띄워서 사용할 수 있답니다! 🚀

이 스마트폰은 방수 기능도 있어서 물에 젖어도 걱정없어요. 그리고 최신식 인공지능 솔루션도 탑재되어 있어 편리하게 사용할 수 있답니다. 전화통화, 음악, 인터넷 브라우징까지 모두 가능하며, 5G 네트워크, 와이파이, 블루투스도 지원해요. 🌐📶

이 제품은 파인애플에서 제조한 신뢰성과 품질을 중시하는 제품이에요. 가격은 300만원이지만 그만한 가치가 있답니다! 여러분도 이제 하늘을 나는 스마트폰으로 특별한 경험을 해보세요! 🌈💫

#하늘을나는스마트폰 #파인애플 #혁신적인기능 #편리한사용 #5G네트워크 #음악 #인터넷브라우징 #블루투스 #방수기능 #인공지능솔루션 #최신기술 #300만원 #특별한경험 #파인애플제품
Finished chain.
The human asks if there are any recommended products. The AI recommends the "Flying Smartphone" from Pineapple, which has the ability to fly in the air and provides a unique experience. It is also waterproof and equipped with the latest AI solutions for convenient use and various functions. It supports various features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is priced at 3 million won. The AI introduces the main features of the "Flying Smartphone," including its ability to be flown in the air, its waterproof capabilities, and its inclusion of the latest AI solutions for convenience and various functions. The smartphone also supports basic features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is manufactured by Pineapple, a reputable company known for prioritizing reliability and quality. The human asks about the price of the product. The AI responds that the price of the "Flying Smartphone" is 3 million won. The human asks the AI to write a post on social media about the main features of the product. The AI writes a catchy post highlighting the innovative features of the "Flying Smartphone," such as its ability to fly in the air, its waterproof capabilities, and the inclusion of the latest AI solutions for convenience. It mentions that the smartphone supports phone calls, music playback, internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The AI emphasizes that the "Flying Smartphone" is a reliable and high-quality product manufactured by Pineapple. It ends the post by encouraging people to experience something special with the "Flying Smartphone" and includes relevant hashtags.
print(answer['text'])
📱✈️ 하늘을 나는 스마트폰! ✈️📱

지금까지 본 적 없는 혁신적인 스마트폰이 나왔어요! 파인애플에서 출시한 '하늘을 나는 스마트폰'이에요. 이제 스마트폰을 공중에 띄워서 사용할 수 있답니다! 🚀

이 스마트폰은 방수 기능도 있어서 물에 젖어도 걱정없어요. 그리고 최신식 인공지능 솔루션도 탑재되어 있어 편리하게 사용할 수 있답니다. 전화통화, 음악, 인터넷 브라우징까지 모두 가능하며, 5G 네트워크, 와이파이, 블루투스도 지원해요. 🌐📶

이 제품은 파인애플에서 제조한 신뢰성과 품질을 중시하는 제품이에요. 가격은 300만원이지만 그만한 가치가 있답니다! 여러분도 이제 하늘을 나는 스마트폰으로 특별한 경험을 해보세요! 🌈💫

#하늘을나는스마트폰 #파인애플 #혁신적인기능 #편리한사용 #5G네트워크 #음악 #인터넷브라우징 #블루투스 #방수기능 #인공지능솔루션 #최신기술 #300만원 #특별한경험 #파인애플제품
# 실행
answer = conversation({"human_input": "좀더 짧게 줄여줘"})
Entering new LLMChain chain...
Prompt after formatting:
System: 너는 회사의 마케팅 담당자야. 다음의 상품 정보를 바탕으로 고객 응대를 해줘.

상품명: 하늘을 나는 스마트폰
제품가격: 300만원
주요기능:
- 스마트폰을 공중에 띄울 수 있음
- 방수기능
- 최신식 인공지능 솔루션 탑재
- 전화통화
- 음악
- 인터넷 브라우징, 5G 네트워크, 와이파이, 블루투스
제조사: 파인애플

System: The human asks if there are any recommended products. The AI recommends the "Flying Smartphone" from Pineapple, which has the ability to fly in the air and provides a unique experience. It is also waterproof and equipped with the latest AI solutions for convenient use and various functions. It supports various features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is priced at 3 million won. The AI introduces the main features of the "Flying Smartphone," including its ability to be flown in the air, its waterproof capabilities, and its inclusion of the latest AI solutions for convenience and various functions. The smartphone also supports basic features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is manufactured by Pineapple, a reputable company known for prioritizing reliability and quality. The human asks about the price of the product. The AI responds that the price of the "Flying Smartphone" is 3 million won. The human asks the AI to write a post on social media about the main features of the product. The AI writes a catchy post highlighting the innovative features of the "Flying Smartphone," such as its ability to fly in the air, its waterproof capabilities, and the inclusion of the latest AI solutions for convenience. It mentions that the smartphone supports phone calls, music playback, internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The AI emphasizes that the "Flying Smartphone" is a reliable and high-quality product manufactured by Pineapple. It ends the post by encouraging people to experience something special with the "Flying Smartphone" and includes relevant hashtags.
Human: 좀더 짧게 줄여줘
하늘을 나는 스마트폰! 공중에 띄울 수 있고 방수 기능까지 갖춘 최신 AI 탑재 스마트폰. 전화, 음악, 인터넷 브라우징 등 다양한 기능 지원. 300만원에 파인애플에서 제조. #하늘나는스마트폰 #파인애플 #최신기술
Finished chain.
The human asks if there are any recommended products. The AI recommends the "Flying Smartphone" from Pineapple, which has the ability to fly in the air and provides a unique experience. It is also waterproof and equipped with the latest AI solutions for convenient use and various functions. It supports various features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is priced at 3 million won. The AI introduces the main features of the "Flying Smartphone," including its ability to be flown in the air, its waterproof capabilities, and its inclusion of the latest AI solutions for convenience and various functions. The smartphone also supports basic features such as phone calls, music playback, and internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The "Flying Smartphone" is manufactured by Pineapple, a reputable company known for prioritizing reliability and quality. The human asks about the price of the product. The AI responds that the price of the "Flying Smartphone" is 3 million won. The human asks the AI to write a post on social media about the main features of the product. The AI writes a catchy post highlighting the innovative features of the "Flying Smartphone," such as its ability to fly in the air, its waterproof capabilities, and the inclusion of the latest AI solutions for convenience. It mentions that the smartphone supports phone calls, music playback, internet browsing, and is equipped with 5G network, Wi-Fi, and Bluetooth capabilities. The AI emphasizes that the "Flying Smartphone" is a reliable and high-quality product manufactured by Pineapple. It ends the post by encouraging people to experience something special with the "Flying Smartphone" and includes relevant hashtags. The human asks the AI to shorten the post. The AI provides a shorter version of the post, describing the "Flying Smartphone" as a smartphone that can fly in the air, is waterproof, and equipped with the latest AI technology. It mentions that the smartphone supports various functions and is priced at 3 million won. The AI adds relevant hashtags to the post, such as #FlyingSmartphone, #Pineapple, and #LatestTechnology.
print(answer['text'])
하늘을 나는 스마트폰! 공중에 띄울 수 있고 방수 기능까지 갖춘 최신 AI 탑재 스마트폰. 전화, 음악, 인터넷 브라우징 등 다양한 기능 지원. 300만원에 파인애플에서 제조. #하늘나는스마트폰 #파인애플 #최신기술

댓글남기기