mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-27 13:48:51 +01:00
* feat: Add extended inputs for promts library variables * feat: Add maxRows prop to VariableForm input field * 📩 feat: invite user (#3012) * feat: basic invite-user script * feat: add invite user functionality and registration validation middleware * fix: invite user fixes * refactor: consolidate direct model access to a central place of functions * style(Registration): add spinner to continue button * refactor: import ordrer * feat: improve invite user script and error handling * fix: merge conflict * refactor: remove `console.log` and use `logger` * fix: token operation and checkinvite issues * bring back comment and remove console log * fix: return invalid token when token is not found * fix: getInvite fix * refactor: Update Token.js to use async/await syntax for update and delete operations * feat: Refactor Token.js to use async/await syntax for createToken and findToken functions * refactor(inviteUser): define functions outside of module.exports * Update AuthService.js --------- Co-authored-by: Danny Avila <danny@librechat.ai> * style: improve OpenAI.tsx input field focus styling * refactor: update import statement in Input.tsx * refactor: remove multi-line * refactor: update placeholder text to use localization * style: new dropdown variable info and markdown styling for info * Add ReactMarkdown * chore: styling, import order * refactor: update ReactMarkdown usage in VariableForm * style: remove markdown class * refactor: update mobile styling and use code renderer * style(InputWithDropDown): update focus trigger style * style(OptionsPopover): update Save As Preset `focus` and `dark:bg` --------- Co-authored-by: Konstantin Meshcheryakov <kmeshcheryakov@klika-tech.com> Co-authored-by: Marco Beretta <81851188+berry-13@users.noreply.github.com> Co-authored-by: bsu3338 <bsu3338@users.noreply.github.com>
74 lines
3.1 KiB
TypeScript
74 lines
3.1 KiB
TypeScript
import React, { useMemo } from 'react';
|
|
import ReactMarkdown from 'react-markdown';
|
|
import remarkGfm from 'remark-gfm';
|
|
import rehypeKatex from 'rehype-katex';
|
|
import remarkMath from 'remark-math';
|
|
import supersub from 'remark-supersub';
|
|
import rehypeHighlight from 'rehype-highlight';
|
|
import type { TPromptGroup } from 'librechat-data-provider';
|
|
import { code } from '~/components/Chat/Messages/Content/Markdown';
|
|
import { useLocalize, useAuthContext } from '~/hooks';
|
|
import CategoryIcon from './Groups/CategoryIcon';
|
|
import PromptVariables from './PromptVariables';
|
|
import { PromptVariableGfm } from './Markdown';
|
|
import { replaceSpecialVars } from '~/utils';
|
|
import Description from './Description';
|
|
import Command from './Command';
|
|
|
|
const PromptDetails = ({ group }: { group?: TPromptGroup }) => {
|
|
const localize = useLocalize();
|
|
const { user } = useAuthContext();
|
|
|
|
const mainText = useMemo(() => {
|
|
const initialText = group?.productionPrompt?.prompt ?? '';
|
|
return replaceSpecialVars({ text: initialText, user });
|
|
}, [group?.productionPrompt?.prompt, user]);
|
|
|
|
if (!group) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<div className="flex flex-col items-center justify-between px-4 dark:text-gray-200 sm:flex-row">
|
|
<div className="mb-1 flex flex-row items-center font-bold sm:text-xl md:mb-0 md:text-2xl">
|
|
<div className="mb-1 flex items-center md:mb-0">
|
|
<div className="rounded p-2">
|
|
{(group.category?.length ?? 0) > 0 ? (
|
|
<CategoryIcon category={group.category ?? ''} />
|
|
) : null}
|
|
</div>
|
|
<span className="mr-2 border border-transparent p-2">{group.name}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="flex h-full max-h-screen w-full max-w-[90vw] flex-col overflow-y-auto md:flex-row">
|
|
<div className="flex flex-1 flex-col gap-4 border-gray-300 p-0 dark:border-gray-600 md:max-h-[calc(100vh-150px)] md:p-2">
|
|
<div>
|
|
<h2 className="flex items-center justify-between rounded-t-lg border border-gray-300 py-2 pl-4 text-base font-semibold dark:border-gray-600 dark:text-gray-200">
|
|
{localize('com_ui_prompt_text')}
|
|
</h2>
|
|
<div className="group relative min-h-32 rounded-b-lg border border-gray-300 p-4 transition-all duration-150 dark:border-gray-600 sm:max-w-full">
|
|
<ReactMarkdown
|
|
remarkPlugins={[supersub, remarkGfm, [remarkMath, { singleDollarTextMath: true }]]}
|
|
rehypePlugins={[
|
|
[rehypeKatex, { output: 'mathml' }],
|
|
[rehypeHighlight, { ignoreMissing: true }],
|
|
]}
|
|
components={{ p: PromptVariableGfm, code }}
|
|
className="prose dark:prose-invert light dark:text-gray-70 my-1"
|
|
>
|
|
{mainText}
|
|
</ReactMarkdown>
|
|
</div>
|
|
</div>
|
|
<PromptVariables promptText={mainText} showInfo={false} />
|
|
<Description initialValue={group.oneliner} disabled={true} />
|
|
<Command initialValue={group.command} disabled={true} />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default PromptDetails;
|