💬 feat: assistant conversation starter (#3699)

* feat: initial UI convoStart

* fix: ConvoStarter UI

* fix: convoStarters bug

* feat: Add input field focus on conversation starters

* style: conversation starter UI update

* feat: apply fixes for starters

* style: update conversationStarters UI and fixed typo

* general UI update

* feat: Add onClick functionality to ConvoStarter component

* fix: quick fix test

* fix(AssistantSelect): remove object check

* fix: updateAssistant `conversation_starters` var

* chore: remove starter autofocus

* fix: no empty conversation starters, always show input, use Constants value for max count

* style: Update defaultTextPropsLabel styles, for a11y placeholder

* refactor: Update ConvoStarter component styles and class names for a11y and theme

* refactor: convostarter, move plus button to within persistent element

* fix: types

* chore: Update landing page assistant description styling with theming

* chore: assistant types

* refactor: documents routes

* refactor: optimize conversation starter mutations/queries

* refactor: Update listAllAssistants return type to Promise<Array<Assistant>>

* feat: edit existing starters

* feat(convo-starters): enhance ConvoStarter component and add animations

    - Update ConvoStarter component styling for better visual appeal
    - Implement fade-in animation for smoother appearance
    - Add hover effect with background color change
    - Improve text overflow handling with line-clamp and text-balance
    - Ensure responsive design for various screen sizes

* feat(assistant): add conversation starters to assistant builder

- Add localization strings for conversation starters
- Update mobile.css with shake animation for max starters reached
- Enhance user experience with tooltips and dynamic input handling

* refactor: select specific fields for assistant documents fetch

* refactor: remove endpoint query key, fetch all assistant docs for now, add conversation_starters to v1 methods

* refactor: add document filters based on endpoint config

* fix: starters not applied during creation

* refactor: update AssistantSelect component to handle undefined lastSelectedModels

---------

Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
Marco Beretta 2024-08-31 13:42:20 -04:00 committed by GitHub
parent 63b80c3067
commit 79f9cd5a4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
58 changed files with 602 additions and 214 deletions

View file

@ -13,7 +13,7 @@ import type {
ValidationResult,
AssistantsEndpoint,
} from 'librechat-data-provider';
import type { ActionAuthForm } from '~/common';
import type { ActionAuthForm, ActionWithNullableMetadata } from '~/common';
import type { Spec } from './ActionsTable';
import { useAssistantsMapContext, useToastContext } from '~/Providers';
import { ActionsTable, columns } from './ActionsTable';
@ -37,7 +37,7 @@ export default function ActionsInput({
version,
setAction,
}: {
action?: Action;
action?: ActionWithNullableMetadata;
assistant_id?: string;
endpoint: AssistantsEndpoint;
version: number | string;
@ -62,12 +62,13 @@ export default function ActionsInput({
const [functions, setFunctions] = useState<FunctionTool[] | null>(null);
useEffect(() => {
if (!action?.metadata.raw_spec) {
const rawSpec = action?.metadata?.raw_spec ?? '';
if (!rawSpec) {
return;
}
setInputValue(action.metadata.raw_spec);
debouncedValidation(action.metadata.raw_spec, handleResult);
}, [action?.metadata.raw_spec]);
setInputValue(rawSpec);
debouncedValidation(rawSpec, handleResult);
}, [action?.metadata?.raw_spec]);
useEffect(() => {
if (!validationResult || !validationResult.status || !validationResult.spec) {
@ -100,7 +101,8 @@ export default function ActionsInput({
},
onError(error) {
showToast({
message: (error as Error).message ?? localize('com_assistants_update_actions_error'),
message:
(error as Error | undefined)?.message ?? localize('com_assistants_update_actions_error'),
status: 'error',
});
},
@ -108,7 +110,8 @@ export default function ActionsInput({
const saveAction = handleSubmit((authFormData) => {
console.log('authFormData', authFormData);
if (!assistant_id) {
const currentAssistantId = assistant_id ?? '';
if (!currentAssistantId) {
// alert user?
return;
}
@ -121,7 +124,10 @@ export default function ActionsInput({
return;
}
let { metadata = {} } = action ?? {};
let { metadata } = action ?? {};
if (!metadata) {
metadata = {};
}
const action_id = action?.action_id;
metadata.raw_spec = inputValue;
const parsedUrl = new URL(data[0].domain);
@ -177,10 +183,10 @@ export default function ActionsInput({
action_id,
metadata,
functions,
assistant_id,
assistant_id: currentAssistantId,
endpoint,
version,
model: assistantMap?.[endpoint][assistant_id].model ?? '',
model: assistantMap?.[endpoint][currentAssistantId].model ?? '',
});
});