🏷️ fix: Ensure modelLabel Field Usage for ModelSpecs/GPTPlugins (#4224)

This commit is contained in:
Danny Avila 2024-09-24 07:27:11 -04:00 committed by GitHub
parent 321260e3c7
commit 6f498eee0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 10 deletions

View file

@ -199,8 +199,8 @@ class OpenAIClient extends BaseClient {
model: this.modelOptions.model, model: this.modelOptions.model,
endpoint: this.options.endpoint, endpoint: this.options.endpoint,
endpointType: this.options.endpointType, endpointType: this.options.endpointType,
chatGptLabel: this.options.chatGptLabel,
modelDisplayLabel: this.options.modelDisplayLabel, modelDisplayLabel: this.options.modelDisplayLabel,
chatGptLabel: this.options.chatGptLabel || this.options.modelLabel,
}); });
this.userLabel = this.options.userLabel || 'User'; this.userLabel = this.options.userLabel || 'User';

View file

@ -3,6 +3,7 @@ const generateArtifactsPrompt = require('~/app/clients/prompts/artifacts');
const buildOptions = (endpoint, parsedBody) => { const buildOptions = (endpoint, parsedBody) => {
const { const {
modelLabel,
chatGptLabel, chatGptLabel,
promptPrefix, promptPrefix,
agentOptions, agentOptions,
@ -16,10 +17,10 @@ const buildOptions = (endpoint, parsedBody) => {
} = parsedBody; } = parsedBody;
const endpointOption = removeNullishValues({ const endpointOption = removeNullishValues({
endpoint, endpoint,
tools: tools: tools
tools .map((tool) => tool?.pluginKey ?? tool)
.map((tool) => tool?.pluginKey ?? tool) .filter((toolName) => typeof toolName === 'string'),
.filter((toolName) => typeof toolName === 'string'), modelLabel,
chatGptLabel, chatGptLabel,
promptPrefix, promptPrefix,
agentOptions, agentOptions,

View file

@ -220,13 +220,16 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
model: _m, model: _m,
endpoint, endpoint,
endpointType, endpointType,
modelDisplayLabel, modelDisplayLabel: _mdl,
chatGptLabel, chatGptLabel: _cgl,
modelLabel, modelLabel: _ml,
jailbreak, jailbreak,
} = endpointOption; } = endpointOption;
const model = _m ?? ''; const model = _m ?? '';
const modelDisplayLabel = _mdl ?? '';
const chatGptLabel = _cgl ?? '';
const modelLabel = _ml ?? '';
if ( if (
[ [
EModelEndpoint.openAI, EModelEndpoint.openAI,
@ -238,6 +241,8 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
) { ) {
if (chatGptLabel) { if (chatGptLabel) {
return chatGptLabel; return chatGptLabel;
} else if (modelLabel) {
return modelLabel;
} else if (model && /\bo1\b/i.test(model)) { } else if (model && /\bo1\b/i.test(model)) {
return 'o1'; return 'o1';
} else if (model && model.includes('gpt-3')) { } else if (model && model.includes('gpt-3')) {
@ -257,11 +262,11 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
} }
if (endpoint === EModelEndpoint.anthropic) { if (endpoint === EModelEndpoint.anthropic) {
return modelLabel ?? 'Claude'; return modelLabel || 'Claude';
} }
if (endpoint === EModelEndpoint.bedrock) { if (endpoint === EModelEndpoint.bedrock) {
return modelLabel ?? alternateName[endpoint]; return modelLabel || alternateName[endpoint];
} }
if (endpoint === EModelEndpoint.google) { if (endpoint === EModelEndpoint.google) {

View file

@ -1018,6 +1018,7 @@ export const compactChatGPTSchema = tConversationSchema
export const compactPluginsSchema = tConversationSchema export const compactPluginsSchema = tConversationSchema
.pick({ .pick({
model: true, model: true,
modelLabel: true,
chatGptLabel: true, chatGptLabel: true,
promptPrefix: true, promptPrefix: true,
temperature: true, temperature: true,
@ -1033,6 +1034,9 @@ export const compactPluginsSchema = tConversationSchema
}) })
.transform((obj) => { .transform((obj) => {
const newObj: Partial<TConversation> = { ...obj }; const newObj: Partial<TConversation> = { ...obj };
if (newObj.modelLabel === null) {
delete newObj.modelLabel;
}
if (newObj.chatGptLabel === null) { if (newObj.chatGptLabel === null) {
delete newObj.chatGptLabel; delete newObj.chatGptLabel;
} }