@@ -138,8 +138,14 @@ def create(cls, args):
138138 if args .n is not None and args .n > 1 and args .stream :
139139 raise ValueError ("Can't stream completions with n>1 with the current CLI" )
140140
141+ if args .engine and args .model :
142+ warnings .warn (
143+ "In most cases, you should not be specifying both engine and model."
144+ )
145+
141146 resp = openai .Completion .create (
142147 engine = args .engine ,
148+ model = args .model ,
143149 n = args .n ,
144150 max_tokens = args .max_tokens ,
145151 logprobs = args .logprobs ,
@@ -253,30 +259,14 @@ def create(cls, args):
253259 return
254260
255261 sys .stdout .write (
256- "Created job : {job_id}\n "
257- "Streaming events until the job is complete...\n \n "
258- "(Ctrl-C will interrupt the stream, but not cancel the job )\n " .format (
262+ "Created fine-tune : {job_id}\n "
263+ "Streaming events until fine-tuning is complete...\n \n "
264+ "(Ctrl-C will interrupt the stream, but not cancel the fine-tune )\n " .format (
259265 job_id = resp ["id" ]
260266 )
261267 )
262268 cls ._stream_events (resp ["id" ])
263269
264- resp = openai .FineTune .retrieve (id = resp ["id" ])
265- status = resp ["status" ]
266- sys .stdout .write ("\n Job complete! Status: {status}" .format (status = status ))
267- if status == "succeeded" :
268- sys .stdout .write (" 🎉" )
269- sys .stdout .write (
270- "\n Try out your fine-tuned model: {model}\n "
271- "(Pass this as the model parameter to a completion request)" .format (
272- model = resp ["fine_tuned_model" ]
273- )
274- )
275- # TODO(rachel): Print instructions on how to use the model here.
276- elif status == "failed" :
277- sys .stdout .write ("\n Please contact support@openai.com for assistance." )
278- sys .stdout .write ("\n " )
279-
280270 @classmethod
281271 def get (cls , args ):
282272 resp = openai .FineTune .retrieve (id = args .id )
@@ -296,8 +286,8 @@ def signal_handler(sig, frame):
296286 status = openai .FineTune .retrieve (job_id ).status
297287 sys .stdout .write (
298288 "\n Stream interrupted. Job is still {status}. "
299- "To cancel your job, run:\n "
300- "` openai api fine_tunes.cancel -i {job_id}` \n " .format (
289+ "To cancel your job, run:\n \n "
290+ "openai api fine_tunes.cancel -i {job_id}\n " .format (
301291 status = status , job_id = job_id
302292 )
303293 )
@@ -318,6 +308,22 @@ def signal_handler(sig, frame):
318308 sys .stdout .write ("\n " )
319309 sys .stdout .flush ()
320310
311+ resp = openai .FineTune .retrieve (id = job_id )
312+ status = resp ["status" ]
313+ if status == "succeeded" :
314+ sys .stdout .write ("\n Job complete! Status: succeeded 🎉" )
315+ sys .stdout .write (
316+ "\n Try out your fine-tuned model:\n \n "
317+ "openai api completions.create -m {model} -p <YOUR_PROMPT>" .format (
318+ model = resp ["fine_tuned_model" ]
319+ )
320+ )
321+ elif status == "failed" :
322+ sys .stdout .write (
323+ "\n Job failed. Please contact support@openai.com if you need assistance."
324+ )
325+ sys .stdout .write ("\n " )
326+
321327 @classmethod
322328 def cancel (cls , args ):
323329 resp = openai .FineTune .cancel (id = args .id )
@@ -422,7 +428,16 @@ def help(args):
422428
423429 # Completions
424430 sub = subparsers .add_parser ("completions.create" )
425- sub .add_argument ("-e" , "--engine" , required = True , help = "The engine to use" )
431+ sub .add_argument (
432+ "-e" ,
433+ "--engine" ,
434+ help = "The engine to use. See https://beta.openai.com/docs/engines for more about what engines are available." ,
435+ )
436+ sub .add_argument (
437+ "-m" ,
438+ "--model" ,
439+ help = "The model to use. At most one of `engine` or `model` should be specified." ,
440+ )
426441 sub .add_argument (
427442 "--stream" , help = "Stream tokens as they're ready." , action = "store_true"
428443 )
0 commit comments