이 노트북은 JinaChat chat model을 시작하는 방법을 다룹니다.
from langchain_community.chat_models import JinaChat
from langchain.messages import HumanMessage, SystemMessage
from langchain_core.prompts.chat import (
    ChatPromptTemplate,
    HumanMessagePromptTemplate,
    SystemMessagePromptTemplate,
)
chat = JinaChat(temperature=0)
messages = [
    SystemMessage(
        content="You are a helpful assistant that translates English to French."
    ),
    HumanMessage(
        content="Translate this sentence from English to French. I love programming."
    ),
]
chat(messages)
AIMessage(content="J'aime programmer.", additional_kwargs={}, example=False)
MessagePromptTemplate을 사용하여 템플릿을 활용할 수 있습니다. 하나 이상의 MessagePromptTemplates로부터 ChatPromptTemplate을 구성할 수 있습니다. ChatPromptTemplateformat_prompt를 사용할 수 있으며, 이는 PromptValue를 반환합니다. 이를 문자열 또는 Message 객체로 변환할 수 있으며, 포맷된 값을 llm 또는 chat model의 입력으로 사용할지 여부에 따라 달라집니다. 편의를 위해 template에 from_template 메서드가 제공됩니다. 이 template을 사용한다면 다음과 같이 보일 것입니다:
template = (
    "You are a helpful assistant that translates {input_language} to {output_language}."
)
system_message_prompt = SystemMessagePromptTemplate.from_template(template)
human_template = "{text}"
human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)
chat_prompt = ChatPromptTemplate.from_messages(
    [system_message_prompt, human_message_prompt]
)

# get a chat completion from the formatted messages
chat(
    chat_prompt.format_prompt(
        input_language="English", output_language="French", text="I love programming."
    ).to_messages()
)
AIMessage(content="J'aime programmer.", additional_kwargs={}, example=False)

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I