Skip to content

Commit 35f04d3

Browse files
committed
fix:text post processing
1 parent 12ba0d8 commit 35f04d3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ovos_solver_openai_persona/engines.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ def get_spoken_answer(self, query: str,
7272
return answer
7373

7474

75+
def post_process_sentence(text: str) -> str:
76+
text = text.replace("*", "") # TTS often literally reads "asterisk"
77+
return text.strip()
78+
79+
7580
class OpenAIChatCompletionsSolver(ChatMessageSolver):
7681
enable_tx = False
7782
priority = 25
@@ -186,7 +191,7 @@ def continue_chat(self, messages: MessageList,
186191
Optional[str]: The generated response or None if no response could be generated.
187192
"""
188193
response = self._do_api_request(messages)
189-
answer = response.strip()
194+
answer = post_process_sentence(response)
190195
if not answer or not answer.strip("?") or not answer.strip("_"):
191196
return None
192197
if self.memory:
@@ -222,7 +227,7 @@ def stream_chat_utterances(self, messages: List[Dict[str, str]],
222227
if self.memory:
223228
full_ans = f"{self.qa_pairs[-1][-1]}\n{answer}".strip()
224229
self.qa_pairs[-1] = (query, full_ans)
225-
yield answer
230+
yield post_process_sentence(answer)
226231
answer = ""
227232

228233
def stream_utterances(self, query: str,

0 commit comments

Comments
 (0)