From f4cb9dfa92ee956ff1272f4f96e82c9bac01230c Mon Sep 17 00:00:00 2001 From: boladeE Date: Tue, 22 Apr 2025 15:19:00 +0100 Subject: [PATCH] Modified Document_processor to avoid tight coupling --- src/services/document_processor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/document_processor.py b/src/services/document_processor.py index fef88b5..c5afb8b 100644 --- a/src/services/document_processor.py +++ b/src/services/document_processor.py @@ -1,6 +1,6 @@ import cohere import requests -from typing import List, Dict, Any +from typing import List, Dict, Any, Optional import json import os import logging @@ -8,7 +8,7 @@ from services.config import config from services.database import Database class DocumentProcessor: - def __init__(self, vector_store): + def __init__(self, vector_store, database: Optional[Database] = None): self.vector_store = vector_store self.cohere_client = cohere.Client(config.COHERE_API_KEY) self.deepseek_url = "https://api.deepseek.com/v1/chat/completions" @@ -16,7 +16,7 @@ class DocumentProcessor: "Authorization": f"Bearer {config.DEEPSEEK_API_KEY}", "Content-Type": "application/json" } - self.database = Database() + self.database = Database() or database async def process_document(self, doc_id: str, file_path: str, document_type: str, is_resubmission: bool = False):