Send a message to chatgpt and get the reply in stream :param message: The message to send :param model_kwargs: Other parameters to pass to openai.ChatCompletion.create() :return: A iterator that yields the reply from chatgpt. The iterator will be exhausted
(self, message: str, **model_kwargs)
| 92 | return reply_content |
| 93 | |
| 94 | def ask_stream(self, message: str, **model_kwargs) -> ChatGPTStreamResponse: |
| 95 | """ |
| 96 | Send a message to chatgpt and get the reply in stream |
| 97 | |
| 98 | :param message: The message to send |
| 99 | :param model_kwargs: Other parameters to pass to openai.ChatCompletion.create() |
| 100 | :return: A iterator that yields the reply from chatgpt. |
| 101 | The iterator will be exhausted when the reply is complete. |
| 102 | """ |
| 103 | resp = self._ask(message, stream=True, **model_kwargs) |
| 104 | self.pending_stream_reply = ChatGPTStreamResponse(resp) |
| 105 | return self.pending_stream_reply |
| 106 | |
| 107 | def latest_finish_reason(self) -> str: |
| 108 | """The finish reason for the latest reply of chatgpt. |
no test coverage detected