Léo Bourrel commited on
Commit
1bf2e1f
·
1 Parent(s): 5ef0b6a

feat: rename vector store

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. custom_pgvector.py → vector_store.py +4 -4
app.py CHANGED
@@ -11,7 +11,7 @@ from langchain.llms import OpenAI
11
 
12
  from chat_history import insert_chat_history, insert_chat_history_articles
13
  from css import load_css
14
- from custom_pgvector import CustomPGVector
15
  from message import Message
16
  from connection import connect
17
 
@@ -32,7 +32,7 @@ def initialize_session_state():
32
  if "conversation" not in st.session_state:
33
  embeddings = GPT4AllEmbeddings()
34
 
35
- db = CustomPGVector(
36
  embedding_function=embeddings,
37
  table_name="article",
38
  column_name="abstract_embedding",
 
11
 
12
  from chat_history import insert_chat_history, insert_chat_history_articles
13
  from css import load_css
14
+ from custom_pgvector import CustomVectorStore
15
  from message import Message
16
  from connection import connect
17
 
 
32
  if "conversation" not in st.session_state:
33
  embeddings = GPT4AllEmbeddings()
34
 
35
+ db = CustomVectorStore(
36
  embedding_function=embeddings,
37
  table_name="article",
38
  column_name="abstract_embedding",
custom_pgvector.py → vector_store.py RENAMED
@@ -27,7 +27,7 @@ def _results_to_docs(docs_and_scores: Any) -> List[Document]:
27
  return [doc for doc, _ in docs_and_scores]
28
 
29
 
30
- class CustomPGVector(VectorStore):
31
  """`Postgres`/`PGVector` vector store.
32
 
33
  To use, you should have the ``pgvector`` python package installed.
@@ -141,7 +141,7 @@ class CustomPGVector(VectorStore):
141
  connection_string: Optional[str] = None,
142
  pre_delete_collection: bool = False,
143
  **kwargs: Any,
144
- ) -> CustomPGVector:
145
  if not metadatas:
146
  metadatas = [{} for _ in texts]
147
  if connection_string is None:
@@ -381,7 +381,7 @@ class CustomPGVector(VectorStore):
381
 
382
  @classmethod
383
  def from_texts(
384
- cls: Type[CustomPGVector],
385
  texts: List[str],
386
  embedding: Embeddings,
387
  metadatas: Optional[List[dict]] = None,
@@ -390,7 +390,7 @@ class CustomPGVector(VectorStore):
390
  ids: Optional[List[str]] = None,
391
  pre_delete_collection: bool = False,
392
  **kwargs: Any,
393
- ) -> CustomPGVector:
394
  """
395
  Return VectorStore initialized from texts and embeddings.
396
  Postgres connection string is required
 
27
  return [doc for doc, _ in docs_and_scores]
28
 
29
 
30
+ class CustomVectorStore(VectorStore):
31
  """`Postgres`/`PGVector` vector store.
32
 
33
  To use, you should have the ``pgvector`` python package installed.
 
141
  connection_string: Optional[str] = None,
142
  pre_delete_collection: bool = False,
143
  **kwargs: Any,
144
+ ) -> CustomVectorStore:
145
  if not metadatas:
146
  metadatas = [{} for _ in texts]
147
  if connection_string is None:
 
381
 
382
  @classmethod
383
  def from_texts(
384
+ cls: Type[CustomVectorStore],
385
  texts: List[str],
386
  embedding: Embeddings,
387
  metadatas: Optional[List[dict]] = None,
 
390
  ids: Optional[List[str]] = None,
391
  pre_delete_collection: bool = False,
392
  **kwargs: Any,
393
+ ) -> CustomVectorStore:
394
  """
395
  Return VectorStore initialized from texts and embeddings.
396
  Postgres connection string is required