From 1b229b39f1c3ce6e12bcaf94712b21f290a27392 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Mon, 22 Apr 2024 20:54:58 -0500 Subject: [PATCH] Add Use The llm CLI With Claude Models as an LLM TIL --- README.md | 3 ++- llm/use-the-llm-cli-with-claude-models.md | 26 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 llm/use-the-llm-cli-with-claude-models.md diff --git a/README.md b/README.md index 320f3bf..9b9c94a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1415 TILs and counting..._ +_1416 TILs and counting..._ --- @@ -558,6 +558,7 @@ _1415 TILs and counting..._ ### LLM - [Send cURL To Claude Text Completion API](llm/send-curl-to-claude-text-completion-api.md) +- [Use The llm CLI With Claude Models](llm/use-the-llm-cli-with-claude-models.md) ### Mac diff --git a/llm/use-the-llm-cli-with-claude-models.md b/llm/use-the-llm-cli-with-claude-models.md new file mode 100644 index 0000000..a5d1f67 --- /dev/null +++ b/llm/use-the-llm-cli-with-claude-models.md @@ -0,0 +1,26 @@ +# Use The llm CLI With Claude Models + +[Simon Willison's `llm`](https://llm.datasette.io/en/stable/index.html) can be +used with a bunch of different models (local and API). The whole thing is +plugin driven. To use a specific model, you'll need to install the plugin for +it. For instance, to use the [Claude 3 family of +models](https://www.anthropic.com/news/claude-3-family) you need to install +`llm-claude-3`. + +```bash +$ llm install llm-claude-3 +``` + +Then when prompting `llm`, specify which of the Claude models you want to use — +`claude-3-haiku`, `claude-3-sonnet`, or `claude-3-opus` — with the `-m` flag: + +```bash +$ llm \ + -m claude-3-haiku \ + --key $CLAUDE_API_KEY \ + 'Show me the SQL query to create a cocktails table.' +``` + +Note: instead of adding my Claude API key to the key store, I've opted to +include it with the `--key` flag via an environment variable that I've set +ahead of time.