Commit Graph

45 Commits

Author SHA1 Message Date
Enrico Ros 43a13fffe2 Fix again the V-layout of the Area 2023-03-29 03:14:29 -07:00
Enrico Ros 0e49514f03 Fix parsing of C++ code blocks 2023-03-29 03:12:10 -07:00
Enrico Ros 4af44fbff2 Broader NoSSR: too much is customized from localStorage
Also fix the layout of the APP. More stable now.
2023-03-29 02:24:06 -07:00
Enrico Ros 385ea77f93 Update Model/Purpose from the title bar
Remove it from Settings too
2023-03-29 01:51:25 -07:00
Enrico Ros 24a0213397 Move systemPurposeId/chatModelId per-chat 2023-03-28 23:32:23 -07:00
Enrico Ros df512f57b1 ChatStore: persisted multi-conversation store 2023-03-28 05:20:18 -07:00
Enrico Ros 9fd9db5d7a Pedantic 2023-03-27 22:26:42 -07:00
Enrico Ros d532fb6da2 Comments 2023-03-27 03:40:05 -07:00
Enrico Ros e71f08f629 Extract the Conversation (message list) ChatArea
In the future, more actions will be performed on the
state, so the ownership of message and messaging
actions can be brought back to the conversation, from
the (currently) ChatArea
2023-03-27 03:24:26 -07:00
Enrico Ros 9c126086b4 Index to ChatArea 2023-03-27 02:36:40 -07:00
Enrico Ros 3a69ca0b5c Improve Composer Encapsulation 2023-03-27 02:25:30 -07:00
Enrico Ros 25f4d7ed04 Extract ApplicationBar 2023-03-27 01:51:35 -07:00
Enrico Ros 90b267a93b Config cleanup 2023-03-27 01:07:51 -07:00
Enrico Ros ed7333a2c8 Rename SettingsModal 2023-03-26 23:01:12 -07:00
Enrico Ros 5c6e1e9c8d Moving forward we'll use /lib 2023-03-26 22:58:59 -07:00
Enrico Ros 6b96046d40 Cleanups in preparation for Editability & Multi-chats 2023-03-26 04:44:53 -07:00
Enrico Ros 5008f111a7 Merged #22. Stop button in the UI
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.
2023-03-26 04:25:23 -07:00
Enrico Ros f16e744ef9 Smaller moves 2023-03-24 19:06:36 -07:00
Enrico Ros 4ef48f0923 Lints 2023-03-24 18:22:13 -07:00
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
Fred Liu 0ca13e67e6 Stop Generation button initial implementation. 2023-03-23 00:44:17 -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