beerohan commited on
Commit
3a72e1d
Β·
1 Parent(s): 480d354

Rename to studyrag, switch to Groq API, add deployment files

Browse files
studyrag/.env.example ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ GROQ_API_KEY=your_groq_api_key_here
2
+ PORT=8000
3
+ HOST=0.0.0.0
{docsense-rag β†’ studyrag}/.gitignore RENAMED
File without changes
{docsense-rag β†’ studyrag}/Dockerfile RENAMED
File without changes
studyrag/Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8000}
{docsense-rag β†’ studyrag}/README.md RENAMED
@@ -52,7 +52,7 @@ A full-stack Retrieval-Augmented Generation (RAG) system for intelligent documen
52
  1. **Clone the repository**
53
  ```bash
54
  git clone <repository-url>
55
- cd docsense-rag
56
  ```
57
 
58
  2. **Create virtual environment**
@@ -208,7 +208,7 @@ GET /status
208
  ## Project Structure
209
 
210
  ```
211
- docsense-rag/
212
  β”œβ”€β”€ app/
213
  β”‚ β”œβ”€β”€ __init__.py
214
  β”‚ β”œβ”€β”€ main.py # FastAPI application
 
52
  1. **Clone the repository**
53
  ```bash
54
  git clone <repository-url>
55
+ cd studyrag
56
  ```
57
 
58
  2. **Create virtual environment**
 
208
  ## Project Structure
209
 
210
  ```
211
+ studyrag/
212
  β”œβ”€β”€ app/
213
  β”‚ β”œβ”€β”€ __init__.py
214
  β”‚ β”œβ”€β”€ main.py # FastAPI application
{docsense-rag β†’ studyrag}/app/__init__.py RENAMED
File without changes
{docsense-rag β†’ studyrag}/app/config.py RENAMED
@@ -3,7 +3,7 @@ from pathlib import Path
3
 
4
 
5
  class Settings(BaseSettings):
6
- google_api_key: str
7
  host: str = "0.0.0.0"
8
  port: int = 8000
9
  upload_dir: Path = Path("uploads")
 
3
 
4
 
5
  class Settings(BaseSettings):
6
+ groq_api_key: str
7
  host: str = "0.0.0.0"
8
  port: int = 8000
9
  upload_dir: Path = Path("uploads")
{docsense-rag β†’ studyrag}/app/main.py RENAMED
@@ -179,9 +179,11 @@ async def reset_index():
179
  try:
180
  rag_service.reset_index()
181
 
182
- for file_path in settings.upload_dir.glob("*"):
183
- if file_path.is_file():
184
- file_path.unlink()
 
 
185
 
186
  return StatusResponse(
187
  status="success",
 
179
  try:
180
  rag_service.reset_index()
181
 
182
+ # Only try to delete files if uploads directory exists
183
+ if settings.upload_dir.exists():
184
+ for file_path in settings.upload_dir.glob("*"):
185
+ if file_path.is_file():
186
+ file_path.unlink()
187
 
188
  return StatusResponse(
189
  status="success",
{docsense-rag β†’ studyrag}/app/models/__init__.py RENAMED
File without changes
{docsense-rag β†’ studyrag}/app/models/schemas.py RENAMED
File without changes
{docsense-rag β†’ studyrag}/app/services/__init__.py RENAMED
File without changes
{docsense-rag β†’ studyrag}/app/services/rag_service.py RENAMED
@@ -1,5 +1,5 @@
1
  from llama_index.core import VectorStoreIndex, Document, Settings
2
- from llama_index.llms.gemini import Gemini
3
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
4
  from llama_index.core.chat_engine import CondensePlusContextChatEngine
5
  from typing import Optional, AsyncGenerator, List
@@ -11,7 +11,7 @@ import os
11
  class RAGService:
12
 
13
  def __init__(self):
14
- os.environ["GOOGLE_API_KEY"] = settings.google_api_key
15
  self._llm_initialized = False
16
  self.index: Optional[VectorStoreIndex] = None
17
  self.chat_engine = None
@@ -19,8 +19,8 @@ class RAGService:
19
 
20
  def _initialize_llm(self):
21
  if not self._llm_initialized:
22
- Settings.llm = Gemini(model="models/gemini-2.5-flash")
23
- # Use local HuggingFace embeddings to avoid API quota limits
24
  Settings.embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
25
  self._llm_initialized = True
26
 
 
1
  from llama_index.core import VectorStoreIndex, Document, Settings
2
+ from llama_index.llms.groq import Groq
3
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
4
  from llama_index.core.chat_engine import CondensePlusContextChatEngine
5
  from typing import Optional, AsyncGenerator, List
 
11
  class RAGService:
12
 
13
  def __init__(self):
14
+ os.environ["GROQ_API_KEY"] = settings.groq_api_key
15
  self._llm_initialized = False
16
  self.index: Optional[VectorStoreIndex] = None
17
  self.chat_engine = None
 
19
 
20
  def _initialize_llm(self):
21
  if not self._llm_initialized:
22
+ Settings.llm = Groq(model="llama-3.1-8b-instant", api_key=settings.groq_api_key)
23
+ # Use local HuggingFace embeddings (free, no API needed)
24
  Settings.embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
25
  self._llm_initialized = True
26
 
{docsense-rag β†’ studyrag}/app/utils/__init__.py RENAMED
File without changes
{docsense-rag β†’ studyrag}/app/utils/document_processor.py RENAMED
File without changes
{docsense-rag β†’ studyrag}/docker-compose.yml RENAMED
@@ -1,12 +1,12 @@
1
  version: '3.8'
2
 
3
  services:
4
- docsense-rag:
5
  build: .
6
  ports:
7
  - "8000:8000"
8
  environment:
9
- - GOOGLE_API_KEY=${GOOGLE_API_KEY}
10
  - HOST=0.0.0.0
11
  - PORT=8000
12
  volumes:
 
1
  version: '3.8'
2
 
3
  services:
4
+ studyrag:
5
  build: .
6
  ports:
7
  - "8000:8000"
8
  environment:
9
+ - GROQ_API_KEY=${GROQ_API_KEY}
10
  - HOST=0.0.0.0
11
  - PORT=8000
12
  volumes:
{docsense-rag β†’ studyrag}/requirements.txt RENAMED
@@ -2,8 +2,7 @@ fastapi>=0.115.0
2
  uvicorn[standard]>=0.32.0
3
  python-multipart>=0.0.12
4
  llama-index>=0.12.0
5
- llama-index-llms-gemini>=0.6.0
6
- llama-index-embeddings-gemini>=0.3.0
7
  llama-index-embeddings-huggingface>=0.4.0
8
  pypdf>=5.1.0
9
  pymupdf>=1.24.0
 
2
  uvicorn[standard]>=0.32.0
3
  python-multipart>=0.0.12
4
  llama-index>=0.12.0
5
+ llama-index-llms-groq>=0.3.0
 
6
  llama-index-embeddings-huggingface>=0.4.0
7
  pypdf>=5.1.0
8
  pymupdf>=1.24.0
studyrag/runtime.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.11
{docsense-rag β†’ studyrag}/static/css/style.css RENAMED
File without changes
{docsense-rag β†’ studyrag}/static/index.html RENAMED
File without changes
{docsense-rag β†’ studyrag}/static/js/app.js RENAMED
@@ -325,15 +325,8 @@ resetBtn.addEventListener('click', async () => {
325
 
326
  if (response.ok) {
327
  alert(data.message);
328
- chatMessages.innerHTML = `
329
- <div class="empty-state">
330
- <div class="empty-icon">πŸ’¬</div>
331
- <h3>Start a Conversation</h3>
332
- <p>Ask me anything about your indexed documents</p>
333
- </div>
334
- `;
335
- clearAllResults();
336
- await updateStatus();
337
  } else {
338
  alert(data.detail || 'Reset failed');
339
  }
 
325
 
326
  if (response.ok) {
327
  alert(data.message);
328
+ // Force page reload to clear all state
329
+ window.location.reload();
 
 
 
 
 
 
 
330
  } else {
331
  alert(data.detail || 'Reset failed');
332
  }