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
f437eeae
Unverified
Commit
f437eeae
authored
10 months ago
by
Gal Dayan
Committed by
GitHub
10 months ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1 from GENWAY-AI/add_dimension_azure
Add dimension azure
parents
a8544d8f
82c06d51
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
semantic_router/encoders/zure.py
+7
-2
7 additions, 2 deletions
semantic_router/encoders/zure.py
with
7 additions
and
2 deletions
semantic_router/encoders/zure.py
+
7
−
2
View file @
f437eeae
import
os
from
time
import
sleep
from
typing
import
List
,
Optional
from
typing
import
List
,
Optional
,
Union
import
openai
from
openai._types
import
NotGiven
from
openai
import
OpenAIError
from
openai.types
import
CreateEmbeddingResponse
...
...
@@ -13,6 +14,7 @@ from semantic_router.utils.logger import logger
class
AzureOpenAIEncoder
(
BaseEncoder
):
client
:
Optional
[
openai
.
AzureOpenAI
]
=
None
dimensions
:
Union
[
int
,
NotGiven
]
=
NotGiven
()
type
:
str
=
"
azure
"
api_key
:
Optional
[
str
]
=
None
deployment_name
:
Optional
[
str
]
=
None
...
...
@@ -28,6 +30,7 @@ class AzureOpenAIEncoder(BaseEncoder):
api_version
:
Optional
[
str
]
=
None
,
model
:
Optional
[
str
]
=
None
,
# TODO we should change to `name` JB
score_threshold
:
float
=
0.82
,
dimensions
:
Union
[
int
,
NotGiven
]
=
NotGiven
(),
):
name
=
deployment_name
if
name
is
None
:
...
...
@@ -38,6 +41,8 @@ class AzureOpenAIEncoder(BaseEncoder):
self
.
azure_endpoint
=
azure_endpoint
self
.
api_version
=
api_version
self
.
model
=
model
# set dimensions to support openai embed 3 dimensions param
self
.
dimensions
=
dimensions
if
self
.
api_key
is
None
:
self
.
api_key
=
os
.
getenv
(
"
AZURE_OPENAI_API_KEY
"
)
if
self
.
api_key
is
None
:
...
...
@@ -89,7 +94,7 @@ class AzureOpenAIEncoder(BaseEncoder):
for
j
in
range
(
3
):
try
:
embeds
=
self
.
client
.
embeddings
.
create
(
input
=
docs
,
model
=
str
(
self
.
model
)
input
=
docs
,
model
=
str
(
self
.
model
)
,
dimensions
=
self
.
dimensions
,
)
if
embeds
.
data
:
break
...
...
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