Giter Site home page Giter Site logo

sagi-ba / groq Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 314 KB

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

Home Page: https://bit.ly/4aiA36A

JavaScript 49.09% Python 50.91%
api-integration chatbots content-generation examples groq-api javascript language-model natural-language-processing groqclass simplified-api-interaction

groq's Introduction

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

groq's People

Contributors

sagi-ba avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    馃枛 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 馃搳馃搱馃帀

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google 鉂わ笍 Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.