| | |
| | | import produce from 'immer' |
| | | import { useContext } from 'use-context-selector' |
| | | import ConfirmAddVar from './confirm-add-var' |
| | | import s from './style.module.css' |
| | | import PromptEditorHeightResizeWrap from './prompt-editor-height-resize-wrap' |
| | | import cn from '@/utils/classnames' |
| | | import type { PromptVariable } from '@/models/debug' |
| | | import { type PromptVariable } from '@/models/debug' |
| | | import Tooltip from '@/app/components/base/tooltip' |
| | | import type { CompletionParams } from '@/types/app' |
| | | import { AppType } from '@/types/app' |
| | |
| | | import { PROMPT_EDITOR_UPDATE_VALUE_BY_EVENT_EMITTER } from '@/app/components/base/prompt-editor/plugins/update-block' |
| | | import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' |
| | | import { useFeaturesStore } from '@/app/components/base/features/hooks' |
| | | import { noop } from 'lodash-es' |
| | | |
| | | export type ISimplePromptInput = { |
| | | mode: AppType |
| | |
| | | readonly = false, |
| | | onChange, |
| | | noTitle, |
| | | gradientBorder, |
| | | editorHeight: initEditorHeight, |
| | | noResize, |
| | | }) => { |
| | |
| | | const [editorHeight, setEditorHeight] = useState(minHeight) |
| | | |
| | | return ( |
| | | <div className={cn('relative rounded-xl bg-gradient-to-r from-components-input-border-active-prompt-1 to-components-input-border-active-prompt-2 p-0.5 shadow-xs')}> |
| | | <div className='rounded-xl bg-background-section-burn'> |
| | | <div className={cn((!readonly || gradientBorder) ? `${s.gradientBorder}` : 'bg-gray-50', ' relative shadow-md')}> |
| | | <div className='rounded-xl bg-[#EEF4FF]'> |
| | | {!noTitle && ( |
| | | <div className="flex h-11 items-center justify-between pl-3 pr-2.5"> |
| | | <div className="flex justify-between items-center h-11 pl-3 pr-6"> |
| | | <div className="flex items-center space-x-1"> |
| | | <div className='h2 system-sm-semibold-uppercase text-text-secondary'>{mode !== AppType.completion ? t('appDebug.chatSubTitle') : t('appDebug.completionSubTitle')}</div> |
| | | <div className='h2'>{mode !== AppType.completion ? t('appDebug.chatSubTitle') : t('appDebug.completionSubTitle')}</div> |
| | | {!readonly && ( |
| | | <Tooltip |
| | | popupContent={ |
| | |
| | | )} |
| | | |
| | | <PromptEditorHeightResizeWrap |
| | | className='min-h-[228px] rounded-t-xl bg-background-default px-4 pt-2 text-sm text-text-secondary' |
| | | className='px-4 pt-2 min-h-[228px] bg-white rounded-t-xl text-sm text-gray-700' |
| | | height={editorHeight} |
| | | minHeight={minHeight} |
| | | onHeightChange={setEditorHeight} |
| | | hideResize={noResize} |
| | | footer={( |
| | | <div className='flex rounded-b-xl bg-background-default pb-2 pl-4'> |
| | | <div className="h-[18px] rounded-md bg-components-badge-bg-gray-soft px-1 text-xs leading-[18px] text-text-tertiary">{promptTemplate.length}</div> |
| | | <div className='pl-4 pb-2 flex bg-white rounded-b-xl'> |
| | | <div className="h-[18px] leading-[18px] px-1 rounded-md bg-gray-100 text-xs text-gray-500">{promptTemplate.length}</div> |
| | | </div> |
| | | )} |
| | | > |
| | |
| | | user: '', |
| | | assistant: '', |
| | | }, |
| | | onEditRole: noop, |
| | | onEditRole: () => { }, |
| | | }} |
| | | queryBlock={{ |
| | | show: false, |
| | | selectable: !hasSetBlockStatus.query, |
| | | }} |
| | | onChange={(value) => { |
| | | if (handleChange) |
| | | handleChange(value, []) |
| | | handleChange?.(value, []) |
| | | }} |
| | | onBlur={() => { |
| | | handleChange(promptTemplate, getVars(promptTemplate)) |