File size: 3,994 Bytes
98346d0
 
 
0736eb7
 
98346d0
 
b4c8380
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
title: GenAI Toolkit
emoji: πŸ€–
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
---

# πŸ€– GenAI Toolkit

> A powerful, all-in-one Generative AI application combining multiple NLP features into a single, clean interface β€” powered by LangChain, LangGraph, and Groq LLaMA 3.

---

## 🌟 Features

| Feature | Description |
|---------|-------------|
| 🌐 **Language Translation** | Translate text across 20+ languages instantly |
| πŸ“ **Text Summarization** | Condense long documents using map-reduce chunking |
| πŸ” **Keyword Extraction** | Extract key topics and phrases from any text |
| βœ‰οΈ **Email Writer** | Generate professional emails and cover letters |
| πŸ’¬ **Chat Assistant** | Multi-turn AI conversations with memory |
| πŸ“„ **PDF Q&A** | Upload PDFs and ask questions using RAG |

---

## πŸ› οΈ Tech Stack

| Layer | Technology |
|-------|-----------|
| **LLM** | Groq LLaMA 3.3 70B + LLaMA 3.1 8B |
| **Orchestration** | LangChain + LangGraph |
| **Vector Store** | FAISS + HuggingFace Embeddings |
| **UI** | Gradio |
| **Deployment** | Docker + Hugging Face Spaces |

---

## πŸ—οΈ Architecture
GenAI-Toolkit/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ features/
β”‚   β”‚   β”œβ”€β”€ translation.py        # LangChain PromptTemplate
β”‚   β”‚   β”œβ”€β”€ summarization.py      # Map-Reduce summarization
β”‚   β”‚   β”œβ”€β”€ keyword_extraction.py # Structured output extraction
β”‚   β”‚   β”œβ”€β”€ email_writer.py       # Email + Cover letter generation
β”‚   β”‚   └── pdf_qa.py             # RAG pipeline with FAISS
β”‚   β”œβ”€β”€ graphs/
β”‚   β”‚   └── chat_graph.py         # LangGraph conversation graph
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ llm.py                # Groq LLM setup
β”‚   β”‚   └── vector_store.py       # FAISS vector store
β”‚   └── app.py                    # Gradio UI
β”œβ”€β”€ Dockerfile
└── requirements.txt

---

## πŸš€ How It Works

### Language Translation
Uses LangChain `PromptTemplate` with Groq LLaMA 3.1 to translate text between 20+ languages while preserving tone and context.

### Text Summarization
Implements **map-reduce chunking** β€” splits long documents into chunks, summarizes each chunk, then combines into a final summary. Handles documents of any length.

### Keyword Extraction
Uses structured LLM output to extract the most relevant keywords with context and relevance explanations.

### Email & Cover Letter Writer
Template-driven generation with customizable tone, email type, and recipient details. Cover letter writer tailors content to specific job roles and companies.

### Chat Assistant
Built with **LangGraph StateGraph** β€” maintains full conversation history across turns using a stateful graph architecture.

### PDF Q&A
Implements **RAG (Retrieval Augmented Generation)**:
1. Upload PDF β†’ extract text with PyMuPDF
2. Chunk text with RecursiveCharacterTextSplitter
3. Embed chunks with HuggingFace sentence-transformers
4. Store in FAISS vector store
5. Retrieve top-k relevant chunks per question
6. Generate answer with LangGraph agent

---

## πŸ”§ Local Setup

```bash
# Clone the repo
git clone https://github.com/shashankheg/GenAI-Toolkit.git
cd GenAI-Toolkit

# Create virtual environment
uv venv
.venv\Scripts\activate

# Install dependencies
uv pip install -r requirements.txt

# Add API key to .env
echo "GROQ_API_KEY=your-key-here" > .env

# Run the app
python -m src.app
```

---

## 🐳 Docker

```bash
docker build -t genai-toolkit .
docker run -p 7860:7860 -e GROQ_API_KEY=your-key genai-toolkit
```

---

## πŸ”‘ API Keys

- **Groq API** (free) β†’ https://console.groq.com
- No OpenAI key required β€” fully powered by Groq

---

## πŸ“Š Model Details

| Task | Model | Speed |
|------|-------|-------|
| Translation, Keywords, Email | LLaMA 3.1 8B Instant | ~0.5s |
| Summarization, Chat, PDF Q&A | LLaMA 3.3 70B Versatile | ~1-2s |

---

## πŸ‘¨β€πŸ’» Author


- HuggingFace: [@shashankheg](https://huggingface.co/shashankheg)