File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 21
21
'ResponseError' ,
22
22
'generate' ,
23
23
'chat' ,
24
+ 'embed' ,
24
25
'embeddings' ,
25
26
'pull' ,
26
27
'push' ,
36
37
37
38
generate = _client .generate
38
39
chat = _client .chat
40
+ embed = _client .embed
39
41
embeddings = _client .embeddings
40
42
pull = _client .pull
41
43
push = _client .push
Original file line number Diff line number Diff line change @@ -243,6 +243,29 @@ def chat(
243
243
stream = stream ,
244
244
)
245
245
246
+ def embed (
247
+ self ,
248
+ model : str = '' ,
249
+ input : Union [str , Sequence [AnyStr ]] = '' ,
250
+ truncate : bool = True ,
251
+ options : Optional [Options ] = None ,
252
+ keep_alive : Optional [Union [float , str ]] = None ,
253
+ ) -> Mapping [str , Any ]:
254
+ if not model :
255
+ raise RequestError ('must provide a model' )
256
+
257
+ return self ._request (
258
+ 'POST' ,
259
+ '/api/embed' ,
260
+ json = {
261
+ 'model' : model ,
262
+ 'input' : input ,
263
+ 'truncate' : truncate ,
264
+ 'options' : options or {},
265
+ 'keep_alive' : keep_alive ,
266
+ },
267
+ ).json ()
268
+
246
269
def embeddings (
247
270
self ,
248
271
model : str = '' ,
@@ -634,6 +657,31 @@ async def chat(
634
657
stream = stream ,
635
658
)
636
659
660
+ async def embed (
661
+ self ,
662
+ model : str = '' ,
663
+ input : Union [str , Sequence [AnyStr ]] = '' ,
664
+ truncate : bool = True ,
665
+ options : Optional [Options ] = None ,
666
+ keep_alive : Optional [Union [float , str ]] = None ,
667
+ ) -> Mapping [str , Any ]:
668
+ if not model :
669
+ raise RequestError ('must provide a model' )
670
+
671
+ response = await self ._request (
672
+ 'POST' ,
673
+ '/api/embed' ,
674
+ json = {
675
+ 'model' : model ,
676
+ 'input' : input ,
677
+ 'truncate' : truncate ,
678
+ 'options' : options or {},
679
+ 'keep_alive' : keep_alive ,
680
+ },
681
+ )
682
+
683
+ return response .json ()
684
+
637
685
async def embeddings (
638
686
self ,
639
687
model : str = '' ,
You can’t perform that action at this time.
0 commit comments