Skip to content

Commit

Permalink
add prints to text ingest
Browse files Browse the repository at this point in the history
  • Loading branch information
KastanDay committed Sep 27, 2023
1 parent b969ee4 commit 6585981
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ai_ta_backend/vector_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import time
import traceback
import uuid
from importlib import metadata
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import Any, Dict, List, Optional, Tuple, Union
Expand Down Expand Up @@ -537,10 +538,13 @@ def _ingest_single_txt(self, s3_path: str, course_name: str) -> str:
Returns:
str: "Success" or an error message
"""
print("In text ingest")
try:
# NOTE: slightly different method for .txt files, no need for download. It's part of the 'body'
response = self.s3_client.get_object(Bucket=os.environ['S3_BUCKET_NAME'], Key=s3_path)
print("s3 Resonse:", response)
text = response['Body'].read().decode('utf-8')
print("Text from s3:", text)
text = [text]

metadatas: List[Dict[str, Any]] = [{
Expand All @@ -552,6 +556,7 @@ def _ingest_single_txt(self, s3_path: str, course_name: str) -> str:
'url': '',
'base_url': '',
}]
print("Prior to ingest", metadatas)

success_or_failure = self.split_and_upload(texts=text, metadatas=metadatas)
return success_or_failure
Expand Down

0 comments on commit 6585981

Please sign in to comment.