Why do we need to pass "style' and 'text' twice?

In the lesson ’ L1 - Models, Prompts and Output Parsers’, why do we need to pass ‘style’ and ‘text’ to prompt_template.format_messages (customer_messages = prompt_template.format_messages( style=customer_style, text=customer_email)), when we have already included them in template_string parameter, which was used to create prompt_template? (prompt_template = ChatPromptTemplate.from_template(template_string)). Just want to know if it is a redundancy.

Also, if we change these two parameters in

service_messages = prompt_template.format_messages(
    style=service_style_pirate,
    text=service_reply)

with something different as shown in the video, I wonder how is the conflict avoided? LangChain seems to be doing some magic.

Hi vsrinivas,

First of all I am happy that you are from one of us who are learning these cutting edge techs and tbh I also just started :smiley:

But to answer your question …
you are mixing up … the template_string above is:

template_string = “”“Translate the text
that is delimited by triple backticks
into a style that is {style}.
text: {text}
“””

Here we are not passing the style and text, what we used earlier in this lecture but we are defining here to let LLM know ok these will be your inputs. As you can see on this line:

prompt_template.messages[0].prompt.input_variables

When you run this line, it will print two input variables (style and text). So whenever you use the function “prompt_template.format_messages(style, text)” you just need to pass the values in these arguments …

But If you don’t pass the style and text above in the template_string … think about it how the LLM will know inputs … It will get confused and may be try to suicide :smiley:
Anyways, best of luck for your rest of the course.

Thanks Mohammed for the clarification. As far as the first part of my query, let me rephrase it.

Since we have already let LLM know about the inputs ‘style’ and ‘text’ in template_string, which is passed as an argument to ChatPromptTemplate.from_template() to create prompt_template,

then is it necessary to call them again in prompt_template.format_messages() to create customer_messages?

This query is just to make myself clear. :slight_smile: