Skip to content
/ groq Public

The GroqClass simplifies interaction with the Groq API, allowing easy integration of the Groq language model into applications.

Notifications You must be signed in to change notification settings

Sagi-BA/groq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alt text

👀 Groq language model

This project demonstrates how to use the Groq SDK in both Node.js and Python environments. It includes example code for sending prompts to the Groq AI and handling responses. Rate Limits for Free Beta

The rate limits for the Free Beta are as follows:

ID REQUESTS PER MINUTE REQUESTS PER DAY TOKENS PER MINUTE
gemma-7b-it 30 14,400 15,000
mixtral-8×7b-32768 30 14,400 5,000
llama3-70b-8192 30 14,400 6,000
llama3-8b-8192 30 14,400 30,000

Support Support Support Support Support Support

Prerequisites

  • Node.js (v12 or higher)
  • Python (v3.7 or higher)
  • Groq SDK
  • Environment variables setup (see .env.example)

Setup

Environment Variables

Create a .env file in the root directory of your project and add the following environment variables:

GROQ_API_KEY=your_api_key_here
GROQ_MAX_TOKENS=100
GROQ_MODEL=your_model_here

Guides & News

To get started, follow these steps:

  1. Clone the repository using:
git clone https://github.com/Sagi-BA/groq.git
  1. Install the required dependencies by running:
npm install --omit=dev
  1. Create a .env file in the root folder of the project. Use the env.example file as a template and add your environment variables.

  2. Register on the Groq platform and create an API Key

  3. To test the application, run the app.js file. You can change the starting JavaScript file by modifying the launch.json configuration.

Dependencies

To install the required dependencies, run the following:

Node.js

  • dotenv: ^16.4.5
  • groq-sdk: ^0.3.3

Python

  • Groq
  • python-dotenv

Examples

Here, I demonstrate how to use the GroqClass()

🚀 Send a Prompt Message to Groq

# pythoe example
import asyncio
from GroqClass import GroqClass  # Corrected import statement

async def main():
    mygroq = GroqClass()
    userPrompt = "מי זה אנתוני הופקינס ?"
    response = await mygroq.sendsendPrompt(userPrompt)

    if response:
        print(response.choices[0].message.content)
    else:
        print("Failed to get a response from Groq.")

if __name__ == "__main__":
    asyncio.run(main())
// JavaScript example
// Import the GroqManager class using CommonJS syntax
const GroqClass = require("./GroqClass");

// Main function to send a user prompt and handle the response
async function main() {
  const mygroq = new GroqClass();
  const userPrompt = "Who is Anthony Hopkins?";

  const response = await mygroq.sendPrompt(userPrompt);

  if (response) {
    console.log(response.choices[0]?.message?.content || "");
  } else {
    console.error("Failed to get a response from Groq.");
  }
}

// Call the main function
main().catch(console.error);

License

This project is licensed under the ISC License. See the LICENSE file for details.

I Am that I Am, I will be what I will be

Releases

No releases published

Packages

No packages published