Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Semantic Router
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
aurelio-labs
Semantic Router
Commits
923b0135
Commit
923b0135
authored
10 months ago
by
tolgaidev
Browse files
Options
Downloads
Patches
Plain Diff
modify the code to address the issue when truncating documents
parent
ee1cb5b9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
semantic_router/encoders/openai.py
+1
-2
1 addition, 2 deletions
semantic_router/encoders/openai.py
tests/integration/encoders/test_openai_integration.py
+1
-3
1 addition, 3 deletions
tests/integration/encoders/test_openai_integration.py
with
2 additions
and
5 deletions
semantic_router/encoders/openai.py
+
1
−
2
View file @
923b0135
...
...
@@ -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
):
...
...
This diff is collapsed.
Click to expand it.
tests/integration/encoders/test_openai_integration.py
+
1
−
3
View file @
923b0135
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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment