memos
memos copied to clipboard
Error on the openAI integration when using quotes
Describe the bug
When using quotes in a question for the openAI API, we get an error stating:
Failed to post chat completion, internal={"code":null,"message":"We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please send an email to [email protected] and include any relevant code you'd like help with.
Steps to reproduce
- Click on Ask AI
- Ask a question with quotes such as: Is "I love you" a positive or negative message?
Screenshots or additional context
No response
maybe should do some reg for user input https://github.com/usememos/memos/blob/595dbdb0ecb1eada129e21f1c1580d86dd256534/web/src/components/AskAIDialog.tsx#L61
perhaps like this:
await api.postChatCompletion(question.replace(/"|“|“/, '\\"'));