@@ -92,6 +92,7 @@ def generate(
9292 format : Literal ['' , 'json' ] = '' ,
9393 images : Optional [Sequence [AnyStr ]] = None ,
9494 options : Optional [Options ] = None ,
95+ keep_alive : Optional [Union [float , str ]] = None ,
9596 ) -> Union [Mapping [str , Any ], Iterator [Mapping [str , Any ]]]:
9697 """
9798 Create a response using the requested model.
@@ -120,6 +121,7 @@ def generate(
120121 'images' : [_encode_image (image ) for image in images or []],
121122 'format' : format ,
122123 'options' : options or {},
124+ 'keep_alive' : keep_alive ,
123125 },
124126 stream = stream ,
125127 )
@@ -131,6 +133,7 @@ def chat(
131133 stream : bool = False ,
132134 format : Literal ['' , 'json' ] = '' ,
133135 options : Optional [Options ] = None ,
136+ keep_alive : Optional [Union [float , str ]] = None ,
134137 ) -> Union [Mapping [str , Any ], Iterator [Mapping [str , Any ]]]:
135138 """
136139 Create a chat response using the requested model.
@@ -164,18 +167,26 @@ def chat(
164167 'stream' : stream ,
165168 'format' : format ,
166169 'options' : options or {},
170+ 'keep_alive' : keep_alive ,
167171 },
168172 stream = stream ,
169173 )
170174
171- def embeddings (self , model : str = '' , prompt : str = '' , options : Optional [Options ] = None ) -> Sequence [float ]:
175+ def embeddings (
176+ self ,
177+ model : str = '' ,
178+ prompt : str = '' ,
179+ options : Optional [Options ] = None ,
180+ keep_alive : Optional [Union [float , str ]] = None ,
181+ ) -> Sequence [float ]:
172182 return self ._request (
173183 'POST' ,
174184 '/api/embeddings' ,
175185 json = {
176186 'model' : model ,
177187 'prompt' : prompt ,
178188 'options' : options or {},
189+ 'keep_alive' : keep_alive ,
179190 },
180191 ).json ()
181192
@@ -360,6 +371,7 @@ async def generate(
360371 format : Literal ['' , 'json' ] = '' ,
361372 images : Optional [Sequence [AnyStr ]] = None ,
362373 options : Optional [Options ] = None ,
374+ keep_alive : Optional [Union [float , str ]] = None ,
363375 ) -> Union [Mapping [str , Any ], AsyncIterator [Mapping [str , Any ]]]:
364376 """
365377 Create a response using the requested model.
@@ -387,6 +399,7 @@ async def generate(
387399 'images' : [_encode_image (image ) for image in images or []],
388400 'format' : format ,
389401 'options' : options or {},
402+ 'keep_alive' : keep_alive ,
390403 },
391404 stream = stream ,
392405 )
@@ -398,6 +411,7 @@ async def chat(
398411 stream : bool = False ,
399412 format : Literal ['' , 'json' ] = '' ,
400413 options : Optional [Options ] = None ,
414+ keep_alive : Optional [Union [float , str ]] = None ,
401415 ) -> Union [Mapping [str , Any ], AsyncIterator [Mapping [str , Any ]]]:
402416 """
403417 Create a chat response using the requested model.
@@ -430,18 +444,26 @@ async def chat(
430444 'stream' : stream ,
431445 'format' : format ,
432446 'options' : options or {},
447+ 'keep_alive' : keep_alive ,
433448 },
434449 stream = stream ,
435450 )
436451
437- async def embeddings (self , model : str = '' , prompt : str = '' , options : Optional [Options ] = None ) -> Sequence [float ]:
452+ async def embeddings (
453+ self ,
454+ model : str = '' ,
455+ prompt : str = '' ,
456+ options : Optional [Options ] = None ,
457+ keep_alive : Optional [Union [float , str ]] = None ,
458+ ) -> Sequence [float ]:
438459 response = await self ._request (
439460 'POST' ,
440461 '/api/embeddings' ,
441462 json = {
442463 'model' : model ,
443464 'prompt' : prompt ,
444465 'options' : options or {},
466+ 'keep_alive' : keep_alive ,
445467 },
446468 )
447469
0 commit comments