MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / run

Method run

camel/models/sglang_model.py:181–215  ·  view source on GitHub ↗

r"""Runs inference of OpenAI chat completion. Args: messages (List[OpenAIMessage]): Message list with the chat history in OpenAI API format. Returns: Union[ChatCompletion, Stream[ChatCompletionChunk]]: `ChatCompletion` in the

(
        self,
        messages: List[OpenAIMessage],
    )

Source from the content-addressed store, hash-verified

179 )
180
181 def run(
182 self,
183 messages: List[OpenAIMessage],
184 ) -> Union[ChatCompletion, Stream[ChatCompletionChunk]]:
185 r"""Runs inference of OpenAI chat completion.
186
187 Args:
188 messages (List[OpenAIMessage]): Message list with the chat history
189 in OpenAI API format.
190
191 Returns:
192 Union[ChatCompletion, Stream[ChatCompletionChunk]]:
193 `ChatCompletion` in the non-stream mode, or
194 `Stream[ChatCompletionChunk]` in the stream mode.
195 """
196
197 # Ensure server is running
198 self._ensure_server_running()
199
200 with self._lock:
201 # Update last run time
202 self.last_run_time = time.time()
203
204 if self._client is None:
205 raise RuntimeError(
206 "Client is not initialized. Ensure the server is running."
207 )
208
209 response = self._client.chat.completions.create(
210 messages=messages,
211 model=self.model_type,
212 **self.model_config_dict,
213 )
214
215 return response
216
217 @property
218 def stream(self) -> bool:

Callers

nothing calls this directly

Calls 2

createMethod · 0.45

Tested by

no test coverage detected