FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sparse-encoding-api/app/sparse_encoding_api/views.py at main · codelibs/sparse-encoding-api · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
codelibs
/
sparse-encoding-api
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sparse-encoding-api
/
app
/
sparse_encoding_api
/
views.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (28 loc) · 955 Bytes
Breadcrumbs
sparse-encoding-api
/
app
/
sparse_encoding_api
/
views.py
Copy path
File metadata and controls
38 lines (28 loc) · 955 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import
time
from
typing
import
List
,
Dict
from
fastapi
import
APIRouter
,
Depends
import
sparse_encoding_api
from
sparse_encoding_api
.
models
import
Docs
from
.
services
import
SparseEncodingService
,
get_sparse_encoding_service
api_router
=
APIRouter
()
@
api_router
.
get
(
"/"
)
async
def
index
(
sparse_encoding_service
:
SparseEncodingService
=
Depends
(
get_sparse_encoding_service
)):
return
{
"version"
:
sparse_encoding_api
.
__version__
,
"model_name"
:
sparse_encoding_service
.
get_model_name
(),
}
@
api_router
.
get
(
"/ping"
)
async
def
ping
():
return
{
"status"
:
"ok"
}
@
api_router
.
post
(
"/encode"
)
async
def
encode
(
docs
:
Docs
,
sparse_encoding_service
:
SparseEncodingService
=
Depends
(
get_sparse_encoding_service
)
):
start
:
float
=
time
.
time
()
embeddings
:
List
[
Dict
[
str
,
float
]]
=
sparse_encoding_service
.
encode
(
docs
)
return
{
"took"
:
time
.
time
()
-
start
,
"embeddings"
:
embeddings
,
}
Back
|
FazBrowse Home
|
New Git URL