You can initialize them with parameters like temperature and others, and pass them around.Next, let's use the predict method to run over a string input.text = "What would be a good company name for a company that makes colorful socks?"llm.predict(text)# >> Feetful of Funchat_model.predict(text)# >> Socks O'ColorFinally, let's use the predict_messages method to run over a list of messages.from langchain.schema import HumanMessagetext = "What would be a good company name for a company that makes colorful socks?"messages = [HumanMessage(content=text)]llm.predict_messages(messages)# >> Feetful of Funchat_model.predict_messages(messages)# >> Socks O'ColorFor both these methods, you can also pass in parameters as keyword arguments.
For example, you could pass in temperature=0 to adjust the temperature that is used from what the object was configured with.
Whatever values are passed in during run time will always override what the object was configured with.Prompt templates‚ÄãMost LLM applications do not pass user input directly into an LLM. Usually they will add the user input to a larger piece of text, called a prompt template, that provides additional context on the specific task at hand.In the previous example, the text we passed to the model contained instructions to generate a company name. For our application, it'd be great if the user only had to provide the description of a company/product, without having to worry about giving the model instructions.PromptTemplates help with exactly this!
They bundle up all the logic for going from user input into a fully formatted prompt.
Installation
Installation ->: You can initialize them with parameters like temperature and others, and pass them around.Next, let's use the predict method to run over a string input.text = "What would be a good company name for a company that makes colorful socks?"llm.predict(text)# >> Feetful of Funchat_model.predict(text)# >> Socks O'ColorFinally, let's use the predict_messages method to run over a list of messages.from langchain.schema import HumanMessagetext = "What would be a good company name for a company that makes colorful socks?"messages = [HumanMessage(content=text)]llm.predict_messages(messages)# >> Feetful of Funchat_model.predict_messages(messages)# >> Socks O'ColorFor both these methods, you can also pass in parameters as keyword arguments.
For example, you could pass in temperature=0 to adjust the temperature that is used from what the object was configured with.
Whatever values are passed in during run time will always override what the object was configured with.Prompt templates‚ÄãMost LLM applications do not pass user input directly into an LLM. Usually they will add the user input to a larger piece of text, called a prompt template, that provides additional context on the specific task at hand.In the previous example, the text we passed to the model contained instructions to generate a company name. For our application, it'd be great if the user only had to provide the description of a company/product, without having to worry about giving the model instructions.PromptTemplates help with exactly this!
They bundle up all the logic for going from user input into a fully formatted prompt.