Skip to content

Commit 0e12853

Browse files
authored
WIP: Update UI to match Official Style; Vision and Assistants 👷🏽 (danny-avila#1190)
* wip: initial client side code * wip: initial api code * refactor: export query keys from own module, export assistant hooks * refactor(SelectDropDown): more customization via props * feat: create Assistant and render real Assistants * refactor: major refactor of UI components to allow multi-chat, working alongside CreationPanel * refactor: move assistant routes to own directory * fix(CreationHeader): state issue with assistant select * refactor: style changes for form, fix setSiblingIdx from useChatHelpers to use latestMessageParentId, fix render issue with ChatView and change location * feat: parseCompactConvo: begin refactor of slimmer JSON payloads between client/api * refactor(endpoints): add assistant endpoint, also use EModelEndpoint as much as possible * refactor(useGetConversationsQuery): use object to access query data easily * fix(MultiMessage): react warning of bad state set, making use of effect during render (instead of useEffect) * fix(useNewConvo): use correct atom key (index instead of convoId) for reset latestMessageFamily * refactor: make routing navigation/conversation change simpler * chore: add removeNullishValues for smaller payloads, remove unused fields, setup frontend pinging of assistant endpoint * WIP: initial complete assistant run handling * fix: CreationPanel form correctly setting internal state * refactor(api/assistants/chat): revise functions to working run handling strategy * refactor(UI): initial major refactor of ChatForm and options * feat: textarea hook * refactor: useAuthRedirect hook and change directory name * feat: add ChatRoute (/c/), make optionsBar absolute and change on textarea height, add temp header * feat: match new toggle Nav open button to ChatGPT's * feat: add OpenAI custom classnames * feat: useOriginNavigate * feat: messages loading view * fix: conversation navigation and effects * refactor: make toggle change nav opacity * WIP: new endpoint menu * feat: NewEndpointsMenu complete * fix: ensure set key dialog shows on endpoint change, and new conversation resets messages * WIP: textarea styling fix, add temp footer, create basic file handling component * feat: image file handling (UI) * feat: PopOver and ModelSelect in Header, remove GenButtons * feat: drop file handling * refactor: bug fixes use SSE at route level add opts to useOriginNavigate delay render of unfinishedMessage to avoid flickering pass params (convoId) to chatHelpers to set messages query data based on param when the route is new (fixes can't continue convo on /new/) style(MessagesView): matches height to official fix(SSE): pass paramId and invalidate convos style(Message): make bg uniform * refactor(useSSE): setStorage within setConversation updates * feat: conversationKeysAtom, allConversationsSelector, update convos query data on created message (if new), correctly handle convo deletion (individual) * feat: add popover select dropdowns to allow options in header while allowing horizontal scroll for mobile * style(pluginsSelect): styling changes * refactor(NewEndpointsMenu): make UI components modular * feat: Presets complete * fix: preset editing, make by index * fix: conversations not setting on inital navigation, fix getMessages() based on query param * fix: changing preset no longer resets latestMessage * feat: useOnClickOutside for OptionsPopover and fix bug that causes selection of preset when deleting * fix: revert /chat/ switchToConvo, also use NewDeleteButton in Convo * fix: Popover correctly closes on close Popover button using custom condition for useOnClickOutside * style: new message and nav styling * style: hover/sibling buttons and preset menu scrolling * feat: new convo header button * style(Textarea): minor style changes to textarea buttons * feat: stop/continue generating and hide hoverbuttons when submitting * feat: compact AI Provider schemas to make json payloads and db saves smaller * style: styling changes for consistency on chat route * fix: created usePresetIndexOptions to prevent bugs between /c/ and /chat/ routes when editing presets, removed redundant code from the new dialog * chore: make /chat/ route default for now since we still lack full image support
1 parent 193c36b commit 0e12853

File tree

171 files changed

+8377
-465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+8377
-465
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ meili_data/
4040
api/node_modules/
4141
client/node_modules/
4242
bower_components/
43-
types/
43+
*.d.ts
4444

4545
# Floobits
4646
.floo

api/models/schema/convoSchema.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,36 @@ const convoSchema = mongoose.Schema(
1818
user: {
1919
type: String,
2020
index: true,
21-
default: null,
21+
// default: null,
2222
},
2323
messages: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Message' }],
2424
// google only
2525
examples: [{ type: mongoose.Schema.Types.Mixed }],
2626
agentOptions: {
2727
type: mongoose.Schema.Types.Mixed,
28-
default: null,
28+
// default: null,
2929
},
3030
...conversationPreset,
3131
// for bingAI only
3232
bingConversationId: {
3333
type: String,
34-
default: null,
34+
// default: null,
3535
},
3636
jailbreakConversationId: {
3737
type: String,
38-
default: null,
38+
// default: null,
3939
},
4040
conversationSignature: {
4141
type: String,
42-
default: null,
42+
// default: null,
4343
},
4444
clientId: {
4545
type: String,
46-
default: null,
46+
// default: null,
4747
},
4848
invocationId: {
4949
type: Number,
50-
default: 1,
50+
// default: 1,
5151
},
5252
},
5353
{ timestamps: true },

api/models/schema/defaults.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,147 +8,147 @@ const conversationPreset = {
88
// for azureOpenAI, openAI, chatGPTBrowser only
99
model: {
1010
type: String,
11-
default: null,
11+
// default: null,
1212
required: false,
1313
},
1414
// for azureOpenAI, openAI only
1515
chatGptLabel: {
1616
type: String,
17-
default: null,
17+
// default: null,
1818
required: false,
1919
},
2020
// for google only
2121
modelLabel: {
2222
type: String,
23-
default: null,
23+
// default: null,
2424
required: false,
2525
},
2626
promptPrefix: {
2727
type: String,
28-
default: null,
28+
// default: null,
2929
required: false,
3030
},
3131
temperature: {
3232
type: Number,
33-
default: 1,
33+
// default: 1,
3434
required: false,
3535
},
3636
top_p: {
3737
type: Number,
38-
default: 1,
38+
// default: 1,
3939
required: false,
4040
},
4141
// for google only
4242
topP: {
4343
type: Number,
44-
default: 0.95,
44+
// default: 0.95,
4545
required: false,
4646
},
4747
topK: {
4848
type: Number,
49-
default: 40,
49+
// default: 40,
5050
required: false,
5151
},
5252
maxOutputTokens: {
5353
type: Number,
54-
default: 1024,
54+
// default: 1024,
5555
required: false,
5656
},
5757
presence_penalty: {
5858
type: Number,
59-
default: 0,
59+
// default: 0,
6060
required: false,
6161
},
6262
frequency_penalty: {
6363
type: Number,
64-
default: 0,
64+
// default: 0,
6565
required: false,
6666
},
6767
// for bingai only
6868
jailbreak: {
6969
type: Boolean,
70-
default: false,
70+
// default: false,
7171
},
7272
context: {
7373
type: String,
74-
default: null,
74+
// default: null,
7575
},
7676
systemMessage: {
7777
type: String,
78-
default: null,
78+
// default: null,
7979
},
8080
toneStyle: {
8181
type: String,
82-
default: null,
82+
// default: null,
8383
},
8484
};
8585

8686
const agentOptions = {
8787
model: {
8888
type: String,
89-
default: null,
89+
// default: null,
9090
required: false,
9191
},
9292
// for azureOpenAI, openAI only
9393
chatGptLabel: {
9494
type: String,
95-
default: null,
95+
// default: null,
9696
required: false,
9797
},
9898
// for google only
9999
modelLabel: {
100100
type: String,
101-
default: null,
101+
// default: null,
102102
required: false,
103103
},
104104
promptPrefix: {
105105
type: String,
106-
default: null,
106+
// default: null,
107107
required: false,
108108
},
109109
temperature: {
110110
type: Number,
111-
default: 1,
111+
// default: 1,
112112
required: false,
113113
},
114114
top_p: {
115115
type: Number,
116-
default: 1,
116+
// default: 1,
117117
required: false,
118118
},
119119
// for google only
120120
topP: {
121121
type: Number,
122-
default: 0.95,
122+
// default: 0.95,
123123
required: false,
124124
},
125125
topK: {
126126
type: Number,
127-
default: 40,
127+
// default: 40,
128128
required: false,
129129
},
130130
maxOutputTokens: {
131131
type: Number,
132-
default: 1024,
132+
// default: 1024,
133133
required: false,
134134
},
135135
presence_penalty: {
136136
type: Number,
137-
default: 0,
137+
// default: 0,
138138
required: false,
139139
},
140140
frequency_penalty: {
141141
type: Number,
142-
default: 0,
142+
// default: 0,
143143
required: false,
144144
},
145145
context: {
146146
type: String,
147-
default: null,
147+
// default: null,
148148
},
149149
systemMessage: {
150150
type: String,
151-
default: null,
151+
// default: null,
152152
},
153153
};
154154

api/server/controllers/EndpointController.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { EModelEndpoint } = require('../routes/endpoints/schemas');
12
const { availableTools } = require('../../app/clients/tools');
23
const { addOpenAPISpecs } = require('../../app/clients/tools/util/addOpenAPISpecs');
34
const {
@@ -7,6 +8,7 @@ const {
78
userProvidedOpenAI,
89
palmKey,
910
openAI,
11+
assistant,
1012
azureOpenAI,
1113
bingAI,
1214
chatGPTBrowser,
@@ -53,7 +55,16 @@ async function endpointController(req, res) {
5355
: false;
5456

5557
res.send(
56-
JSON.stringify({ azureOpenAI, openAI, google, bingAI, chatGPTBrowser, gptPlugins, anthropic }),
58+
JSON.stringify({
59+
[EModelEndpoint.openAI]: openAI,
60+
[EModelEndpoint.assistant]: assistant,
61+
[EModelEndpoint.azureOpenAI]: azureOpenAI,
62+
[EModelEndpoint.google]: google,
63+
[EModelEndpoint.bingAI]: bingAI,
64+
[EModelEndpoint.chatGPTBrowser]: chatGPTBrowser,
65+
[EModelEndpoint.gptPlugins]: gptPlugins,
66+
[EModelEndpoint.anthropic]: anthropic,
67+
}),
5768
);
5869
}
5970

api/server/controllers/ModelController.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { EModelEndpoint } = require('../routes/endpoints/schemas');
12
const {
23
getOpenAIModels,
34
getChatGPTBrowserModels,
@@ -6,17 +7,28 @@ const {
67

78
const { useAzurePlugins } = require('../services/EndpointService').config;
89

10+
const fitlerAssistantModels = (str) => {
11+
return /gpt-4|gpt-3\\.5/i.test(str) && !/vision|instruct/i.test(str);
12+
};
13+
914
async function modelController(req, res) {
10-
const google = ['chat-bison', 'text-bison', 'codechat-bison'];
1115
const openAI = await getOpenAIModels();
1216
const azureOpenAI = await getOpenAIModels({ azure: true });
1317
const gptPlugins = await getOpenAIModels({ azure: useAzurePlugins, plugins: true });
14-
const bingAI = ['BingAI', 'Sydney'];
1518
const chatGPTBrowser = getChatGPTBrowserModels();
1619
const anthropic = getAnthropicModels();
1720

1821
res.send(
19-
JSON.stringify({ azureOpenAI, openAI, google, bingAI, chatGPTBrowser, gptPlugins, anthropic }),
22+
JSON.stringify({
23+
[EModelEndpoint.openAI]: openAI,
24+
[EModelEndpoint.azureOpenAI]: azureOpenAI,
25+
[EModelEndpoint.assistant]: openAI.filter(fitlerAssistantModels),
26+
[EModelEndpoint.google]: ['chat-bison', 'text-bison', 'codechat-bison'],
27+
[EModelEndpoint.bingAI]: ['BingAI', 'Sydney'],
28+
[EModelEndpoint.chatGPTBrowser]: chatGPTBrowser,
29+
[EModelEndpoint.gptPlugins]: gptPlugins,
30+
[EModelEndpoint.anthropic]: anthropic,
31+
}),
2032
);
2133
}
2234

api/server/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const startServer = async () => {
6464
app.use('/api/models', routes.models);
6565
app.use('/api/plugins', routes.plugins);
6666
app.use('/api/config', routes.config);
67+
app.use('/api/assistants', routes.assistants);
6768

6869
// Static files
6970
app.get('/*', function (req, res) {

api/server/routes/ask/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const {
1515
messageUserLimiter,
1616
} = require('../../middleware');
1717
const { isEnabled } = require('../../utils');
18+
const { EModelEndpoint } = require('../endpoints/schemas');
1819

1920
const { LIMIT_CONCURRENT_MESSAGES, LIMIT_MESSAGE_IP, LIMIT_MESSAGE_USER } = process.env ?? {};
2021

@@ -34,11 +35,11 @@ if (isEnabled(LIMIT_MESSAGE_USER)) {
3435
router.use(messageUserLimiter);
3536
}
3637

37-
router.use(['/azureOpenAI', '/openAI'], openAI);
38-
router.use('/google', google);
39-
router.use('/bingAI', bingAI);
40-
router.use('/chatGPTBrowser', askChatGPTBrowser);
41-
router.use('/gptPlugins', gptPlugins);
42-
router.use('/anthropic', anthropic);
38+
router.use([`/${EModelEndpoint.azureOpenAI}`, `/${EModelEndpoint.openAI}`], openAI);
39+
router.use(`/${EModelEndpoint.google}`, google);
40+
router.use(`/${EModelEndpoint.bingAI}`, bingAI);
41+
router.use(`/${EModelEndpoint.chatGPTBrowser}`, askChatGPTBrowser);
42+
router.use(`/${EModelEndpoint.gptPlugins}`, gptPlugins);
43+
router.use(`/${EModelEndpoint.anthropic}`, anthropic);
4344

4445
module.exports = router;

0 commit comments

Comments
 (0)