Modified Document_processor to avoid tight coupling
This commit is contained in:
@@ -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):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user