Prompt - PromptTemplate
Prompts to llm Models Prompts can be given with or without templating. Simple Prompt Without Template ! pip install langchain-openai from langchain_openai import OpenAI llm = OpenAI ( openai_api_key = openai_api_key ) response = llm.invoke ( "Translate from english to french the text <hello>" ) print ( response ) llm vs chat models llm do not require a chat kind of scenario, but rather expects just a response for the prompt. chat models expect a chat like scenario in which the conversation history needs to be remembered. PromptTemplate PromptTemplate class is used with llm and not chat models. PromptTemplate is a string template. It accepts a set of variables as input from the user and they are used to generate prompts for language models. Steps 1. Use from_template() to create PromptTemplate object 2. Create Prompt as string using format() Step 1 : Using from_template() cls - shows it is a class method and so we call the function with t...