Commit Graph

45 Commits

Author SHA1 Message Date
Enrico Ros 23a3185696 Load PDFs on drag/drop, min-worker, dynamic import
Cleaned up the code a bit (thx gpt4), with:
 - dynamic module load: JS is chunked up and deferred to PDF loading,
   which improves all the sessions where PDFs are not loaded
 - unified path for drag/drop and 'load file' (shall call it "magic drop"
   so PDFs are text'ified upon drag/dop as well
 - fixed "not being able to load the same doc twice" (thx gpt4)
 - using minified worker, as it's loaded dynamically, we save ~50% bandwidth
2023-04-03 02:57:02 -07:00
Enrico Ros 0377512464 Move files around, for cleanup 2023-04-03 01:49:02 -07:00
fredliubojin 421e06e617 Using pdfjs-dist to parse and load pdf contents. 2023-04-02 23:37:23 -07:00
Enrico Ros 064de8dc1e Export chats. Closes #25
Chats are exported to paste.gg, are unlisted by default, and expire
in 30 days by default. The user is also provided with the deletion
key which will be only shown at the time of creation, and it's needed
to take down the paste.

Rendering looks quite great, including code and turns.
2023-04-01 04:38:53 -07:00
Enrico Ros c07aee01e0 State Optimizations and Cleanup 2023-03-31 03:35:05 -07:00
Enrico Ros 7154db7f72 Configurable API Host
Closes #32. Enable Users / Deployments to change the host where
OpenAI API calls are directed to. This enables project like
[Helicone](https://www.helicone.ai/) (Observability of LLM ops)
for tracking prompt/responses quality in real-time.

Configuration:
- User: App > Settings > Advanced > API host (e.g. "oai.hconeai.com")
- Deployment: set the 'API_API_HOST=...' environment variable

User takes precedence over deployment over api.openai.com. Realtime
switching in chat apps works well.

Note: the Helicone team is fixing dashboard reporting for 'streaming'
over the /v1/chat/completions endpoint.
2023-03-30 20:00:40 -07:00
Enrico Ros 3e0cd173af Fix 2023-03-29 15:32:12 -07:00
Enrico Ros b5b709b3cd Wide Mode support 2023-03-29 03:14:58 -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 1edcb02c0d Testing quick fix for #28 2023-03-28 02:50:40 -07:00
Enrico Ros 9fd9db5d7a Pedantic 2023-03-27 22:26:42 -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 1b340deb31 Cleanup types 2023-03-26 02:22:03 -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 ccb5456e28 Small fix 2023-03-24 17:57:53 -07:00
Enrico Ros b308bf418c Disable Vercel analytics debug 2023-03-24 17:01:30 -07:00
Enrico Ros ce24209f73 Enable Vercel deployments to have analytics 2023-03-24 16:55:05 -07:00
Enrico Ros 2ea2de601a Cleanups 2023-03-24 03:31:43 -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 0d915f0eb7 Red bar during development 2023-03-24 01:51:57 -07:00
Enrico Ros a63c9123dd Improve the Api (/api/chat) payload 2023-03-24 01:39:51 -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 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 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 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
Enrico Ros ade1fb0b97 Merge pull request #7 from typpo/custom-system-message
Add ability to set custom system message
2023-03-19 20:28:32 -07:00
Ian Webster 6e2ce976fb Add ability to set custom system message 2023-03-19 23:08:08 +00: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 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
Enrico Ros f646fca299 Remove template stuff 2023-03-19 00:24:09 -07:00
Enrico Ros 0b4646cd0a Create Next App 2023-03-18 23:54:30 -07:00