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
d063a20f
Unverified
Commit
d063a20f
authored
1 year ago
by
James Briggs
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #180 from bdqfork/dev
feat: Support openai base_url
parents
e02a4a7c
bc366161
No related branches found
Branches containing commit
Tags
v0.1.10
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
semantic_router/encoders/openai.py
+5
-1
5 additions, 1 deletion
semantic_router/encoders/openai.py
with
5 additions
and
1 deletion
semantic_router/encoders/openai.py
+
5
−
1
View file @
d063a20f
...
...
@@ -20,6 +20,7 @@ class OpenAIEncoder(BaseEncoder):
def
__init__
(
self
,
name
:
Optional
[
str
]
=
None
,
openai_base_url
:
Optional
[
str
]
=
None
,
openai_api_key
:
Optional
[
str
]
=
None
,
openai_org_id
:
Optional
[
str
]
=
None
,
score_threshold
:
float
=
0.82
,
...
...
@@ -29,11 +30,14 @@ class OpenAIEncoder(BaseEncoder):
name
=
EncoderDefault
.
OPENAI
.
value
[
"
embedding_model
"
]
super
().
__init__
(
name
=
name
,
score_threshold
=
score_threshold
)
api_key
=
openai_api_key
or
os
.
getenv
(
"
OPENAI_API_KEY
"
)
base_url
=
openai_base_url
or
os
.
getenv
(
"
OPENAI_BASE_URL
"
)
openai_org_id
=
openai_org_id
or
os
.
getenv
(
"
OPENAI_ORG_ID
"
)
if
api_key
is
None
:
raise
ValueError
(
"
OpenAI API key cannot be
'
None
'
.
"
)
try
:
self
.
client
=
openai
.
Client
(
api_key
=
api_key
,
organization
=
openai_org_id
)
self
.
client
=
openai
.
Client
(
base_url
=
base_url
,
api_key
=
api_key
,
organization
=
openai_org_id
)
except
Exception
as
e
:
raise
ValueError
(
f
"
OpenAI API client failed to initialize. Error:
{
e
}
"
...
...
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