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
954fc926
Commit
954fc926
authored
1 year ago
by
Luca Mannini
Browse files
Options
Downloads
Patches
Plain Diff
Deleted main in layer.py
parent
809aa14e
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/layer.py
+0
-50
0 additions, 50 deletions
semantic_router/layer.py
with
0 additions
and
50 deletions
semantic_router/layer.py
+
0
−
50
View file @
954fc926
...
@@ -541,53 +541,3 @@ def threshold_random_search(
...
@@ -541,53 +541,3 @@ def threshold_random_search(
for
i
,
route
in
enumerate
(
route_names
)
for
i
,
route
in
enumerate
(
route_names
)
}
}
return
score_thresholds
return
score_thresholds
if
__name__
==
"
__main__
"
:
from
semantic_router
import
Route
from
semantic_router.encoders
import
OpenAIEncoder
from
semantic_router.layer
import
RouteLayer
# Define routes with example phrases
politics
=
Route
(
name
=
"
politics
"
,
utterances
=
[
"
isn
'
t politics the best thing ever
"
,
"
why don
'
t you tell me about your political opinions
"
,
"
don
'
t you just love the president
"
,
"
don
'
t you just hate the president
"
,
"
they
'
re going to destroy this country!
"
,
"
they will save the country!
"
,
],
)
chitchat
=
Route
(
name
=
"
chitchat
"
,
utterances
=
[
"
how
'
s the weather today?
"
,
"
how are things going?
"
,
"
lovely weather today
"
,
"
the weather is horrendous
"
,
"
let
'
s go to the chippy
"
,
],
)
routes
=
[
politics
,
chitchat
]
# Initialize the encoder
encoder
=
OpenAIEncoder
()
# Initialize the RouteLayer with the encoder and routes
rl
=
RouteLayer
(
encoder
=
encoder
,
routes
=
routes
)
# Test the RouteLayer with example queries
print
(
rl
.
retrieve_multiple_routes
(
"
how
'
s the weather today?
"
)
)
# Expected to match the chitchat route
print
(
rl
.
retrieve_multiple_routes
(
"
don
'
t you love politics?
"
)
)
# Expected to match the politics route
print
(
rl
.
retrieve_multiple_routes
(
"
I
'
m interested in learning about llama 2
"
)
)
# Expected to return None since it doesn't match any route
print
(
rl
.
retrieve_multiple_routes
(
"
Hi! How are you doing in politics??
"
))
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