From the course: GenAI for Busy Java Developers by Pearson
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Demonstrate dynamic prompt composition using Java variables - Java Tutorial
From the course: GenAI for Busy Java Developers by Pearson
Demonstrate dynamic prompt composition using Java variables
Okay, here we are in IntelliJ, and here we have the same exact example, we're calling it simple template. So the first thing we do as usual is we create an instance of a chat model. In this example, I'm using OpenAI again, and I supply the API key and I say which model I want out of the perhaps dozen models that they have. I set the temperature, and if you remember from prior lesson, that temperature represents creativity. In effect, it's representing more randomness. The higher the number is, the more random your results. Sometimes you might hear, the higher the number, the more creative the language model is. I hesitate to say that, but because if you set it to the maximum, you'll see sometimes random characters, which is not very creative. So temperature ranges from zero to one. So if you set it to the highest number, you can see how random the characters are. But let's keep randomness low. So 0.3 is pretty low. We set the timeout to two minutes and we wanna limit the number of…
Contents
-
-
-
-
-
-
-
-
(Locked)
Learning objectives41s
-
(Locked)
Identify why templates are useful2m 38s
-
(Locked)
Create reusable prompt templates using LangChain4j3m 23s
-
(Locked)
Demonstrate dynamic prompt composition using Java variables9m 11s
-
(Locked)
Identify the advantages and disadvantages of prompt templates2m 33s
-
(Locked)
-
-
-
-
-
-
-