Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Vector database index name #37

Merged
merged 2 commits into from
Feb 13, 2024
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
venv
.venv
.env
__pycache__/
```
3 changes: 2 additions & 1 deletion api/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from models.ingest import RequestPayload
from service.embedding import EmbeddingService, get_encoder
from utils.summarise import SUMMARY_SUFFIX

router = APIRouter()

Expand Down Expand Up @@ -37,7 +38,7 @@ async def ingest(payload: RequestPayload) -> Dict:
embedding_service.generate_embeddings(
nodes=summary_chunks,
encoder=encoder,
index_name=f"{payload.index_name}-summary",
index_name=f"{payload.index_name}-{SUMMARY_SUFFIX}",
),
)

Expand Down
3 changes: 2 additions & 1 deletion service/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from models.query import RequestPayload
from service.embedding import get_encoder
from service.vector_database import VectorService, get_vector_service
from utils.summarise import SUMMARY_SUFFIX


def create_route_layer() -> RouteLayer:
Expand Down Expand Up @@ -48,7 +49,7 @@ async def query(payload: RequestPayload) -> List:

if decision == "summarize":
vector_service: VectorService = get_vector_service(
index_name=f"{payload.index_name}summary",
index_name=f"{payload.index_name}-{SUMMARY_SUFFIX}",
credentials=payload.vector_database,
encoder=encoder,
)
Expand Down
3 changes: 3 additions & 0 deletions utils/summarise.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def _generate_content(document: Document) -> str:
Your summary:"""


SUMMARY_SUFFIX = "summary"


async def completion(document: Document):
content = _generate_content(document)
completion = await client.chat.completions.create(
Expand Down