Summary
- ๋ค๋ฅธ ์ฌ๋์ ํ๋กฌํํธ ๋ถ๋ฌ์ค๊ธฐ
- ๋ด ํ๋กฌํํธ hub์ ์ฌ๋ฆฌ๊ธฐ
Langchain Hub๋ ์ปค๋ฎค๋ํฐ ๊ธฐ๋ฐ์ ๋ฆฌ์์ค ์ ์ฅ์๋ก ๋ค๋ฅธ ์ฌ๋๋ค์ด ์์ฑํ ํ๋กฌํํธ๋ค์ ํ์ํ๊ณ ์ฌ์ฉํ ์ ์๋ค.
1๏ธโฃ ํ๋กฌํํธ ๊ฐ์ ธ์ค๊ธฐ(pull)
from langchain import hub
prompt = hub.pull("rlm/rag-prompt")
print(prompt)# Output
input_variables=['context', 'question'] metadata={'lc_hub_owner': 'rlm', 'lc_hub_repo': 'rag-prompt', 'lc_hub_commit_hash': '50442af133e61576e74536c6556cefe1fac147cad032f4377b60c436e6cdcb6e'} messages=[HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=['context', 'question'], template="You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, just say that you don't know. Use three sentences maximum and keep the answer concise.\nQuestion: {question} \nContext: {context} \nAnswer:"))]
2๏ธโฃ ํ๋กฌํํธ ์ฌ๋ฆฌ๊ธฐ(push)

ํ๋กฌํํธ๋ฅผ ์ฌ๋ฆฌ๊ธฐ ์ํด์๋ hub ๊ณ์ ์ด ์์ด์ผ ํ๋ค.
์ฒซ ์์์ผ๋ก Langchain Hubํ์ด์ง์์ ํ๋กฌํํธ๋ฅผ ๋ง๋ค์ด๋ณด๋ฉด ์ ์ ์๋ค.
[+Prompt] - [Save as] - [Public]์ ๋๋ฅด๋ฉด ์ด๋ฆ์ ์ค์ ํ๋ ํ๋ฉด์ด ์๊ธด๋ค.
ํ๋กฌํํธ ์ญ์ , ์ด๋ฆ ๋ณ๊ฒฝ ๊ธฐ๋ฅ์ด ์๋ค. ์ผ๋ฐ์ ์ธ ํ๋กฌํํธ๋ช ์ ์ฌ์ฉํ์.
๋๋ ํ๋กฌํํธ๋ช
์ test, test-test๋ก ํด์ ์์ฝ๊ฒ ๊ธฐ๋ก์ด ๋จ์๋ฒ๋ ธ๋ค.
๋์ ๊ฐ์ ๊ณ ๋ฏผ์ ๋๊ตฐ๊ฐ๊ฐ ISSUE๋ฅผ ์ฌ๋ ธ๋๋ฐ, ์์ผ๋ก ๋ ผ์ํ ์์ ์ด๋ผ๊ณ ํ๋ค.
์๋ฌดํผ hub ๊ณ์ ๋ช ์ด ์๊ฒผ์ผ๋ฉด ์ด์ ๋ก์ปฌ์์๋ ๋ฐ๋ก ํ๋กฌํํธ๋ฅผ ๊ด๋ฆฌํ ์ ์๋ค.
from langchain.prompts import ChatPromptTemplate
from langchain import hub
template = """
KEY๋ฅผ ๊ฐ์ง JSON ํ์์ผ๋ก ๋ต๋ณํด์ฃผ์ธ์.
KEY:
- text<์
๋ ฅ๋ฐ์ TEXT>
- summary<TEXT๋ฅผ ํ ์ค๋ก ์์ฝํด์ฃผ์ธ์>
- translation<summary๋ฅผ ํ๊ตญ์ด๋ก ๋ฒ์ญํด์ฃผ์ธ์>
TEXT: {text}
"""
prompt = ChatPromptTemplate.from_messages(
[
("system", "๋น์ ์ ๊ธฐ์ฌ๋ฅผ ์์ฝํ์ฌ ํ๊ตญ์ด๋ก ๋ฒ์ญํ ํ ์ ๋ณด๋ฅผ ์ ๋ฌํ๋ ์ญํ ์
๋๋ค."),
("human", template)
]
)
hub.push("thinker/summary_json_korean", prompt)๋ง์ฝ ํ๋กฌํํธ๋ช ์ด ์ด๋ฏธ ์กด์ฌํ๋ค๋ฉด ๋ฎ์ด์์์ง๋ค. Git์ Commit๊ณผ ๋์ผํ ๊ธฐ๋ฅ์ผ๋ก, ์์ ๋ฒ์ ์ ํ๋กฌํํธ๋ฅผ ๊ฐ์ง๊ณ ์ค๊ณ ์ถ๋ค๋ฉด commit hash๋ฅผ ํจ๊ป ์ ๋ ฅํ๋ฉด ๋๋ค.
prompt = hub.pull("thinker/summary_json_korean:9e3d6447")3๏ธโฃ ํ๋กฌํํธ ๊ด๋ฆฌํ๊ธฐ
๋นจ๊ฐ์ ๋ฐ์ค ๋ถ๋ถ์ ๋๋ฅด๋ฉด README, Description, USE CASES, Language, Model ๋ฑ ๋ ๋ง์ ์ ๋ณด๋ฅผ ์์ฑํ ์ ์๋ค.
์์ฑ์ ์์ธํ๊ฒ ํ ์๋ก Langchain Hub์์ ๋ ํ๋ฐํ ๊ณต์ ๋ ์ ์๋ค.

References