Created
October 6, 2023 07:00
-
-
Save maxandersen/36db042c573e36ff4f5e05d40d4c1cb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DEPS dev.langchain4j:langchain4j:0.23.0 | |
//DEPS dev.langchain4j:langchain4j-open-ai:0.23.0 | |
//DEPS org.slf4j:slf4j-simple:2.0.9 | |
//JAVA_OPTIONS -Dorg.slf4j.simpleLogger.defaultLogLevel=debug | |
import dev.langchain4j.model.chat.ChatLanguageModel; | |
import dev.langchain4j.model.openai.OpenAiChatModel; | |
import static dev.langchain4j.model.openai.OpenAiModelName.*; | |
import static java.time.Duration.ofSeconds; | |
public class _01_ModelParameters { | |
public static void main(String[] args) { | |
// parameter meaning for openAI explained here https://platform.openai.com/docs/api-reference/chat/create | |
ChatLanguageModel model = OpenAiChatModel.builder() | |
.apiKey(System.getenv("OPENAI_API_KEY")) | |
.modelName(GPT_4) | |
.temperature(0.8) | |
.timeout(ofSeconds(120)) | |
.logRequests(true) | |
.logResponses(true) | |
.build(); | |
String prompt = "Explain in one line how to make a beautiful painting"; | |
String response = model.generate(prompt); | |
System.out.println(response); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment