Removed magic number 3 by using a settings const

This commit is contained in:
henri123lemoine
2023-06-27 07:34:14 -04:00
parent 11dc2dd6c1
commit 49e9f08cf5
2 changed files with 7 additions and 4 deletions
+4 -1
View File
@@ -18,4 +18,7 @@ EMBEDDINGS_RATE_LIMIT = 3500
PINECONE_INDEX_NAME = "stampy-chat-embeddings-test"
PINECONE_VALUES_DIMS = EMBEDDINGS_DIMS
PINECONE_METRIC = "cosine"
PINECONE_METADATA_ENTRIES = ["entry_id", "source", "title", "authors", "text"]
PINECONE_METADATA_ENTRIES = ["entry_id", "source", "title", "authors", "text"]
### MISCELLANEOUS ###
MAX_NUM_AUTHORS_IN_SIGNATURE = 3
+3 -3
View File
@@ -10,7 +10,7 @@ from .text_splitter import TokenSplitter
from .sql_db_handler import SQLDB
from .pinecone_db_handler import PineconeDB
from .settings import EMBEDDINGS_MODEL, EMBEDDINGS_DIMS, EMBEDDINGS_RATE_LIMIT, ARD_DATASET_NAME
from .settings import EMBEDDINGS_MODEL, EMBEDDINGS_DIMS, EMBEDDINGS_RATE_LIMIT, ARD_DATASET_NAME, MAX_NUM_AUTHORS_IN_SIGNATURE
import logging
logger = logging.getLogger(__name__)
@@ -114,6 +114,6 @@ def get_authors_str(authors_lst: List[str]) -> str:
if authors_lst == []: return 'n/a'
if len(authors_lst) == 1: return authors_lst[0]
else:
authors_lst = authors_lst[:3]
authors_str = ", ".join(authors_lst[:-1]) + " and " + authors_lst[-1]
authors_lst = authors_lst[:MAX_NUM_AUTHORS_IN_SIGNATURE]
authors_str = f"{', '.join(authors_lst[:-1])} and {authors_lst[-1]}"
return authors_str