r"""Runs inference of Yi chat completion. Args: messages (List[OpenAIMessage]): Message list with the chat history in OpenAI API format. Returns: Union[ChatCompletion, Stream[ChatCompletionChunk]]: `ChatCompletion` in the non-
(
self,
messages: List[OpenAIMessage],
)
| 82 | ) |
| 83 | |
| 84 | def run( |
| 85 | self, |
| 86 | messages: List[OpenAIMessage], |
| 87 | ) -> Union[ChatCompletion, Stream[ChatCompletionChunk]]: |
| 88 | r"""Runs inference of Yi chat completion. |
| 89 | |
| 90 | Args: |
| 91 | messages (List[OpenAIMessage]): Message list with the chat history |
| 92 | in OpenAI API format. |
| 93 | |
| 94 | Returns: |
| 95 | Union[ChatCompletion, Stream[ChatCompletionChunk]]: |
| 96 | `ChatCompletion` in the non-stream mode, or |
| 97 | `Stream[ChatCompletionChunk]` in the stream mode. |
| 98 | """ |
| 99 | response = self._client.chat.completions.create( |
| 100 | messages=messages, |
| 101 | model=self.model_type, |
| 102 | **self.model_config_dict, |
| 103 | ) |
| 104 | return response |
| 105 | |
| 106 | @property |
| 107 | def token_counter(self) -> BaseTokenCounter: |
no test coverage detected