The UI side works well, including aborting the network
request to the api, and showing status and issues.
The API function (api/chat.ts) doesn't seem to work yet,
as the try/catch blocks are not triggered (both on the
'handler', and in the 'OpenAIStream').
In the meantime, having the Stop button on the UI is still
a net gain, despite tokens still running/being used from
the API call.
Basic implementation using Zustand to store values. For now just the
ChatModel and the SystemPurpose that are currently active. This enables
app-wide synchronization and automated persistence. Meaning we can now
have settings (and in future conversations) which are persisted and
synchronized.
API keys have not been migrated yet, because we need to import them from
the existing localStorage key, for a smooth transition.
Behind the scenes, we detect the model name from the OpenAI
streaming API (it's in all the chunks), and stream it back
to the UI as a serialized JSON object. This is more of a
workaround, required by virtue of the streaming API, and can
be cleaned up later.
Model names available when hovering 'gpt-4' / '3.5-turbo'.
The keys are stored within the localStorage of the browser.
The string is passed to the backend as a parameter in the REST
API call (to '/api/chat'), where it has priority over other
keys set in the OPENAI_API_KEY of the backend.