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 2121 'ResponseError' ,
2222 'generate' ,
2323 'chat' ,
24+ 'embed' ,
2425 'embeddings' ,
2526 'pull' ,
2627 'push' ,
3637
3738generate = _client .generate
3839chat = _client .chat
40+ embed = _client .embed
3941embeddings = _client .embeddings
4042pull = _client .pull
4143push = _client .push
Original file line number Diff line number Diff line change @@ -243,6 +243,29 @@ def chat(
243243 stream = stream ,
244244 )
245245
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+
246269 def embeddings (
247270 self ,
248271 model : str = '' ,
@@ -634,6 +657,31 @@ async def chat(
634657 stream = stream ,
635658 )
636659
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+
637685 async def embeddings (
638686 self ,
639687 model : str = '' ,
You can’t perform that action at this time.
0 commit comments