Skip to content

Commit

Permalink
Merge pull request #263 from aurelio-labs/james/encoder-disallowed-sp…
Browse files Browse the repository at this point in the history
…ecial

fix: James/encoder disallowed special
  • Loading branch information
jamescalam authored Apr 28, 2024
2 parents eb9ebe3 + cc1430d commit 29762f0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "semantic-router"
version = "0.0.36"
version = "0.0.37"
description = "Super fast semantic router for AI decision making"
authors = [
"James Briggs <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion semantic_router/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__all__ = ["RouteLayer", "HybridRouteLayer", "Route", "LayerConfig"]

__version__ = "0.0.36"
__version__ = "0.0.37"
3 changes: 2 additions & 1 deletion semantic_router/encoders/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def __call__(self, docs: List[str], truncate: bool = True) -> List[List[float]]:
return embeddings

def _truncate(self, text: str) -> str:
tokens = self._token_encoder.encode(text)
# we use encode_ordinary as faster equivalent to encode(text, disallowed_special=())
tokens = self._token_encoder.encode_ordinary(text)
if len(tokens) > self.token_limit:
logger.warning(
f"Document exceeds token limit: {len(tokens)} > {self.token_limit}"
Expand Down

0 comments on commit 29762f0

Please sign in to comment.