MCPcopy Index your code
hub / github.com/PaddlePaddle/FastDeploy / cmd

Method cmd

fastdeploy/entrypoints/cli/openai.py:116–145  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

114
115 @staticmethod
116 def cmd(args: argparse.Namespace) -> None:
117 model_name, client = _interactive_cli(args)
118 system_prompt = args.system_prompt
119 conversation: list[ChatCompletionMessageParam] = []
120
121 if system_prompt is not None:
122 conversation.append({"role": "system", "content": system_prompt})
123
124 if args.quick:
125 conversation.append({"role": "user", "content": args.quick})
126
127 chat_completion = client.chat.completions.create(model=model_name, messages=conversation)
128 print(chat_completion.choices[0].message.content)
129 return
130
131 print("Please enter a message for the chat model:")
132 while True:
133 try:
134 input_message = input("> ")
135 except EOFError:
136 break
137 conversation.append({"role": "user", "content": input_message})
138
139 chat_completion = client.chat.completions.create(model=model_name, messages=conversation)
140
141 response_message = chat_completion.choices[0].message
142 output = response_message.content
143
144 conversation.append(response_message) # type: ignore
145 print(output)
146
147 @staticmethod
148 def add_cli_args(parser: FlexibleArgumentParser) -> FlexibleArgumentParser:

Callers

nothing calls this directly

Calls 3

_interactive_cliFunction · 0.85
printFunction · 0.85
createMethod · 0.45

Tested by

no test coverage detected