Here's an open source alternative with context retrieval and message storage: https://github.com/get-convex/convex-ai-chat
(there are also versions using Assistants API and LangChain, linked from here: https://stack.convex.dev/ai-chat-using-openai-assistants-api)