mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-12 13:38:51 +01:00
* chore: update @librechat/agents to version 2.1.9
* feat: xAI standalone provider for agents
* chore: bump librechat-data-provider version to 0.7.6997
* fix: reorder import statements and enhance user listing output
* fix: Update Docker Compose commands to support v2 syntax with fallback
* 🔧 fix: drop `reasoning_effort` for o1-preview/mini models
* chore: requireLocalAuth logging
* fix: edge case artifact message editing logic to handle `new` conversation IDs
* fix: remove `temperature` from model options in OpenAIClient if o1-mini/preview
* fix: update type annotation for fetchPromisesMap to use Promise<string[]> instead of string[]
* feat: anthropic model fetching
* fix: update model name to use EModelEndpoint.openAI in fetchModels and fetchOpenAIModels
* fix: add error handling to modelController for loadModels
* fix: add error handling and logging for model fetching in loadDefaultModels
* ci: update getAnthropicModels tests to be asynchronous
* feat: add user ID to model options in OpenAI and custom endpoint initialization
---------
Co-authored-by: Andrei Berceanu <andreicberceanu@gmail.com>
Co-authored-by: KiGamji <maloyh44@gmail.com>
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { dataService, QueryKeys, Constants } from 'librechat-data-provider';
|
|
import type { UseMutationResult } from '@tanstack/react-query';
|
|
import type * as t from 'librechat-data-provider';
|
|
|
|
export const useEditArtifact = (
|
|
_options?: t.EditArtifactOptions,
|
|
): UseMutationResult<t.TEditArtifactResponse, Error, t.TEditArtifactRequest> => {
|
|
const queryClient = useQueryClient();
|
|
const { onSuccess, ...options } = _options ?? {};
|
|
return useMutation({
|
|
mutationFn: (variables: t.TEditArtifactRequest) => dataService.editArtifact(variables),
|
|
onSuccess: (data, vars, context) => {
|
|
let targetNotFound = true;
|
|
const setMessageData = (conversationId?: string | null) => {
|
|
if (!conversationId) {
|
|
return;
|
|
}
|
|
queryClient.setQueryData<t.TMessage[]>([QueryKeys.messages, conversationId], (prev) => {
|
|
if (!prev) {
|
|
return prev;
|
|
}
|
|
|
|
const newArray = [...prev];
|
|
let targetIndex: number | undefined;
|
|
|
|
for (let i = newArray.length - 1; i >= 0; i--) {
|
|
if (newArray[i].messageId === vars.messageId) {
|
|
targetIndex = i;
|
|
targetNotFound = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (targetIndex == null) {
|
|
return prev;
|
|
}
|
|
|
|
newArray[targetIndex] = {
|
|
...newArray[targetIndex],
|
|
content: data.content,
|
|
text: data.text,
|
|
};
|
|
|
|
return newArray;
|
|
});
|
|
};
|
|
setMessageData(data.conversationId);
|
|
if (targetNotFound) {
|
|
console.warn(
|
|
'Edited Artifact Message not found in cache, trying `new` as `conversationId`',
|
|
);
|
|
setMessageData(Constants.NEW_CONVO);
|
|
}
|
|
|
|
onSuccess?.(data, vars, context);
|
|
},
|
|
...options,
|
|
});
|
|
};
|