Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ai_ta_backend/database/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def __init__(self):
s3_config = {}

# If running against local MinIO
if os.environ.get("LOCAL_MINIO") == "true" and os.environ.get("MINIO_ENDPOINT"):
s3_config["endpoint_url"] = os.environ["MINIO_ENDPOINT"]
if os.environ.get("LOCAL_MINIO") == "true" and os.environ.get("MINIO_URL"):
s3_config["endpoint_url"] = os.environ["MINIO_URL"]

# AWS credentials
if os.environ.get("AWS_ACCESS_KEY_ID") and os.environ.get("AWS_SECRET_ACCESS_KEY"):
Expand Down
5 changes: 4 additions & 1 deletion ai_ta_backend/rabbitmq/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ def __init__(self):
# Temporarily raise indexing threshold during ingestion, then revert
self.qdrant_indexing_threshold_ingest = int(os.getenv('QDRANT_INDEXING_THRESHOLD_INGEST', '100000000'))
self.qdrant_indexing_threshold_online = int(os.getenv('QDRANT_INDEXING_THRESHOLD_ONLINE', '1000'))

# Embedding API retry configuration
self.embedding_max_attempts = int(os.getenv('EMBEDDING_MAX_ATTEMPTS', '10'))

def initialize_resources(self):
# Initialize Qdrant client and create collection if necessary
Expand Down Expand Up @@ -377,7 +380,7 @@ def split_and_upload(self, texts: List[str], metadatas: List[Dict[str, Any]], fo
max_requests_per_minute=10_000,
max_tokens_per_minute=10_000_000,
token_encoding_name='cl100k_base',
max_attempts=1_000,
max_attempts=self.embedding_max_attempts,
logging_level=logging.INFO,
model=self.embedding_model)
asyncio.run(oai.process_api_requests_from_file())
Expand Down
2 changes: 2 additions & 0 deletions ai_ta_backend/rabbitmq/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

BACKOFF_BASE = float(os.getenv('BACKOFF_BASE', '1.0')) # seconds
BACKOFF_MAX = float(os.getenv('BACKOFF_MAX', '30.0')) # seconds
PREFETCH_COUNT = int(os.getenv('RABBITMQ_PREFETCH_COUNT', '1')) # messages

stop_event = threading.Event()
worker_thread: threading.Thread | None = None
Expand Down Expand Up @@ -50,6 +51,7 @@ def connect(self):
self.connection = pika.BlockingConnection(parameters)
self.channel = self.connection.channel()
self.channel.queue_declare(queue=self.rabbitmq_queue, durable=True)
self.channel.basic_qos(prefetch_count=PREFETCH_COUNT)

def close(self):
try:
Expand Down
4 changes: 2 additions & 2 deletions ai_ta_backend/utils/pubmed_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# supabase_key=os.getenv('SUPABASE_API_KEY') # type: ignore
# )

# MINIO_CLIENT = Minio(os.environ['MINIO_ENDPOINT'],
# MINIO_CLIENT = Minio(os.environ['MINIO_URL'],
# access_key=os.environ['MINIO_ACCESS_KEY'],
# secret_key=os.environ['MINIO_SECRET'],
# secure=True)
Expand All @@ -52,7 +52,7 @@ def extractPubmedData():
)

if 'MINIO_CLIENT' not in globals():
MINIO_CLIENT = Minio(os.environ['MINIO_ENDPOINT'],
MINIO_CLIENT = Minio(os.environ['MINIO_URL'],
access_key=os.environ['MINIO_ACCESS_KEY'],
secret_key=os.environ['MINIO_SECRET'],
secure=True)
Expand Down
6 changes: 3 additions & 3 deletions ai_ta_backend/utils/pubmed_vectorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def extract_text_from_pdf(file_path, s3_path):
def process_pdf(key, bucket, temp_dir):
"""Process a single PDF file - for parallel execution"""
minio_client = Minio(
endpoint=os.environ['MINIO_ENDPOINT'],
endpoint=os.environ['MINIO_URL'],
access_key=os.environ['MINIO_ACCESS_KEY'],
secret_key=os.environ['MINIO_SECRET_KEY'],
secure=os.environ.get('MINIO_SECURE', 'false').lower() == 'true'
Expand Down Expand Up @@ -103,7 +103,7 @@ class MinioClient:
def __init__(self):
"""Initialize MinIO client."""
self.client = Minio(
endpoint=os.environ['MINIO_ENDPOINT'],
endpoint=os.environ['MINIO_URL'],
access_key=os.environ['MINIO_ACCESS_KEY'],
secret_key=os.environ['MINIO_SECRET_KEY'],
secure=os.environ.get('MINIO_SECURE', 'false').lower() == 'true'
Expand Down Expand Up @@ -280,4 +280,4 @@ def main():
print(f"❌ {r.filename} → {r.error_msg}")

if __name__ == "__main__":
main()
main()