diff --git a/semantic_router/encoders/openai.py b/semantic_router/encoders/openai.py index 24cac037b9ec93ea30882d151048ac32594ef8af..86f46e8c1a4dc92f057683027d69755d80bb0c43 100644 --- a/semantic_router/encoders/openai.py +++ b/semantic_router/encoders/openai.py @@ -79,8 +79,7 @@ class OpenAIEncoder(BaseEncoder): if truncate: # check if any document exceeds token limit and truncate if so - for i in range(len(docs)): - docs[i] = self._truncate(docs[i]) + docs = [self._truncate(doc) for doc in docs] # Exponential backoff for j in range(1, 7): diff --git a/tests/integration/encoders/test_openai_integration.py b/tests/integration/encoders/test_openai_integration.py index 73852bb30b2ea99fe4e481f19805d417b6b62219..3298071b46152df0431ccce140873281e3ef9597 100644 --- a/tests/integration/encoders/test_openai_integration.py +++ b/tests/integration/encoders/test_openai_integration.py @@ -1,7 +1,5 @@ import pytest - - -from semantic_router.encoders import OpenAIEncoder +from semantic_router.encoders.openai import OpenAIEncoder with open("tests/integration/57640.4032.txt", "r") as fp: long_doc = fp.read()