Modified Document_processor to avoid tight coupling

This commit is contained in:
boladeE
2025-04-22 15:19:00 +01:00
parent 9259d61e96
commit f4cb9dfa92
+3 -3
View File
@@ -1,6 +1,6 @@
import cohere import cohere
import requests import requests
from typing import List, Dict, Any from typing import List, Dict, Any, Optional
import json import json
import os import os
import logging import logging
@@ -8,7 +8,7 @@ from services.config import config
from services.database import Database from services.database import Database
class DocumentProcessor: class DocumentProcessor:
def __init__(self, vector_store): def __init__(self, vector_store, database: Optional[Database] = None):
self.vector_store = vector_store self.vector_store = vector_store
self.cohere_client = cohere.Client(config.COHERE_API_KEY) self.cohere_client = cohere.Client(config.COHERE_API_KEY)
self.deepseek_url = "https://api.deepseek.com/v1/chat/completions" self.deepseek_url = "https://api.deepseek.com/v1/chat/completions"
@@ -16,7 +16,7 @@ class DocumentProcessor:
"Authorization": f"Bearer {config.DEEPSEEK_API_KEY}", "Authorization": f"Bearer {config.DEEPSEEK_API_KEY}",
"Content-Type": "application/json" "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): async def process_document(self, doc_id: str, file_path: str, document_type: str, is_resubmission: bool = False):