From f101e3dd33d2eb64f5aaded33c1a0dc1841f4b3f Mon Sep 17 00:00:00 2001 From: Ismail Pelaseyed Date: Thu, 15 Feb 2024 09:44:56 -0800 Subject: [PATCH] Fix formatting --- api/ingest.py | 3 +-- models/query.py | 2 +- service/embedding.py | 15 +++++++-------- vectordbs/__init__.py | 1 + vectordbs/astra.py | 2 +- vectordbs/base.py | 2 +- vectordbs/pinecone.py | 2 +- vectordbs/qdrant.py | 2 +- vectordbs/weaviate.py | 2 +- 9 files changed, 15 insertions(+), 16 deletions(-) diff --git a/api/ingest.py b/api/ingest.py index 0aa454c6..1bc06c7d 100644 --- a/api/ingest.py +++ b/api/ingest.py @@ -24,8 +24,7 @@ async def ingest(payload: RequestPayload) -> Dict: summary_documents = await embedding_service.generate_summary_documents( documents=chunks ) - print(summary_documents) - return {"success": True} + await asyncio.gather( embedding_service.generate_and_upsert_embeddings( documents=chunks, encoder=encoder, index_name=payload.index_name diff --git a/models/query.py b/models/query.py index 9d2a897e..58a3128a 100644 --- a/models/query.py +++ b/models/query.py @@ -2,7 +2,7 @@ from pydantic import BaseModel -from models.ingest import EncoderEnum, Encoder +from models.ingest import Encoder from models.vector_database import VectorDatabase diff --git a/service/embedding.py b/service/embedding.py index 25ad0481..037592d4 100644 --- a/service/embedding.py +++ b/service/embedding.py @@ -6,21 +6,20 @@ import numpy as np import requests -from tqdm import tqdm -from unstructured.chunking.title import chunk_by_title -from unstructured.documents.elements import Element -from unstructured.partition.auto import partition - - from semantic_router.encoders import ( BaseEncoder, CohereEncoder, - OpenAIEncoder, HuggingFaceEncoder, + OpenAIEncoder, ) +from tqdm import tqdm +from unstructured.chunking.title import chunk_by_title +from unstructured.documents.elements import Element +from unstructured.partition.auto import partition + from models.document import BaseDocument, BaseDocumentChunk from models.file import File -from models.ingest import EncoderEnum, Encoder +from models.ingest import Encoder, EncoderEnum from utils.logger import logger from utils.summarise import completion from vectordbs import get_vector_service diff --git a/vectordbs/__init__.py b/vectordbs/__init__.py index 970efbed..0e082372 100644 --- a/vectordbs/__init__.py +++ b/vectordbs/__init__.py @@ -3,6 +3,7 @@ from dotenv import load_dotenv from semantic_router.encoders import BaseEncoder from semantic_router.encoders.openai import OpenAIEncoder + from models.vector_database import VectorDatabase from vectordbs.astra import AstraService from vectordbs.base import BaseVectorDatabase diff --git a/vectordbs/astra.py b/vectordbs/astra.py index 5a3785e8..78cb3200 100644 --- a/vectordbs/astra.py +++ b/vectordbs/astra.py @@ -1,9 +1,9 @@ from typing import List from astrapy.db import AstraDB +from semantic_router.encoders import BaseEncoder from tqdm import tqdm -from semantic_router.encoders import BaseEncoder from models.document import BaseDocumentChunk from vectordbs.base import BaseVectorDatabase diff --git a/vectordbs/base.py b/vectordbs/base.py index b515faf7..0f3203c2 100644 --- a/vectordbs/base.py +++ b/vectordbs/base.py @@ -2,9 +2,9 @@ from typing import List from decouple import config +from semantic_router.encoders import BaseEncoder from tqdm import tqdm -from semantic_router.encoders import BaseEncoder from models.delete import DeleteResponse from models.document import BaseDocumentChunk from utils.logger import logger diff --git a/vectordbs/pinecone.py b/vectordbs/pinecone.py index 0e1e77e9..606b339e 100644 --- a/vectordbs/pinecone.py +++ b/vectordbs/pinecone.py @@ -1,9 +1,9 @@ from typing import List from pinecone import Pinecone, ServerlessSpec +from semantic_router.encoders import BaseEncoder from tqdm import tqdm -from semantic_router.encoders import BaseEncoder from models.delete import DeleteResponse from models.document import BaseDocumentChunk from utils.logger import logger diff --git a/vectordbs/qdrant.py b/vectordbs/qdrant.py index f70587ed..ad7cc868 100644 --- a/vectordbs/qdrant.py +++ b/vectordbs/qdrant.py @@ -2,9 +2,9 @@ from qdrant_client import QdrantClient from qdrant_client.http import models as rest +from semantic_router.encoders import BaseEncoder from tqdm import tqdm -from semantic_router.encoders import BaseEncoder from models.document import BaseDocumentChunk from vectordbs.base import BaseVectorDatabase diff --git a/vectordbs/weaviate.py b/vectordbs/weaviate.py index 1c9f5262..59cf0169 100644 --- a/vectordbs/weaviate.py +++ b/vectordbs/weaviate.py @@ -2,9 +2,9 @@ from typing import List import weaviate +from semantic_router.encoders import BaseEncoder from tqdm import tqdm -from semantic_router.encoders import BaseEncoder from models.delete import DeleteResponse from models.document import BaseDocumentChunk from utils.logger import logger