Skip to content

Commit

Permalink
fix: allow encoding of special tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescalam committed Apr 28, 2024
1 parent eb9ebe3 commit 6a45948
Showing 1 changed file with 2 additions and 1 deletion.
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 6a45948

Please sign in to comment.