mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-03 00:58:50 +01:00
feat: chat ui and functionality for prompts (auto-send not working)
This commit is contained in:
parent
7c3356e10b
commit
607a5a2fcf
18 changed files with 636 additions and 19 deletions
|
|
@ -3,7 +3,7 @@ import { AutoSizer, List } from 'react-virtualized';
|
|||
import { Spinner, useCombobox } from '@librechat/client';
|
||||
import { useSetRecoilState, useRecoilValue } from 'recoil';
|
||||
import { PermissionTypes, Permissions } from 'librechat-data-provider';
|
||||
import type { TPromptGroup } from 'librechat-data-provider';
|
||||
import type { TPromptGroup, AgentToolResources } from 'librechat-data-provider';
|
||||
import type { PromptOption } from '~/common';
|
||||
import { removeCharIfLast, detectVariables } from '~/utils';
|
||||
import VariableDialog from '~/components/Prompts/Groups/VariableDialog';
|
||||
|
|
@ -51,7 +51,7 @@ function PromptsCommand({
|
|||
}: {
|
||||
index: number;
|
||||
textAreaRef: React.MutableRefObject<HTMLTextAreaElement | null>;
|
||||
submitPrompt: (textPrompt: string) => void;
|
||||
submitPrompt: (textPrompt: string, toolResources?: AgentToolResources) => void;
|
||||
}) {
|
||||
const localize = useLocalize();
|
||||
const hasAccess = useHasAccess({
|
||||
|
|
@ -79,7 +79,10 @@ function PromptsCommand({
|
|||
|
||||
const handleSelect = useCallback(
|
||||
(mention?: PromptOption, e?: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
console.log('PromptsCommand.handleSelect called with mention:', mention);
|
||||
|
||||
if (!mention) {
|
||||
console.log('No mention provided');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -92,10 +95,19 @@ function PromptsCommand({
|
|||
}
|
||||
|
||||
const group = promptsMap?.[mention.id];
|
||||
console.log('Found group for mention:', group);
|
||||
if (!group) {
|
||||
console.log('No group found for mention ID:', mention.id);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Group productionPrompt details:', {
|
||||
hasProductionPrompt: !!group.productionPrompt,
|
||||
prompt: group.productionPrompt?.prompt?.substring(0, 100) + '...',
|
||||
tool_resources: group.productionPrompt?.tool_resources,
|
||||
hasToolResources: !!group.productionPrompt?.tool_resources,
|
||||
});
|
||||
|
||||
const hasVariables = detectVariables(group.productionPrompt?.prompt ?? '');
|
||||
if (hasVariables) {
|
||||
if (e && e.key === 'Tab') {
|
||||
|
|
@ -105,7 +117,16 @@ function PromptsCommand({
|
|||
setVariableDialogOpen(true);
|
||||
return;
|
||||
} else {
|
||||
submitPrompt(group.productionPrompt?.prompt ?? '');
|
||||
console.log('PromptsCommand - Clicking prompt:', {
|
||||
promptName: group.name,
|
||||
promptText: group.productionPrompt?.prompt,
|
||||
toolResources: group.productionPrompt?.tool_resources,
|
||||
hasToolResources: !!group.productionPrompt?.tool_resources,
|
||||
toolResourcesKeys: group.productionPrompt?.tool_resources
|
||||
? Object.keys(group.productionPrompt.tool_resources)
|
||||
: [],
|
||||
});
|
||||
submitPrompt(group.productionPrompt?.prompt ?? '', group.productionPrompt?.tool_resources);
|
||||
}
|
||||
},
|
||||
[setSearchValue, setOpen, setShowPromptsPopover, textAreaRef, promptsMap, submitPrompt],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue