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
fc8f9a43
Unverified
Commit
fc8f9a43
authored
1 year ago
by
James Briggs
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' into readme-fix
parents
0e995c9b
d063a20f
No related branches found
No related tags found
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 @
fc8f9a43
...
@@ -20,6 +20,7 @@ class OpenAIEncoder(BaseEncoder):
...
@@ -20,6 +20,7 @@ class OpenAIEncoder(BaseEncoder):
def
__init__
(
def
__init__
(
self
,
self
,
name
:
Optional
[
str
]
=
None
,
name
:
Optional
[
str
]
=
None
,
openai_base_url
:
Optional
[
str
]
=
None
,
openai_api_key
:
Optional
[
str
]
=
None
,
openai_api_key
:
Optional
[
str
]
=
None
,
openai_org_id
:
Optional
[
str
]
=
None
,
openai_org_id
:
Optional
[
str
]
=
None
,
score_threshold
:
float
=
0.82
,
score_threshold
:
float
=
0.82
,
...
@@ -29,11 +30,14 @@ class OpenAIEncoder(BaseEncoder):
...
@@ -29,11 +30,14 @@ class OpenAIEncoder(BaseEncoder):
name
=
EncoderDefault
.
OPENAI
.
value
[
"
embedding_model
"
]
name
=
EncoderDefault
.
OPENAI
.
value
[
"
embedding_model
"
]
super
().
__init__
(
name
=
name
,
score_threshold
=
score_threshold
)
super
().
__init__
(
name
=
name
,
score_threshold
=
score_threshold
)
api_key
=
openai_api_key
or
os
.
getenv
(
"
OPENAI_API_KEY
"
)
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
"
)
openai_org_id
=
openai_org_id
or
os
.
getenv
(
"
OPENAI_ORG_ID
"
)
if
api_key
is
None
:
if
api_key
is
None
:
raise
ValueError
(
"
OpenAI API key cannot be
'
None
'
.
"
)
raise
ValueError
(
"
OpenAI API key cannot be
'
None
'
.
"
)
try
:
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
:
except
Exception
as
e
:
raise
ValueError
(
raise
ValueError
(
f
"
OpenAI API client failed to initialize. Error:
{
e
}
"
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