Skip to content

Commit 7524da8

Browse files
chore: sync latest readme and docker-compose improvements
1 parent e974906 commit 7524da8

2 files changed

Lines changed: 47 additions & 27 deletions

File tree

agentic-rag-authorization/README.md

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,19 @@ The agent transparently explains access limitations instead of failing silently.
9292
### Steps
9393

9494
```bash
95-
# 1. Start services
95+
# 1. Configure
96+
cp .env.example .env
97+
# Edit .env with your actual OpenAI API key
98+
99+
# 2. Start services
96100
docker-compose up -d
97101

98-
# 2. Install dependencies
102+
# 3. Install dependencies
99103
python3 -m venv venv
100104
source venv/bin/activate
101105
pip install -r requirements.txt
102-
103-
# 3. Configure
104-
cp .env.example .env
105-
# Edit .env with your actual OpenAI API key (never commit .env!)
106-
107-
# 4. Initialize data
108-
python3 examples/setup_environment.py
109-
110-
# 5. Run demo
111-
python3 examples/basic_example.py
112106
```
113107

114-
115108
## Web UI
116109

117110
A web interface is available to demonstrate the authorization capabilities interactively.
@@ -121,7 +114,7 @@ A web interface is available to demonstrate the authorization capabilities inter
121114
```bash
122115
# 1. Ensure services are running and data is initialized
123116
docker-compose up -d
124-
python3 examples/setup_environment.py # If not already done
117+
python3 examples/setup_environment.py
125118

126119
# 2. Install web dependencies
127120
pip install -r requirements.txt # Includes fastapi and uvicorn
@@ -130,11 +123,29 @@ pip install -r requirements.txt # Includes fastapi and uvicorn
130123
python3 run_ui.py
131124
```
132125

133-
The launcher will:
134-
- ✅ Check that Weaviate, SpiceDB, and OpenAI are configured
135-
- ✅ Verify documents are loaded
136-
- 🚀 Start the FastAPI server
137-
- 🌐 Open your browser to http://localhost:8000
126+
The `setup-environment.py` file sets up Weaviate as the vector DB and SpiceDB with sample documents and department-based access control for the agentic RAG system.
127+
128+
We're creating a schema and writing relationships for a hierarchical permission model with users assigned to departments, department-wide document access, 3 cross-department collaboration grants, and 3 individual user exceptions.
129+
130+
The UI launcher will:
131+
- Verify documents are loaded
132+
- Starts the FastAPI server
133+
- Open your browser to http://localhost:8000
134+
135+
Here are few sample prompts you can run:
136+
137+
Choose "Bob" from "Sales" as the user and the query as "What are the company handbook guidelines?"
138+
139+
You should see:
140+
📊 Retrieved: 5
141+
✅ Authorized: 3
142+
❌ Denied: 2
143+
144+
Now run the same query as the "HR Manager". You should see:
145+
📊 Retrieved: 5
146+
✅ Authorized: 5
147+
❌ Denied: 0
148+
138149

139150
### Manual Start
140151

@@ -149,6 +160,16 @@ uvicorn api.main:app --reload --host 0.0.0.0 --port 8000
149160
open http://localhost:8000
150161
```
151162

163+
## Run Without UI
164+
165+
```
166+
# Initialize data
167+
python3 examples/setup_environment.py
168+
169+
# Run demo
170+
python3 examples/basic_example.py
171+
```
172+
152173
## How It Works
153174

154175
### 1. Authorization Model (SpiceDB)
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
---
21
version: '3.8'
32

43
services:
54
weaviate:
6-
image: "cr.weaviate.io/semitechnologies/weaviate:latest"
5+
image: cr.weaviate.io/semitechnologies/weaviate:latest
76
ports:
87
- "8080:8080" # HTTP and gRPC both use this port
98
environment:
@@ -13,19 +12,19 @@ services:
1312
DEFAULT_VECTORIZER_MODULE: 'text2vec-openai'
1413
ENABLE_MODULES: 'text2vec-openai'
1514
CLUSTER_HOSTNAME: 'node1'
16-
OPENAI_APIKEY: "${OPENAI_API_KEY}"
15+
OPENAI_APIKEY: ${OPENAI_API_KEY}
1716
volumes:
18-
- "weaviate_data:/var/lib/weaviate"
17+
- weaviate_data:/var/lib/weaviate
1918
env_file:
20-
- ".env"
19+
- .env
2120

2221
spicedb:
23-
image: "authzed/spicedb:latest"
24-
command: "serve --grpc-preshared-key \"devtoken\""
22+
image: authzed/spicedb:latest
23+
command: serve --grpc-preshared-key "devtoken"
2524
ports:
2625
- "50051:50051"
2726
environment:
28-
SPICEDB_DATASTORE_ENGINE: "memory"
27+
SPICEDB_DATASTORE_ENGINE: memory
2928

3029
volumes:
3130
weaviate_data:

0 commit comments

Comments
 (0)