With this simple change, if the key is defined _at build time_,
the user will not be prompted to enter a key, and it will be
marked as 'not required' in the Settings dialog.
Note that this verifies a build-time key (next build), not that
the same key is set at runtime (next start).
The behavior of the UI is just altered slightly, but enough to
show that the key is not required when set on the server.
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.
Closes#18 and closes#16. Interesting find: the "code":"model_not_found" shows
that the model is just not authorized for this API key. If the model is really
non-existing and can't be found, the error code will be "null", and the message
will be "The model 'XYZ' does not exist".
Adapt speech recognition to begin as 'false' and dynamically update state.
UX: the button can now be dynamic (no hydration issues). Differentiated
mobile vs desktop look.
I need to use the 'useCallback' function to pass the onResult callback,
otherwise the code loops (as the callback function will get recreated
every time, and it's circular).
This closes#10, and improves insertion of files, by allowing both
drag/drop and File dialog selections. Adapted all the UI to make it
look good both on Mobile and Desktop - and to avoid hydration issues
I had to use css visibility (which means duplication of code).
As a side quest, I tried to support drag&drop from VSCode but it
doesn't seem to work to transfer files, at least within chrome.
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'.
Fix an uninitialized 'model' variable in case the user dismissed the
settings dialog. Fixed a missing variable expansion, '{{Today}}', for
Chat and Custom purposes.
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.
Warning: this adds 203kb of JS to the app, more than 4x'ing
the size of the app. Will remove if not worth it. Uses Sandpack
from Codesandbox.io, which stands up full execution environments
for the code.