From 1e2268665dfb63b7dfb1188ce0ff6759a6c31f9e Mon Sep 17 00:00:00 2001 From: Tanya Rai Date: Tue, 5 Mar 2024 20:06:44 -0500 Subject: [PATCH 1/2] [groq] updated readme for the new instructions addressed comments --- cookbooks/Groq/aiconfig_model_registry.py | 3 +++ extensions/Groq/README.md | 31 ++++++++++++----------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/cookbooks/Groq/aiconfig_model_registry.py b/cookbooks/Groq/aiconfig_model_registry.py index 422ce3917..7eb341979 100644 --- a/cookbooks/Groq/aiconfig_model_registry.py +++ b/cookbooks/Groq/aiconfig_model_registry.py @@ -15,4 +15,7 @@ def register_model_parsers() -> None: groq_mixtral = GroqParser(model="mixtral-8x7b-32768") ModelParserRegistry.register_model_parser(groq_mixtral) + groq_llama = GroqParser(model="llama2-70b-4096") + ModelParserRegistry.register_model_parser(groq_llama) + dotenv.load_dotenv() diff --git a/extensions/Groq/README.md b/extensions/Groq/README.md index 6bcd333b6..0f43ec9ac 100644 --- a/extensions/Groq/README.md +++ b/extensions/Groq/README.md @@ -1,23 +1,24 @@ -This extension contains the Groq client wrapper to use with AIConfig: +This extension contains the Groq client wrapper to use with AIConfig so you can use models supported by the [GroqAPI](https://console.groq.com/docs/quickstart). -# Part 1: Register your API key +## Step 1: Set your Groq API key -Create an API key from the Groq [website](https://console.groq.com/keys) and save it in your environment under the name `GROQ_API_KEY`. We recommend saving it into your home `~/.env` file, or one of your home hidden files like `~/.bashrc` or `~/.zshrc` so that you don't need to redefine it every session whenever you open a new terminal: +1. Create an API key from the Groq [website](https://console.groq.com/keys). +2. Add the key to your home `~/env` file: `GROQ_API_KEY=''` -```bash -GROQ_API_KEY= -``` +## Step 2: Import the Groq Extension -# Part 2: Import and use this extension +1. `pip3 install aiconfig-extension-groq` +2. Add this file [`aiconfig_model_registry.py`](https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Groq/aiconfig_model_registry.py) in your working directory. -`pip3 install aiconfig-extension-groq` +NOTE: When new models are supported by the GroqAPI that you want to use, make sure to manually add them to this file (similar to how `mixtral-8x7b-32768` was registered for example). -For the following steps below, see the [Groq cookbook](https://github.com/lastmile-ai/aiconfig/blob/b9a9e59dfd6251ab91580c0b8a4ef37906e8b9d4/cookbooks/Groq/aiconfig_model_registry.py) and associated [AIConfig file](https://github.com/lastmile-ai/aiconfig/blob/b9a9e59dfd6251ab91580c0b8a4ef37906e8b9d4/cookbooks/Groq/groq.aiconfig.json) for a reference example. +## Step 2: Use models from Groq in AIConfig -1. Import the library to your code: `from aiconfig_extension_groq import GroqParser`. -2. Import the AIConfig model registery: `from aiconfig import ModelRegistryParser` -3. In code, add all the relevant model parser objects that you want to use from this extension to the registry. Ex: `ModelParserRegistry.register_model_parser(GroqParser("mixtral-8x7b-32768"))`. You can read the docstrings under `ModelParserRegistry` class for more info -4. In your AIConfig file, add a field `model_parsers` with the model name you want to use and map it to the id of model parser you want to use. Ex (here both the model name and model id for this model parser are the same): https://github.com/lastmile-ai/aiconfig/blob/cddf72bba2bd011355d88f98bdd1d7385de53883/cookbooks/Groq/groq.aiconfig.json#L7-L9 -5. Now whenever you call `aiconfig.run()` these model parsers will be loaded and available! +Make sure you have AIConfig VS Code Extension installed [here](https://marketplace.visualstudio.com/items?itemName=lastmile-ai.vscode-aiconfig). -You can now use either the AIConfig SDK, VS Code extension, or local editor to use the Groq client to play around with models, modify prompts, change parameters, etc. +1. `CMD/Ctrl+Shift+P` and enter `'AIConfig: Create new AIConfig (yaml)'` +2. Groq models (ex. `mixtral-8x7b-32768`) will now be available via model dropdown for your prompts. +3. Run a prompt with a Groq model! + +Want to start with an existing Groq AIConfig? +Open this [AIConfig file](https://github.com/lastmile-ai/aiconfig/blob/b9a9e59dfd6251ab91580c0b8a4ef37906e8b9d4/cookbooks/Groq/groq.aiconfig.json) with the AIConfig Editor. Make sure the steps above were completed. From 199c2fe9b70c393213b50849fa1af9728e689d45 Mon Sep 17 00:00:00 2001 From: Tanya Rai Date: Tue, 5 Mar 2024 20:18:23 -0500 Subject: [PATCH 2/2] [groq] addressed comments --- extensions/Groq/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/Groq/README.md b/extensions/Groq/README.md index 0f43ec9ac..3725a2c16 100644 --- a/extensions/Groq/README.md +++ b/extensions/Groq/README.md @@ -16,7 +16,7 @@ NOTE: When new models are supported by the GroqAPI that you want to use, make su Make sure you have AIConfig VS Code Extension installed [here](https://marketplace.visualstudio.com/items?itemName=lastmile-ai.vscode-aiconfig). -1. `CMD/Ctrl+Shift+P` and enter `'AIConfig: Create new AIConfig (yaml)'` +1. `CMD/Ctrl + Shift + P` and enter `'AIConfig: Create New AIConfig (yaml)'` 2. Groq models (ex. `mixtral-8x7b-32768`) will now be available via model dropdown for your prompts. 3. Run a prompt with a Groq model!