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

Add support for semantic-router encoders #45

Merged
merged 2 commits into from
Feb 15, 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
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ Input example:
}
},
"index_name": "my_index",
"encoder": "my_encoder"
"encoder": {
"type": "openai",
"name": "text-embedding-3-small",
"dimensions": 1536 # encoder depends on the provider and model
},
"webhook_url": "https://my-webhook-url"
}
```
Expand All @@ -42,7 +46,10 @@ Input example:
}
},
"index_name": "my_index",
"encoder": "my_encoder",
"encoder": {
"type": "openai",
"name": "text-embedding-3-small",
}
}
```

Expand Down
3 changes: 2 additions & 1 deletion api/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

@router.delete("/delete", response_model=ResponsePayload)
async def delete(payload: RequestPayload):
encoder = get_encoder(encoder_type=payload.encoder)
encoder = get_encoder(encoder_config=payload.encoder)
vector_service: BaseVectorDatabase = get_vector_service(
index_name=payload.index_name,
credentials=payload.vector_database,
encoder=encoder,
dimensions=encoder.dimensions,
)
data = await vector_service.delete(file_url=payload.file_url)
return ResponsePayload(success=True, data=data)
3 changes: 2 additions & 1 deletion api/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ async def ingest(payload: RequestPayload) -> Dict:
files=payload.files,
index_name=payload.index_name,
vector_credentials=payload.vector_database,
dimensions=payload.encoder.dimensions,
)
chunks = await embedding_service.generate_chunks()
encoder = get_encoder(encoder_type=payload.encoder)
encoder = get_encoder(encoder_config=payload.encoder)
summary_documents = await embedding_service.generate_summary_documents(
documents=chunks
)
Expand Down
13 changes: 0 additions & 13 deletions encoders/__init__.py

This file was deleted.

16 changes: 0 additions & 16 deletions encoders/base.py

This file was deleted.

67 changes: 0 additions & 67 deletions encoders/bm25.py

This file was deleted.

40 changes: 0 additions & 40 deletions encoders/cohere.py

This file was deleted.

114 changes: 0 additions & 114 deletions encoders/huggingface.py

This file was deleted.

65 changes: 0 additions & 65 deletions encoders/openai.py

This file was deleted.

4 changes: 2 additions & 2 deletions models/delete.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from pydantic import BaseModel

from models.ingest import EncoderEnum
from models.ingest import Encoder
from models.vector_database import VectorDatabase


class RequestPayload(BaseModel):
index_name: str
file_url: str
vector_database: VectorDatabase
encoder: EncoderEnum
encoder: Encoder


class DeleteResponse(BaseModel):
Expand Down
Loading