mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🗃️ feat: General File Support for OpenAI, Azure, Custom, Anthropic and Google (RAG) (#2143)
* refactor: re-purpose `resendImages` as `resendFiles` * refactor: re-purpose `resendImages` as `resendFiles` * feat: upload general files * feat: embed file during upload * feat: delete file embeddings on file deletion * chore(fileConfig): add epub+zip type * feat(encodeAndFormat): handle non-image files * feat(createContextHandlers): build context prompt from file attachments and successful RAG * fix: prevent non-temp files as well as embedded files to be deleted on new conversation * fix: remove temp_file_id on usage, prevent non-temp files as well as embedded files to be deleted on new conversation * fix: prevent non-temp files as well as embedded files to be deleted on new conversation * feat(OpenAI/Anthropic/Google): basic RAG support * fix: delete `resendFiles` only when true (Default) * refactor(RAG): update endpoints and pass JWT * fix(resendFiles): default values * fix(context/processFile): query unique ids only * feat: rag-api.yaml * feat: file upload improved ux for longer uploads * chore: await embed call and catch embedding errors * refactor: store augmentedPrompt in Client * refactor(processFileUpload): throw error if not assistant file upload * fix(useFileHandling): handle markdown empty mimetype issue * chore: necessary compose file changes
This commit is contained in:
parent
af347cccde
commit
f7761df52c
38 changed files with 683 additions and 261 deletions
|
|
@ -216,8 +216,10 @@ export const tConversationSchema = z.object({
|
|||
maxOutputTokens: z.number().optional(),
|
||||
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
||||
file_ids: z.array(z.string()).optional(),
|
||||
/* vision */
|
||||
/** @deprecated */
|
||||
resendImages: z.boolean().optional(),
|
||||
/* vision */
|
||||
resendFiles: z.boolean().optional(),
|
||||
imageDetail: eImageDetailSchema.optional(),
|
||||
/* assistant */
|
||||
assistant_id: z.string().optional(),
|
||||
|
|
@ -273,7 +275,7 @@ export const openAISchema = tConversationSchema
|
|||
top_p: true,
|
||||
presence_penalty: true,
|
||||
frequency_penalty: true,
|
||||
resendImages: true,
|
||||
resendFiles: true,
|
||||
imageDetail: true,
|
||||
})
|
||||
.transform((obj) => ({
|
||||
|
|
@ -285,7 +287,7 @@ export const openAISchema = tConversationSchema
|
|||
top_p: obj.top_p ?? 1,
|
||||
presence_penalty: obj.presence_penalty ?? 0,
|
||||
frequency_penalty: obj.frequency_penalty ?? 0,
|
||||
resendImages: obj.resendImages ?? false,
|
||||
resendFiles: typeof obj.resendFiles === 'boolean' ? obj.resendFiles : true,
|
||||
imageDetail: obj.imageDetail ?? ImageDetail.auto,
|
||||
}))
|
||||
.catch(() => ({
|
||||
|
|
@ -296,7 +298,7 @@ export const openAISchema = tConversationSchema
|
|||
top_p: 1,
|
||||
presence_penalty: 0,
|
||||
frequency_penalty: 0,
|
||||
resendImages: false,
|
||||
resendFiles: true,
|
||||
imageDetail: ImageDetail.auto,
|
||||
}));
|
||||
|
||||
|
|
@ -391,7 +393,7 @@ export const anthropicSchema = tConversationSchema
|
|||
maxOutputTokens: true,
|
||||
topP: true,
|
||||
topK: true,
|
||||
resendImages: true,
|
||||
resendFiles: true,
|
||||
})
|
||||
.transform((obj) => ({
|
||||
...obj,
|
||||
|
|
@ -402,7 +404,7 @@ export const anthropicSchema = tConversationSchema
|
|||
maxOutputTokens: obj.maxOutputTokens ?? 4000,
|
||||
topP: obj.topP ?? 0.7,
|
||||
topK: obj.topK ?? 5,
|
||||
resendImages: obj.resendImages ?? false,
|
||||
resendFiles: typeof obj.resendFiles === 'boolean' ? obj.resendFiles : true,
|
||||
}))
|
||||
.catch(() => ({
|
||||
model: 'claude-1',
|
||||
|
|
@ -412,7 +414,7 @@ export const anthropicSchema = tConversationSchema
|
|||
maxOutputTokens: 4000,
|
||||
topP: 0.7,
|
||||
topK: 5,
|
||||
resendImages: false,
|
||||
resendFiles: true,
|
||||
}));
|
||||
|
||||
export const chatGPTBrowserSchema = tConversationSchema
|
||||
|
|
@ -504,7 +506,7 @@ export const compactOpenAISchema = tConversationSchema
|
|||
top_p: true,
|
||||
presence_penalty: true,
|
||||
frequency_penalty: true,
|
||||
resendImages: true,
|
||||
resendFiles: true,
|
||||
imageDetail: true,
|
||||
})
|
||||
.transform((obj: Partial<TConversation>) => {
|
||||
|
|
@ -521,8 +523,8 @@ export const compactOpenAISchema = tConversationSchema
|
|||
if (newObj.frequency_penalty === 0) {
|
||||
delete newObj.frequency_penalty;
|
||||
}
|
||||
if (newObj.resendImages !== true) {
|
||||
delete newObj.resendImages;
|
||||
if (newObj.resendFiles === true) {
|
||||
delete newObj.resendFiles;
|
||||
}
|
||||
if (newObj.imageDetail === ImageDetail.auto) {
|
||||
delete newObj.imageDetail;
|
||||
|
|
@ -571,7 +573,7 @@ export const compactAnthropicSchema = tConversationSchema
|
|||
maxOutputTokens: true,
|
||||
topP: true,
|
||||
topK: true,
|
||||
resendImages: true,
|
||||
resendFiles: true,
|
||||
})
|
||||
.transform((obj) => {
|
||||
const newObj: Partial<TConversation> = { ...obj };
|
||||
|
|
@ -587,8 +589,8 @@ export const compactAnthropicSchema = tConversationSchema
|
|||
if (newObj.topK === 5) {
|
||||
delete newObj.topK;
|
||||
}
|
||||
if (newObj.resendImages !== true) {
|
||||
delete newObj.resendImages;
|
||||
if (newObj.resendFiles === true) {
|
||||
delete newObj.resendFiles;
|
||||
}
|
||||
|
||||
return removeNullishValues(newObj);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue