Skip to content

Commit 58dba31

Browse files
committed
feat: Make OpenAI optional and use local model by default - Update main.py to use LocalRAGAgent when no OpenAI key is present Update README to reflect that OpenAI is optional - Make Mistral-7B the default RAG model
1 parent 31e7aac commit 58dba31

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

agentic_rag/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The system has the following features:
99
- Persistent vector storage with ChromaDB
1010
- Smart context retrieval and response generation
1111
- FastAPI-based REST API
12-
- Support for both OpenAI-based agents or local, transformer-based agents
12+
- Support for both OpenAI-based agents or local, transformer-based agents (Mistral-7B by default)
1313

1414
## Setup
1515

@@ -21,13 +21,15 @@ The system has the following features:
2121
pip install -r requirements.txt
2222
```
2323

24-
2. In case you're going to use the OpenAI-based agent, create a `.env` file with your OpenAI API key:
24+
2. (Optional) If you want to use the OpenAI-based agent instead of the default local model, create a `.env` file with your OpenAI API key:
2525

2626
```bash
2727
OPENAI_API_KEY=your-api-key-here
2828
```
2929

30-
3. If you're planning to use the local open-source model alternative for RAG, there's no additional configuration needed. The system will automatically use `Mistral-7B-Instruct-v0.2` for text generation.
30+
If no API key is provided, the system will automatically use the local Mistral-7B model for text generation.
31+
32+
3. The system will automatically download and use `Mistral-7B-Instruct-v0.2` for text generation when using the local model. No additional configuration is needed.
3133

3234
## 1. Getting Started
3335

agentic_rag/main.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from pdf_processor import PDFProcessor
1010
from store import VectorStore
11+
from local_rag_agent import LocalRAGAgent
1112
from rag_agent import RAGAgent
1213

1314
# Load environment variables
@@ -32,10 +33,15 @@
3233
# Initialize components
3334
pdf_processor = PDFProcessor()
3435
vector_store = VectorStore()
35-
rag_agent = RAGAgent(
36-
vector_store=vector_store,
37-
openai_api_key=os.getenv("OPENAI_API_KEY")
38-
)
36+
37+
# Initialize RAG agent - use OpenAI if API key is available, otherwise use local model
38+
openai_api_key = os.getenv("OPENAI_API_KEY")
39+
if openai_api_key:
40+
print("\nUsing OpenAI GPT-4 for RAG...")
41+
rag_agent = RAGAgent(vector_store=vector_store, openai_api_key=openai_api_key)
42+
else:
43+
print("\nOpenAI API key not found. Using local Mistral model for RAG...")
44+
rag_agent = LocalRAGAgent(vector_store=vector_store)
3945

4046
class QueryRequest(BaseModel):
4147
query: str

0 commit comments

Comments
 (0)