@@ -93,6 +93,7 @@ def generate(
9393 format : Literal ['' , 'json' ] = '' ,
9494 images : Optional [Sequence [AnyStr ]] = None ,
9595 options : Optional [Options ] = None ,
96+ keep_alive : Optional [Union [float , str ]] = None ,
9697 ) -> Union [Mapping [str , Any ], Iterator [Mapping [str , Any ]]]:
9798 """
9899 Create a response using the requested model.
@@ -121,6 +122,7 @@ def generate(
121122 'images' : [_encode_image (image ) for image in images or []],
122123 'format' : format ,
123124 'options' : options or {},
125+ 'keep_alive' : keep_alive ,
124126 },
125127 stream = stream ,
126128 )
@@ -132,6 +134,7 @@ def chat(
132134 stream : bool = False ,
133135 format : Literal ['' , 'json' ] = '' ,
134136 options : Optional [Options ] = None ,
137+ keep_alive : Optional [Union [float , str ]] = None ,
135138 ) -> Union [Mapping [str , Any ], Iterator [Mapping [str , Any ]]]:
136139 """
137140 Create a chat response using the requested model.
@@ -165,18 +168,26 @@ def chat(
165168 'stream' : stream ,
166169 'format' : format ,
167170 'options' : options or {},
171+ 'keep_alive' : keep_alive ,
168172 },
169173 stream = stream ,
170174 )
171175
172- def embeddings (self , model : str = '' , prompt : str = '' , options : Optional [Options ] = None ) -> Sequence [float ]:
176+ def embeddings (
177+ self ,
178+ model : str = '' ,
179+ prompt : str = '' ,
180+ options : Optional [Options ] = None ,
181+ keep_alive : Optional [Union [float , str ]] = None ,
182+ ) -> Sequence [float ]:
173183 return self ._request (
174184 'POST' ,
175185 '/api/embeddings' ,
176186 json = {
177187 'model' : model ,
178188 'prompt' : prompt ,
179189 'options' : options or {},
190+ 'keep_alive' : keep_alive ,
180191 },
181192 ).json ()
182193
@@ -364,6 +375,7 @@ async def generate(
364375 format : Literal ['' , 'json' ] = '' ,
365376 images : Optional [Sequence [AnyStr ]] = None ,
366377 options : Optional [Options ] = None ,
378+ keep_alive : Optional [Union [float , str ]] = None ,
367379 ) -> Union [Mapping [str , Any ], AsyncIterator [Mapping [str , Any ]]]:
368380 """
369381 Create a response using the requested model.
@@ -391,6 +403,7 @@ async def generate(
391403 'images' : [_encode_image (image ) for image in images or []],
392404 'format' : format ,
393405 'options' : options or {},
406+ 'keep_alive' : keep_alive ,
394407 },
395408 stream = stream ,
396409 )
@@ -402,6 +415,7 @@ async def chat(
402415 stream : bool = False ,
403416 format : Literal ['' , 'json' ] = '' ,
404417 options : Optional [Options ] = None ,
418+ keep_alive : Optional [Union [float , str ]] = None ,
405419 ) -> Union [Mapping [str , Any ], AsyncIterator [Mapping [str , Any ]]]:
406420 """
407421 Create a chat response using the requested model.
@@ -434,18 +448,26 @@ async def chat(
434448 'stream' : stream ,
435449 'format' : format ,
436450 'options' : options or {},
451+ 'keep_alive' : keep_alive ,
437452 },
438453 stream = stream ,
439454 )
440455
441- async def embeddings (self , model : str = '' , prompt : str = '' , options : Optional [Options ] = None ) -> Sequence [float ]:
456+ async def embeddings (
457+ self ,
458+ model : str = '' ,
459+ prompt : str = '' ,
460+ options : Optional [Options ] = None ,
461+ keep_alive : Optional [Union [float , str ]] = None ,
462+ ) -> Sequence [float ]:
442463 response = await self ._request (
443464 'POST' ,
444465 '/api/embeddings' ,
445466 json = {
446467 'model' : model ,
447468 'prompt' : prompt ,
448469 'options' : options or {},
470+ 'keep_alive' : keep_alive ,
449471 },
450472 )
451473
0 commit comments