Build LLama 3 Chatbot on Groq Cloud with INSANE 800 TOKENS per second!

AI FOR DEVS · Intermediate ·🧠 Large Language Models ·2y ago

Key Takeaways

Build a LLama 3 Chatbot on Groq Cloud with 800 tokens per second capability

Full Transcript

in this video you'll learn how to build a website featuring a lightning fast chat with memory capabilities using llama 3 grock and streamlit if you've seen the Javis video you already know how incredibly fast Gro can process data let's do a quick recap what is Gro it's similar to GPT but with an incredibly faster processing capability here in this example you see Gro is done with a 500-word poem before GPT even starts on the other hand dreamlit is a python library that lets you build applications in just a few lines of code with our magically simple API together we will follow the gro documentation to build a very basic chat completion then we'll proceed step by step through the process of creating a Gro llama 3 chatbot allowing users to interact via a web page let's dive into the gro Cloud documentation to see how we can get started we follow the quick start tutorial the first step is to set the gro API key let's just copy the statement but before we first create a new file app.py before we can set the API key we need to create a new one for this we have to log into the Grog Cloud the registration to Grog is free and done in seconds just go to API keys and create a new one just enter a name and simply copy the key and paste it in the console once we have set this we can continue to keep things simple we start with a minimalistic example and increase the complexity from there let's now copy the example code so we can try it out the first thing we should do is install grock with Pip install then we can paste the example from the docs what do we have here at the beginning grock is imported then we create a new client using the API key that we just exported in the environment then we have a classic chat completion as we know from open AI in this case with a mix trail 8X 7B model when we run it we get a small essay about the importance of language models and we see how fast that was totally impressive let's make it a bit simpler and say it should now tell a joke let's run it wow our joke came super fast but this video is not about mix trol let's change the model to llama 3 we choose the 70b variant oops Gro doesn't know this model model that means we need to check what the correct name is for that I go to models in the gro documentation and see that it's not just 70b but 8192 must also be added at the end let's try it out and see if it works with the correct name and it looks good we got our joke all right we want to make it a bit more fancy and add a bit more functionality into it let's rename the file app.py to to basic call so that you can access both files later in the GitHub repository we take a look at what exciting examples there are in the documentation I find the idea of the conversational chat bot quite interesting so let's take a closer look at it well we click on the link to the GitHub repository okay we go there to the app py well that looks significantly more complicated at first glance but we will try to build a simplified version of and step by step so we understand everything that is being done here well obviously the chat was created with streamlit streamlit is a wonderful library to create very simple webuis which can interact with python code but sometimes it feels a little bit like magic I suggest that we first get familiar with streamlit and get to know it and for that we first copy the two statements the title and a right statement for this I first create a chatbot py file copying content and importing streamlit we try to run it and get an error message okay and we see that the indentation is not correct line four must of course be moved further to the left well we try it again okay and it tells us that we should start the program with streamlit run chatbot py and now our web application is actually running on Port 8501 on Local Host we'll call it up now and we see we have a website with our chat perfect then let's continue well the next step is apparently to give the chatbot memory the example uses buffer memory similar to a bucket that holds only a few messages before forgetting the latest we keep it simple and we later set the number of messages to 10 that means we will set our memory variable to a fixed value let's paste the memory code we also need the import statements the buffer memory is provided by the Lang chain Library therefore let's install it well and we now set the conversion in memory length to just 10 messages so that it can remember the last 10 messages then we have the use a question and there we have a text input similar to the python input where we can make entries and they are directly saved in a variable it looks like this we can now ask questions like what is the meaning of life but if we press enter not much would happen because we don't have any further logic so let's see how it goes from here the next code checks if the chat history variable exists in the session state if it doesn't it initializes es an empty list for storing chat history if it does exist it Loops through each message in the history and saves the conversation after that we have the initialization of chat Gro which gets the API key and the model in the GitHub example it could be selected via the sidebar we'll make it simple here again and just hardcode it the following code creates a conversation chain object using Gro and the session memory to manage and remember the context of interactions all right let's copy the complete block we see that there are some missing dependencies we need to import chat groke and conversation chain let's copy the import statements from the example let's install the last missing dependency Lang chain Gro and the indentation is off let's move everything to the left very good now we see that it doesn't know the variables Gro API key and model yet let's simply take the code snippet from our base example so that it gets the key from the environment okay but for this we need the OS Library we import OS briefly we get the model name again from our base example that looks good and last but not least we start processing our request and here we have the condition if a user question is there then we actually start the conversation this code processes a user's question through the conversation object stores both the users's question and the ai's response in chat history and then displays the ai's response on the screen let's move the user question of the input field down so that it's clear all right time to try it out oh we get an error message that it doesn't know Lang chain Gro well here we have the problem now that we didn't set up a virtual environment from the beginning so that the dependencies are clearly separated from each other we'll do that now so that we can install the libraries very cleanly within this project we have to install all libraries again but this time in our new virtual environment and not in the global one I'm lucky to still have the commands in the history and we started again and that looks good we can ask again what is the meaning of life and we get a wonderful answer okay now I also want to check if the memory is working well and for that I write once hello I am Sebastian and that he should please use my name in every answer and he confirms that and is pleased to meet and next I ask him whether he thinks it makes sense for developers to develop courses over Ai and perfect the answer already States it directly and he addresses me by my first name that means he hasn't forgotten who I am and that's great now we actually already have a kind of chat GPT which we completely control and which is much faster pretty cool

Original Description

💡 Liked this video? This was just the surface. Get the full code, deep-dive lessons, and premium projects here → https://ai-for-devs.com/youtube
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Playlist UUL_DTHlvMUDGnBV0_B7NTyQ · AI FOR DEVS · 1 of 46

← Previous Next →
Build LLama 3 Chatbot on Groq Cloud with INSANE 800 TOKENS per second!
Build LLama 3 Chatbot on Groq Cloud with INSANE 800 TOKENS per second!
AI FOR DEVS
2 Build a Terminator Vision and Voice System with GPT-4V & ElevenLabs
Build a Terminator Vision and Voice System with GPT-4V & ElevenLabs
AI FOR DEVS
3 GPT-4o API: Create Your Own Talking and Listening AI Girlfriend
GPT-4o API: Create Your Own Talking and Listening AI Girlfriend
AI FOR DEVS
4 Vision-based Web Scraping with the New GPT-4o model
Vision-based Web Scraping with the New GPT-4o model
AI FOR DEVS
5 Course Preview: Real-Time AI Mastery: Voice & Smart Assistants
Course Preview: Real-Time AI Mastery: Voice & Smart Assistants
AI FOR DEVS
6 Course Preview: AI Fundamentals
Course Preview: AI Fundamentals
AI FOR DEVS
7 GPT-4o API: Create Your Own Talking and Listening AI Girlfriend #gpt4o #ai  #chatgpt
GPT-4o API: Create Your Own Talking and Listening AI Girlfriend #gpt4o #ai #chatgpt
AI FOR DEVS
8 Preview: Build your own YODA with MemGPT & Elevenlabs
Preview: Build your own YODA with MemGPT & Elevenlabs
AI FOR DEVS
9 Creating an Illustrated Book with GPT-4o Autogen Studio
Creating an Illustrated Book with GPT-4o Autogen Studio
AI FOR DEVS
10 NEW Claude 3.5 Sonnet API: Build a Handwriting Analyzer Web App from Scratch
NEW Claude 3.5 Sonnet API: Build a Handwriting Analyzer Web App from Scratch
AI FOR DEVS
11 Groq API: Real-Time Chatting with All Your Podcasts & MP3s
Groq API: Real-Time Chatting with All Your Podcasts & MP3s
AI FOR DEVS
12 NEW Claude 3.5 Sonnet API: Create Your Own AI Book Author & Illustrator App
NEW Claude 3.5 Sonnet API: Create Your Own AI Book Author & Illustrator App
AI FOR DEVS
13 Build A Talking AI Agent with Claude 3.5 Sonnet - Python Tutorial
Build A Talking AI Agent with Claude 3.5 Sonnet - Python Tutorial
AI FOR DEVS
14 NEW GPT-4o Mini API - First Impressions: Real-World Use Cases … and Why It Beats GPT-4o
NEW GPT-4o Mini API - First Impressions: Real-World Use Cases … and Why It Beats GPT-4o
AI FOR DEVS
15 Building A LinkedIn Outreach AutoGen Workforce
Building A LinkedIn Outreach AutoGen Workforce
AI FOR DEVS
16 ClaudeDev: This Mind-Blowing Coding Agent Can Build SaaS Apps in Minutes!
ClaudeDev: This Mind-Blowing Coding Agent Can Build SaaS Apps in Minutes!
AI FOR DEVS
17 Watch Me Build an AI Chat Agent Solution for a Real Client
Watch Me Build an AI Chat Agent Solution for a Real Client
AI FOR DEVS
18 Build an Insane Realistic Uncensored Image Generator App with Cursor
Build an Insane Realistic Uncensored Image Generator App with Cursor
AI FOR DEVS
19 3 Cursor Hacks to Boost Your Development Speed
3 Cursor Hacks to Boost Your Development Speed
AI FOR DEVS
20 LLAMA 3.2 Just Dropped! Let's Build a Full-Stack App with Incredible VISION
LLAMA 3.2 Just Dropped! Let's Build a Full-Stack App with Incredible VISION
AI FOR DEVS
21 Run LLAMA 3.2 Models Locally with Ollama and Open WebUI
Run LLAMA 3.2 Models Locally with Ollama and Open WebUI
AI FOR DEVS
22 OpenAI Swarm - The New Groundbreaking AI Agent Framework
OpenAI Swarm - The New Groundbreaking AI Agent Framework
AI FOR DEVS
23 Enhancing OpenAI Swarm Agents with Real Business Data and Email Integration
Enhancing OpenAI Swarm Agents with Real Business Data and Email Integration
AI FOR DEVS
24 Building an OpenAI o1 Clone with Nemotron
Building an OpenAI o1 Clone with Nemotron
AI FOR DEVS
25 Building an OpenAI o1 Clone with Nemotron, RunPod, and Open WebUI
Building an OpenAI o1 Clone with Nemotron, RunPod, and Open WebUI
AI FOR DEVS
26 GROK 2: The Power—and Danger—of Uncensored AI
GROK 2: The Power—and Danger—of Uncensored AI
AI FOR DEVS
27 Magentic One: Microsoft’s Revolutionary Multi-Agent AI System
Magentic One: Microsoft’s Revolutionary Multi-Agent AI System
AI FOR DEVS
28 Building and Tracking AI Agents with LangChain and LangSmith
Building and Tracking AI Agents with LangChain and LangSmith
AI FOR DEVS
29 NEW Model Context Protocol Revolutionizes AI Database Access
NEW Model Context Protocol Revolutionizes AI Database Access
AI FOR DEVS
30 Claude MCP Step-by-Step: AI + Files + Search + Databases = Magic!
Claude MCP Step-by-Step: AI + Files + Search + Databases = Magic!
AI FOR DEVS
31 Claude MCP Step-by-Step: AI + Files + Search + Databases = Magic!
Claude MCP Step-by-Step: AI + Files + Search + Databases = Magic!
AI FOR DEVS
32 Magentic One: Microsoft’s Revolutionary Multi-Agent AI System
Magentic One: Microsoft’s Revolutionary Multi-Agent AI System
AI FOR DEVS
33 Turn Claude Into Your Ultimate AI Hub – Connect Anything with Custom MCP Servers!
Turn Claude Into Your Ultimate AI Hub – Connect Anything with Custom MCP Servers!
AI FOR DEVS
34 Build A Human-Like AI Agent That Feels Shockingly Real with Gemini 2.0 Flash API
Build A Human-Like AI Agent That Feels Shockingly Real with Gemini 2.0 Flash API
AI FOR DEVS
35 Build Real-World Apps with DeepSeek V3: 98% Cheaper & Better Than GPT
Build Real-World Apps with DeepSeek V3: 98% Cheaper & Better Than GPT
AI FOR DEVS
36 Build a Talking Smarter-Than-You AI Girlfriend (DeepSeek R1 Tutorial)
Build a Talking Smarter-Than-You AI Girlfriend (DeepSeek R1 Tutorial)
AI FOR DEVS
37 This AI Girlfriend is Smarter Than You (And She’s Not Nice) - DeepSeek R1 Tutorial
This AI Girlfriend is Smarter Than You (And She’s Not Nice) - DeepSeek R1 Tutorial
AI FOR DEVS
38 NEW Gemini 2.0 EXP is MIND-BLOWING: Create Children's Stories with YOUR CHARACTERS (API Tutorial)
NEW Gemini 2.0 EXP is MIND-BLOWING: Create Children's Stories with YOUR CHARACTERS (API Tutorial)
AI FOR DEVS
39 Gemini 2.5 Pro + Cursor + Custom MCP Server: The ULTIMATE AI Powerhouse!
Gemini 2.5 Pro + Cursor + Custom MCP Server: The ULTIMATE AI Powerhouse!
AI FOR DEVS
40 Manus AI: Building a Profitable AI Business from Scratch in 45 Min
Manus AI: Building a Profitable AI Business from Scratch in 45 Min
AI FOR DEVS
41 Run LLaMA 4 at Lightning Speed (Almost Free!)
Run LLaMA 4 at Lightning Speed (Almost Free!)
AI FOR DEVS
42 Coding Showdown: Building A Learning App - GPT-4.1 vs Sonnet 3.7
Coding Showdown: Building A Learning App - GPT-4.1 vs Sonnet 3.7
AI FOR DEVS
43 Is GPT 4.1 in Cursor the NEW KING? 👑 Coding Challenge vs Claude 3.7 Sonnet
Is GPT 4.1 in Cursor the NEW KING? 👑 Coding Challenge vs Claude 3.7 Sonnet
AI FOR DEVS
44 Build Your Own Video SaaS in Minutes with OpenAI Codex
Build Your Own Video SaaS in Minutes with OpenAI Codex
AI FOR DEVS
45 Build an AI Skin Improver SaaS with Cursor & MCP
Build an AI Skin Improver SaaS with Cursor & MCP
AI FOR DEVS
46 Einführung in LLMOps - Best Practices für Betrieb von LLMs
Einführung in LLMOps - Best Practices für Betrieb von LLMs
AI FOR DEVS

Related Reads

📰
Building an open-source offline voice assistant with Ollama—looking for contributors and brutally honest feedback
Learn how to build an open-source offline voice assistant using Ollama and contribute to the AURA project for a private and extensible AI experience
Dev.to AI
📰
Optimizing LLM Inference for Human-Computer Interaction
Optimize LLM inference for human-computer interaction to achieve low latency and high responsiveness, crucial for user experience
Dev.to AI
📰
AI Isn’t Smarter Than a Baby—Yet
Babies' brains may hold the key to advancing AI, learn how their learning mechanisms can inform AI development
Wired AI
📰
Open-Weight LLM API Integration: A Developer's Guide to Flexible AI Integration
Learn to integrate open-weight LLM APIs for flexible AI integration, enabling fine-grained control and vendor-agnostic solutions
Dev.to AI
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →