mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-11 18:42:36 +01:00
🧪 feat: Prompt Dropdown Variable; style: Add Markdown Support (#3681)
* 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>
This commit is contained in:
parent
bbb9324447
commit
d3a20357e9
19 changed files with 473 additions and 110 deletions
42
client/src/components/Prompts/Markdown.tsx
Normal file
42
client/src/components/Prompts/Markdown.tsx
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import React from 'react';
|
||||
import { handleDoubleClick } from '~/utils';
|
||||
|
||||
export const CodeVariableGfm = ({ children }: { children: React.ReactNode }) => {
|
||||
return (
|
||||
<code
|
||||
onDoubleClick={handleDoubleClick}
|
||||
className="rounded-md bg-surface-primary-alt p-1 text-xs text-text-secondary md:text-sm"
|
||||
>
|
||||
{children}
|
||||
</code>
|
||||
);
|
||||
};
|
||||
|
||||
const regex = /{{(.*?)}}/g;
|
||||
export const PromptVariableGfm = ({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode & React.ReactNode[];
|
||||
}) => {
|
||||
const renderContent = (child: React.ReactNode) => {
|
||||
if (typeof child === 'object' && child !== null) {
|
||||
return child;
|
||||
}
|
||||
if (typeof child !== 'string') {
|
||||
return child;
|
||||
}
|
||||
|
||||
const parts = child.split(regex);
|
||||
return parts.map((part, index) =>
|
||||
index % 2 === 1 ? (
|
||||
<b key={index} className="rounded-md bg-yellow-100/90 p-1 text-gray-700">
|
||||
{`{{${part}}}`}
|
||||
</b>
|
||||
) : (
|
||||
part
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
return <p>{React.Children.map(children, (child) => renderContent(child))}</p>;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue