Commit Graph

25 Commits

Author SHA1 Message Date
Enrico Ros 2ea2de601a Cleanups 2023-03-24 03:31:43 -07:00
Enrico Ros ecdcdef749 Error message for Context size 2023-03-24 03:10:51 -07:00
Enrico Ros 89b77b2408 Move all State and Defaults in the store 2023-03-24 02:45:32 -07:00
Enrico Ros 798e9e878f Migrate the API Key into the state store 2023-03-24 02:15:45 -07:00
Enrico Ros 65b8aab53e Markdown: syntax highlight in code blocks
Implements part of #11, where the markdown is in code blocks of this type:
```SomeName.md
# ...
```
2023-03-24 00:39:33 -07:00
Enrico Ros f2bb334778 Markdown: syntax highlight in code blocks
Implements part of #11, where the markdown is in code blocks of this type:
```markdown
# ...
```
2023-03-24 00:26:45 -07:00
Enrico Ros 2dafafdcf4 Improve running code. Can render basic HTML.
Fixes #19. Now it's showing the HTML in the Sandpack box.
2023-03-23 23:33:52 -07:00
Enrico Ros c15b48d1b4 Fix #24: when OPENAI_API_KEY is defined, do not prompt the user
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.
2023-03-23 22:45:47 -07:00
Enrico Ros 4babee363a Migrated the history state 2023-03-22 01:20:17 -07:00
Enrico Ros 3e6bbd8fe8 Persisted State Store - enables better UX
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.
2023-03-22 00:29:51 -07:00
Enrico Ros 49bc3192ec Explain model/system errors to the users
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".
2023-03-21 22:52:57 -07:00
Enrico Ros 5425ed3ca4 Update README.md 2023-03-20 21:27:01 -07:00
Enrico Ros 5cfcd7931e React hook for Speech Recognition
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).
2023-03-20 21:04:26 -07:00
Marc Khoury 1a052b3b64 Basic Voice Input 2023-03-20 20:59:40 -04:00
Enrico Ros ba8a281d80 Restart the conversation from any point
Also useful to try a few answers before moving forward. Good time saver.
2023-03-20 02:37:12 -07:00
Enrico Ros db9b6b5b46 File Dialog for attaching text/code
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.
2023-03-20 02:09:49 -07:00
Enrico Ros 2d0136c78f Display the API model (as tooltip)
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'.
2023-03-19 23:08:38 -07:00
Enrico Ros de41740f02 Adding the Catalyst (growth hacker) AI. 2023-03-19 22:20:57 -07:00
Enrico Ros 9d265689a8 Simple fixes.
Fix an uninitialized 'model' variable in case the user dismissed the
settings dialog. Fixed a missing variable expansion, '{{Today}}', for
Chat and Custom purposes.
2023-03-19 21:15:39 -07:00
Marc Khoury 3d72246d72 Added support for GPT3.5 Turbo model 2023-03-19 14:18:53 -04:00
Enrico Ros 1677db1df8 Error Handling
Show the user if Errors are raised from the OpenAI API, or by
our backend. Good messaging, red coloring.
2023-03-19 05:11:17 -07:00
Enrico Ros 3c60361635 User Provided API Keys
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.
2023-03-19 04:28:20 -07:00
Enrico Ros 010b1b17cf Run TS/JS/HTML blocks
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.
2023-03-19 00:59:30 -07:00
Enrico Ros cd60c6cc27 Highlight Code blocks
Using prismjs, we add coloring of source code blocks, which
translates in 12k of additional code. But the eyes and mind
are so happy.
2023-03-19 00:53:52 -07:00
Enrico Ros d2a7082564 Add Application
NextJS, React, JoyUI (like MUI), application for self-hosted
Chat-like GPT use cases. Includes streaming of responses from
the Vercel edge runtimes.
2023-03-19 00:42:23 -07:00