mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-21 09:46:12 +01:00
* feat: bare bones implementation of claude client (WIP) * feat: client implementation of Claude (WIP) * fix: add claude to store * feat: bare bones implementation of claude client (WIP) * switch eventsource * Try new method of calling claude with anthropic sdk * (WIP) Finish initial claude client implementation and api * debugging update * fix(ClaudeClient.js): fix prompt prefixes for HUMAN_PROMPT and AI_PROMPT fix(ClaudeClient.js): refactor buildMessages logic for correct handling of messages refactor(ClaudeClient.js): refactor buildPrompt method to buildMessages for use in BaseClient sendMessage method refactor(ClaudeClient.js): refactor getCompletion method to sendCompletion for use in BaseClient sendMessage method refactor(ClaudeClient.js): omit getMessageMapMethod method for future refactoring refactor(ClaudeClient.js): remove unused sendMessage method to prefer BaseClient message fix(askClaude.js): error in getIds method was causing a frontend crash, userMessage was not defined fix(askClaude.js): import abortMessage function from utils module feat(askClaude.js): add /abort route to handle message abort requests feat(askClaude.js): create abortControllers map to store abort controllers feat(askClaude.js): implement abortAsk function to handle message abort logic feat(askClaude.js): add onStart callback to handle message start logic feat(HoverButtons.jsx): add 'claude' as a supported endpoint for branching * fix(ClaudeClient.js): update defaultPrefix and promptPrefix messages includes 'Remember your instructions' as Claude is trained to recognize labels preceding colons as participants of a conversation * Change name from claude to anthropic * add settings to handleSubmit and models to endpoints * Implement Claude settings * use svg for anthropic icon * Implement abort * Implement reverse proxy * remove png icons * replace web browser plugin * remove default prefix * fix styling of claude icon * fix console error from svg properties * remove single quote requirement from eslintrc * fix(AnthropicClient.js): fix labels for HUMAN_PROMPT and AI_PROMPT feat(AnthropicClient.js): add support for custom userLabel and modelLabel options feat(AnthropicClient.js): add user_id metadata to requestOptions in getCompletion method feat(anthropic, AnthropicClient.js): add debug logging * refactor(AnthropicClient.js): change promptSuffix variable declaration from let to const * fix(EndpointOptionsDialog.jsx): remove unnecessary code that changes endpointName from 'anthropic' to 'Claude' fix(utils/index.jsx): fix alternateName value for 'anthropic' from 'Claude' to 'Anthropic' * fix(AnthropicIcon): fix sizing/rendering/name of anthropic icon * fix(AnthropicClient.js): change maxContextTokens default value to 99999 fix(AnthropicClient.js): change maxResponseTokens default value to 1500 fix(AnthropicClient.js): remove unnecessary code for setting maxContextTokens and maxResponseTokens based on modelOptions fix(AnthropicClient.js): change max_tokens_to_sample default value to 1500 fix(anthropic.js): pass endpointOption.token to AnthropicClient constructor * Update .env.example * fix(AnthropicClient.js): remove exceeding message when it puts us over the token limit fix(AnthropicClient.js): handle case when the first message exceeds the token limit fix(AnthropicClient.js): throw error when prompt is too long fix(AnthropicClient.js): adjust max tokens calculation to use maxOutputTokens fix(anthropic.js): remove console.log statement in ask route * feat(server/index): increase incoming json payload allowed size --------- Co-authored-by: Danny Avila <messagedaniel@protonmail.com>
81 lines
3.1 KiB
JavaScript
81 lines
3.1 KiB
JavaScript
import React from 'react';
|
|
import { cn } from '~/utils/';
|
|
import Clipboard from '../svg/Clipboard';
|
|
import CheckMark from '../svg/CheckMark';
|
|
import EditIcon from '../svg/EditIcon';
|
|
import RegenerateIcon from '../svg/RegenerateIcon';
|
|
|
|
export default function HoverButtons({
|
|
isEditting,
|
|
enterEdit,
|
|
copyToClipboard,
|
|
conversation,
|
|
isSubmitting,
|
|
message,
|
|
regenerate
|
|
}) {
|
|
const { endpoint } = conversation;
|
|
const [isCopied, setIsCopied] = React.useState(false);
|
|
|
|
const branchingSupported =
|
|
// azureOpenAI, openAI, chatGPTBrowser support branching, so edit enabled // 5/21/23: Bing is allowing editing and Message regenerating
|
|
!!['azureOpenAI', 'openAI', 'chatGPTBrowser', 'google', 'bingAI', 'gptPlugins', 'anthropic'].find(
|
|
(e) => e === endpoint
|
|
);
|
|
// Sydney in bingAI supports branching, so edit enabled
|
|
|
|
const editEnabled =
|
|
!message?.error &&
|
|
message?.isCreatedByUser &&
|
|
!message?.searchResult &&
|
|
!isEditting &&
|
|
branchingSupported;
|
|
|
|
// for now, once branching is supported, regerate will be enabled
|
|
let regenerateEnabled =
|
|
// !message?.error &&
|
|
!message?.isCreatedByUser &&
|
|
!message?.searchResult &&
|
|
!isEditting &&
|
|
!isSubmitting &&
|
|
branchingSupported;
|
|
|
|
return (
|
|
<div className="visible mt-2 flex justify-center gap-3 self-end text-gray-400 md:gap-4 lg:absolute lg:right-0 lg:top-0 lg:mt-0 lg:translate-x-full lg:gap-1 lg:self-center lg:pl-2">
|
|
{editEnabled ? (
|
|
<button
|
|
className="hover-button rounded-md p-1 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"
|
|
onClick={enterEdit}
|
|
type="button"
|
|
title="edit"
|
|
>
|
|
{/* <button className="rounded-md p-1 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"> */}
|
|
<EditIcon />
|
|
</button>
|
|
) : null}
|
|
{regenerateEnabled ? (
|
|
<button
|
|
className="hover-button active rounded-md p-1 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"
|
|
onClick={regenerate}
|
|
type="button"
|
|
title="regenerate"
|
|
>
|
|
{/* <button className="rounded-md p-1 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"> */}
|
|
<RegenerateIcon />
|
|
</button>
|
|
) : null}
|
|
|
|
<button
|
|
className={cn(
|
|
'hover-button rounded-md p-1 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible',
|
|
message?.isCreatedByUser ? '' : 'active'
|
|
)}
|
|
onClick={() => copyToClipboard(setIsCopied)}
|
|
type="button"
|
|
title={isCopied ? 'Copied to clipboard' : 'Copy to clipboard'}
|
|
>
|
|
{isCopied ? <CheckMark /> : <Clipboard />}
|
|
</button>
|
|
</div>
|
|
);
|
|
}
|