Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[groq] addressed comments #1406

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cookbooks/Groq/aiconfig_model_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
31 changes: 16 additions & 15 deletions extensions/Groq/README.md
Original file line number Diff line number Diff line change
@@ -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='<your-api-key>'`

```bash
GROQ_API_KEY=<your-api-key-here>
```
## 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.