File size: 2,305 Bytes
296d10f
f792b11
3a36ea1
296d10f
3a36ea1
296d10f
506e6b6
296d10f
 
 
ffddeed
296d10f
 
f792b11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
title: Groq-LLaMA3.x
emoji: πŸ“š
colorFrom: yellow
colorTo: blue
sdk: streamlit
sdk_version: 1.41.1
app_file: app.py
pinned: false
license: mit
short_description: Groq & Llama3.x updated
---

# Groq Chat with LLaMA3x

A Streamlit-based chat application that leverages Groq's API to interact with LLaMA3x models.

## Features

### Model Integration
- Seamless integration with Groq's LLaMA3x model family
- Dynamic model selection from available LLaMA variants
- Automatic model metadata fetching and display
- Model-specific token limit handling

### Chat Interface
- Real-time streaming responses with character-by-character display
- Non-streaming mode for batch responses
- Persistent chat history with session management
- Clear chat functionality
- User-friendly message input system
- Distinct avatars for user (πŸ§‘β€πŸ’») and assistant (πŸ”‹) messages

### Performance Controls
- Adjustable token limit slider with model-specific maximums
- Toggle between streaming and non-streaming modes
- Automatic session state management
- Error handling with user-friendly error messages

### Usage Analytics
- Real-time token usage tracking
  - Prompt tokens
  - Response tokens
  - Total tokens used
- Performance timing metrics
  - Prompt processing time
  - Response generation time
  - Total interaction time

### UI/UX Features
- Responsive wide-layout design
- Sidebar with model controls and settings
- Groq branding integration
- Important disclaimer for AI-generated content
- Clear visual hierarchy with markdown formatting

## Prerequisites

- Python 3.7+
- Groq API key
- Required Python packages:
  - streamlit
  - groq
  - python-dotenv

## Installation

1. Clone the repository
2. Install dependencies:
```bash
pip install streamlit groq python-dotenv
```
3. Create a `.env` file and add your Groq API key:
```
GROQ_API_KEY=your_api_key_here
```

## Usage

Run the application:
```bash
streamlit run app.py
```

The app will open in your default browser, featuring:
- Model selection dropdown
- Adjustable token limit slider
- Streaming mode toggle
- Clear chat functionality
- Real-time usage statistics

## Security Note

Always keep your API key secure and never commit it to version control. The application uses environment variables for sensitive data management.

## License

MIT