|
3 | 3 | [org.httpkit.client :as hk-client] |
4 | 4 | [cheshire.core :as json])) |
5 | 5 |
|
6 | | -;;# using Large Language Models from Clojure |
| 6 | +;;# Using Large Language Models from Clojure |
7 | 7 | ;;LLMs often come as APIs, as they require computing power (GPUs), which most users do not have |
8 | | -;;localy. |
| 8 | +;;locally. |
9 | 9 | ;;OpenAI offers their models behind an (paid) API for example. In the following we will see three |
10 | 10 | ;;different ways to use the GPT-4 model from OpenAI |
11 | 11 |
|
12 | | -;; Get the openai API key either from environemnt or a specific file |
| 12 | +;; Get the openai API key either from environment or a specific file |
13 | 13 | (def open-ai-key |
14 | 14 | (or (System/getenv "OPEN_AI_KEY") |
15 | 15 | (slurp "open_ai_secret.txt") |
|
20 | 20 | ;## Use OpenAI API directly |
21 | 21 | ;; OpenAI offers a rather simple API, text-in text-out for "chatting" with GPT |
22 | 22 | ;; |
23 | | -;; The following shows how to ask a simple question, and getting the answer using an http libray, |
| 23 | +;; The following shows how to ask a simple question, and getting the answer using an http library, |
24 | 24 | ;; [http-kit](https://github.com/http-kit/http-kit). The API is based on JSON, so easy to use |
25 | 25 | ;; from Clojure |
26 | 26 |
|
|
43 | 43 | ; ## use Bosquet |
44 | 44 | ; [Bosquet](https://github.com/zmedelis/bosquet) abstracts some of the concepts of LLMs |
45 | 45 | ; on a higher level API. Its has further notions of "memory" and "tools" |
46 | | -; and has other features we find for exampl in python "LangChain" |
| 46 | +; and has other features we find for example in python "LangChain" |
47 | 47 |
|
48 | 48 | ;; Bosque wants the API key in a config file |
49 | 49 | (spit "secrets.edn" |
|
66 | 66 | ;; We can use LLMs as well via a Java Interop and the library |
67 | 67 | ;; [lnagchain4j](https://github.com/langchain4j/langchain4j) which aims |
68 | 68 | ;; to be a copy of the python library langchain, and offers support or |
69 | | -;; building blocks for several concepts arround LLMs (model, vectorstores, document loaders, etc.) |
| 69 | +;; building blocks for several concepts around LLMs (model, vector stores, document loaders, etc.) |
70 | 70 | ;; We see it used in the following chapters |
71 | 71 |
|
72 | 72 | (import '[dev.langchain4j.model.openai OpenAiChatModel OpenAiChatModelName]) |
|
0 commit comments