Created
April 17, 2025 14:19
-
-
Save nomisRev/69d303615d967a1d35b74fb0f4df3b69 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"cells" : [ { | |
"metadata" : { | |
"ExecuteTime" : { | |
"end_time" : "2025-04-17T14:19:03.405374Z", | |
"start_time" : "2025-04-17T14:19:02.942365Z" | |
} | |
}, | |
"cell_type" : "code", | |
"source" : [ "@file:DependsOn(\"dev.langchain4j:langchain4j:1.0.0-beta3\")\n", "@file:DependsOn(\"dev.langchain4j:langchain4j-open-ai:1.0.0-beta3\")\n", "\n", "import dev.langchain4j.agent.tool.Tool\n", "import dev.langchain4j.model.chat.ChatLanguageModel\n", "import dev.langchain4j.model.chat.StreamingChatLanguageModel\n", "import dev.langchain4j.model.openai.OpenAiChatModel\n", "import dev.langchain4j.model.openai.OpenAiChatModelName\n", "import dev.langchain4j.model.openai.OpenAiStreamingChatModel\n", "import dev.langchain4j.service.AiServices\n", "import dev.langchain4j.service.SystemMessage\n", "import dev.langchain4j.model.chat.chat\n", "\n", "val token = System.getenv(\"OPENAI_TOKEN\") ?: \"your-token\"\n", "\n", "val chat: ChatLanguageModel =\n", " OpenAiChatModel.builder()\n", " .apiKey(token)\n", " .modelName(OpenAiChatModelName.GPT_4_O_MINI)\n", " .build()" ], | |
"id" : "e1b3f7f4955b150b", | |
"outputs" : [ ], | |
"execution_count" : 1 | |
}, { | |
"metadata" : { | |
"ExecuteTime" : { | |
"end_time" : "2025-04-17T14:19:05.153738Z", | |
"start_time" : "2025-04-17T14:19:03.416758Z" | |
} | |
}, | |
"cell_type" : "code", | |
"source" : "chat.chat(\"Give me a Kotlin Joke!\")", | |
"id" : "a23ba59cb9d6c844", | |
"outputs" : [ { | |
"data" : { | |
"text/plain" : [ "Sure! Here’s a Kotlin joke for you:\n", "\n", "Why do Kotlin developers prefer to use `val` instead of `var`?\n", "\n", "Because they don’t like to change their minds! 😄 \n", "\n", "(Immutable variables for the win!)" ] | |
}, | |
"execution_count" : 2, | |
"metadata" : { }, | |
"output_type" : "execute_result" | |
} ], | |
"execution_count" : 2 | |
} ], | |
"metadata" : { | |
"kernelspec" : { | |
"display_name" : "Kotlin", | |
"language" : "kotlin", | |
"name" : "kotlin" | |
}, | |
"language_info" : { | |
"name" : "kotlin", | |
"version" : "1.9.23", | |
"mimetype" : "text/x-kotlin", | |
"file_extension" : ".kt", | |
"pygments_lexer" : "kotlin", | |
"codemirror_mode" : "text/x-kotlin", | |
"nbconvert_exporter" : "" | |
}, | |
"ktnbPluginMetadata" : { | |
"projectLibraries" : true | |
} | |
}, | |
"nbformat" : 4, | |
"nbformat_minor" : 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment