openai compatible integration done
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
## Project Overview
|
||||
|
||||
This is a Retrieval-Augmented Generation (RAG) solution built using the Langchain framework. The project is designed to load documents from a data directory, store them in a vector database (Qdrant), and enable semantic search and chat capabilities using local LLMs via Ollama.
|
||||
This is a Retrieval-Augmented Generation (RAG) solution built using the Langchain framework. The project is designed to load documents from a data directory, store them in a vector database (Qdrant), and enable semantic search and chat capabilities using local LLMs via Ollama or OpenAI-compatible APIs.
|
||||
|
||||
The project follows a phased development approach with CLI entry points for different functionalities like document loading, retrieval, and chat.
|
||||
|
||||
@@ -10,7 +10,7 @@ The project follows a phased development approach with CLI entry points for diff
|
||||
- **Framework**: Langchain
|
||||
- **Vector Storage**: Qdrant
|
||||
- **Embeddings**: Ollama (with fallback option for OpenAI via OpenRouter)
|
||||
- **Chat Models**: Ollama
|
||||
- **Chat Models**: Ollama and OpenAI-compatible APIs
|
||||
- **Data Directory**: `./../../../data` (relative to project root)
|
||||
- **Virtual Environment**: Python venv in `venv/` directory
|
||||
|
||||
@@ -35,7 +35,7 @@ rag-solution/services/rag/langchain/
|
||||
## Dependencies
|
||||
|
||||
The project relies on several key libraries:
|
||||
- `langchain` and related ecosystem (`langchain-community`, `langchain-core`, `langchain-ollama`)
|
||||
- `langchain` and related ecosystem (`langchain-community`, `langchain-core`, `langchain-ollama`, `langchain-openai`)
|
||||
- `langgraph` for workflow management
|
||||
- `qdrant-client` for vector storage (to be installed)
|
||||
- `ollama` for local LLM interaction
|
||||
@@ -45,7 +45,7 @@ The project relies on several key libraries:
|
||||
|
||||
## Development Phases
|
||||
|
||||
The project is organized into 6 development phases as outlined in `PLANNING.md`:
|
||||
The project is organized into 8 development phases as outlined in `PLANNING.md`:
|
||||
|
||||
### Phase 1: CLI Entrypoint
|
||||
- [x] Virtual environment setup
|
||||
@@ -79,13 +79,25 @@ The project is organized into 6 development phases as outlined in `PLANNING.md`:
|
||||
- [x] Integrate with retrieval functionality
|
||||
- [x] Add CLI command for chat interaction
|
||||
|
||||
### Phase 7: OpenAI Integration for Chat Model
|
||||
- [x] Create OpenAI-compatible integration using `.env` variables `OPENAI_CHAT_URL` and `OPENAI_CHAT_KEY`
|
||||
- [x] Make this integration optional using `.env` variable `CHAT_MODEL_STRATEGY` with "ollama" as default
|
||||
- [x] Allow switching between "ollama" and "openai" strategies
|
||||
|
||||
### Phase 8: HTTP Endpoint
|
||||
- [ ] Create web framework with POST endpoint `/api/test-query` for agent queries
|
||||
|
||||
## Environment Configuration
|
||||
|
||||
The project uses environment variables for configuration:
|
||||
|
||||
```env
|
||||
OLLAMA_EMBEDDING_MODEL=MODEL # Name of the Ollama model for embeddings
|
||||
OLLAMA_CHAT_MODEL=MODEL # Name of the Ollama model for chat
|
||||
OLLAMA_EMBEDDING_MODEL=MODEL # Name of the Ollama model for embeddings
|
||||
OLLAMA_CHAT_MODEL=MODEL # Name of the Ollama model for chat
|
||||
OPENAI_CHAT_URL=URL # OpenAI-compatible API URL
|
||||
OPENAI_CHAT_KEY=KEY # Authorization token for OpenAI-compatible API
|
||||
OPENAI_CHAT_MODEL=MODEL # Name of the OpenAI-compatible model to use
|
||||
CHAT_MODEL_STRATEGY=ollama # Strategy to use: "ollama" (default) or "openai"
|
||||
```
|
||||
|
||||
## Building and Running
|
||||
@@ -176,6 +188,13 @@ The project is in early development phase. The virtual environment is set up and
|
||||
- Agent uses document retrieval tool to fetch relevant information based on user queries
|
||||
- Implemented proper error handling and conversation history management
|
||||
|
||||
### Phase 7 Implementation Notes
|
||||
- Enhanced `agent.py` to support both Ollama and OpenAI-compatible chat models
|
||||
- Added conditional logic to select chat model based on `CHAT_MODEL_STRATEGY` environment variable
|
||||
- When strategy is "openai", uses `ChatOpenAI` with `OPENAI_CHAT_URL` and `OPENAI_CHAT_KEY` from environment
|
||||
- When strategy is "ollama" (default), uses existing `ChatOllama` implementation
|
||||
- Updated CLI chat command to show which model strategy is being used
|
||||
|
||||
### Issue Fix Notes
|
||||
- Fixed DocumentRetrievalTool class to properly declare and initialize the retriever field
|
||||
- Resolved Pydantic field declaration issue that caused "object has no field" error
|
||||
|
||||
Reference in New Issue
Block a user