@@ -101,9 +101,18 @@ def cmd(args: argparse.Namespace) -> None:
101
101
model_name , client = _interactive_cli (args )
102
102
system_prompt = args .system_prompt
103
103
conversation : list [ChatCompletionMessageParam ] = []
104
+
104
105
if system_prompt is not None :
105
106
conversation .append ({"role" : "system" , "content" : system_prompt })
106
107
108
+ if args .quick :
109
+ conversation .append ({"role" : "user" , "content" : args .quick })
110
+
111
+ chat_completion = client .chat .completions .create (
112
+ model = model_name , messages = conversation )
113
+ print (chat_completion .choices [0 ].message .content )
114
+ return
115
+
107
116
print ("Please enter a message for the chat model:" )
108
117
while True :
109
118
try :
@@ -136,6 +145,12 @@ def subparser_init(
136
145
default = None ,
137
146
help = ("The system prompt to be added to the chat template, "
138
147
"used for models that support system prompts." ))
148
+ chat_parser .add_argument ("-q" ,
149
+ "--quick" ,
150
+ type = str ,
151
+ metavar = "MESSAGE" ,
152
+ help = ("Send a single prompt as MESSAGE "
153
+ "and print the response, then exit." ))
139
154
return chat_parser
140
155
141
156
@@ -149,6 +164,13 @@ def __init__(self):
149
164
@staticmethod
150
165
def cmd (args : argparse .Namespace ) -> None :
151
166
model_name , client = _interactive_cli (args )
167
+
168
+ if args .quick :
169
+ completion = client .completions .create (model = model_name ,
170
+ prompt = args .quick )
171
+ print (completion .choices [0 ].text )
172
+ return
173
+
152
174
print ("Please enter prompt to complete:" )
153
175
while True :
154
176
input_prompt = input ("> " )
@@ -168,6 +190,13 @@ def subparser_init(
168
190
"via the running API server." ),
169
191
usage = "vllm complete [options]" )
170
192
_add_query_options (complete_parser )
193
+ complete_parser .add_argument (
194
+ "-q" ,
195
+ "--quick" ,
196
+ type = str ,
197
+ metavar = "PROMPT" ,
198
+ help =
199
+ "Send a single prompt and print the completion output, then exit." )
171
200
return complete_parser
172
201
173
202
0 commit comments