Skip to content

Commit af37695

Browse files
committed
Add command-line option for selecting embeddings backend (Oracle DB or ChromaDB). Oracle DB is now the default, with ChromaDB as fallback. Update documentation.
1 parent f193f3e commit af37695

File tree

2 files changed

+72
-4
lines changed

2 files changed

+72
-4
lines changed

agentic_rag/README.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ The system consists of several key components:
358358
1. **PDF Processor**: we use `docling` to extract and chunk text from PDF documents
359359
2. **Web Processor**: we use `trafilatura` to extract and chunk text from websites
360360
3. **GitHub Repository Processor**: we use `gitingest` to extract and chunk text from repositories
361-
4. **Vector Store**: Manages document embeddings and similarity search using `ChromaDB` and `Oracle Database 23ai`
361+
4. **Vector Store**: Manages document embeddings and similarity search using `Oracle Database 23ai` (default) or `ChromaDB` (fallback)
362362
5. **RAG Agent**: Makes intelligent decisions about query routing and response generation
363363
- OpenAI Agent: Uses `gpt-4-turbo-preview` for high-quality responses, but requires an OpenAI API key
364364
- Local Agent: Uses `Mistral-7B` as an open-source alternative
@@ -373,6 +373,50 @@ The RAG Agent flow is the following:
373373
4. If no PDF context is found OR if it's a general knowledge query, use the pre-trained LLM directly
374374
5. Fall back to a "no information" response only in edge cases.
375375

376+
## Annex: Command Line Usage
377+
378+
You can run the system from the command line using:
379+
380+
```bash
381+
python local_rag_agent.py --query "Your question here" [options]
382+
```
383+
384+
### Command Line Arguments
385+
386+
| Argument | Description | Default |
387+
| --- | --- | --- |
388+
| `--query` | The query to process | *Required* |
389+
| `--embeddings` | Select embeddings backend (`oracle` or `chromadb`) | `oracle` |
390+
| `--model` | Model to use for inference | `mistralai/Mistral-7B-Instruct-v0.2` |
391+
| `--collection` | Collection to query (PDF, Repository, Web, General) | Auto-determined |
392+
| `--use-cot` | Enable Chain of Thought reasoning | `False` |
393+
| `--store-path` | Path to ChromaDB store (if using ChromaDB) | `embeddings` |
394+
| `--skip-analysis` | Skip query analysis step | `False` |
395+
| `--verbose` | Show full content of sources | `False` |
396+
| `--quiet` | Disable verbose logging | `False` |
397+
398+
### Examples
399+
400+
Query using Oracle DB (default):
401+
```bash
402+
python local_rag_agent.py --query "How does vector search work?"
403+
```
404+
405+
Force using ChromaDB:
406+
```bash
407+
python local_rag_agent.py --query "How does vector search work?" --embeddings chromadb
408+
```
409+
410+
Query with Chain of Thought reasoning:
411+
```bash
412+
python local_rag_agent.py --query "Explain the difference between RAG and fine-tuning" --use-cot
413+
```
414+
415+
Query a specific collection:
416+
```bash
417+
python local_rag_agent.py --query "How to implement a queue?" --collection "Repository Collection"
418+
```
419+
376420
## Contributing
377421

378422
This project is open source. Please submit your contributions by forking this repository and submitting a pull request! Oracle appreciates any contributions that are made by the open source community.

agentic_rag/local_rag_agent.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ def main():
510510
help="Specify which collection to query")
511511
parser.add_argument("--skip-analysis", action="store_true", help="Skip query analysis step")
512512
parser.add_argument("--verbose", action="store_true", help="Show full content of sources")
513+
parser.add_argument("--embeddings", choices=["oracle", "chromadb"], default="oracle",
514+
help="Select embeddings backend (default: oracle)")
513515

514516
args = parser.parse_args()
515517

@@ -523,15 +525,37 @@ def main():
523525
print("=" * 50)
524526

525527
try:
526-
logger.info(f"Initializing vector store from: {args.store_path}")
527-
store = VectorStore(persist_directory=args.store_path)
528+
# Determine which vector store to use based on args.embeddings
529+
if args.embeddings == "oracle" and ORACLE_DB_AVAILABLE:
530+
try:
531+
logger.info("Initializing Oracle DB vector store")
532+
store = OraDBVectorStore()
533+
print("✓ Using Oracle DB for vector storage")
534+
except Exception as e:
535+
logger.warning(f"Failed to initialize Oracle DB: {str(e)}")
536+
logger.info(f"Falling back to ChromaDB from: {args.store_path}")
537+
store = VectorStore(persist_directory=args.store_path)
538+
print("⚠ Oracle DB initialization failed, using ChromaDB instead")
539+
else:
540+
if args.embeddings == "oracle" and not ORACLE_DB_AVAILABLE:
541+
logger.warning("Oracle DB support not available")
542+
print("⚠ Oracle DB support not available (missing dependencies)")
543+
544+
logger.info(f"Initializing ChromaDB vector store from: {args.store_path}")
545+
store = VectorStore(persist_directory=args.store_path)
546+
print("✓ Using ChromaDB for vector storage")
547+
528548
logger.info("Initializing local RAG agent...")
549+
# Set use_oracle_db based on the actual store type
550+
use_oracle_db = args.embeddings == "oracle" and isinstance(store, OraDBVectorStore)
551+
529552
agent = LocalRAGAgent(
530553
store,
531554
model_name=args.model,
532555
use_cot=args.use_cot,
533556
collection=args.collection,
534-
skip_analysis=args.skip_analysis
557+
skip_analysis=args.skip_analysis,
558+
use_oracle_db=use_oracle_db
535559
)
536560

537561
print(f"\nProcessing query: {args.query}")

0 commit comments

Comments
 (0)