In-flow user input
In-flow user input (흐름 내 사용자 입력)
생성형 AI 채팅 내에서 구조화된 입력을 수집하거나 사용자가 에이전트가 생성한 출력을 검토하고 수정할 수 있게 하는 인라인 상호작용을 다룹니다. 이 페이지에서는 핵심 UX 개념, 일반적인 사용 사례, 일반 가이드라인, 작성 가이드라인, 접근성 가이드라인을 다룹니다.
출처: 문서
본문
생성형 AI 채팅 내에서 구조화된 입력을 수집하거나 사용자가 에이전트가 생성한 출력을 검토하고 수정할 수 있게 하는 인라인 상호작용.
핵심 UX 개념 (Key UX concepts)
올바른 시점에 올바른 정보 (The right information at the right time)
에이전트가 사용자의 의도를 이해하고 진행하기 위해 사용자에게서 특정한 무언가가 필요할 때만 상호작용을 제시하세요. 연기하거나 자동으로 해결할 수 있는 상호작용을 앞당겨(프론트 로드) 배치하지 마세요.
입력이 필요한 이유 설명 (Explain why input is needed)
사용자가 추가 정보를 제공하는 것의 가치를 이해하도록 돕습니다. 사용자의 입력이 에이전트가 더 나은 출력을 생성하거나 동작을 올바르게 실행할 수 있게 하며, 예상되는 결과를 강조하세요.
입력 메커니즘을 정보 유형에 맞추기 (Match input mechanism to information type)
수집할 정보의 유형을 보완하는 입력 방법을 표시하세요. 리소스 ID나 타임스탬프 선택 같은 유한한 답변 집합이 있는 질문은 간결한 form을 사용해야 합니다. 이렇게 하면 오류를 줄이고 데이터 품질을 개선합니다.
일반적인 사용 사례 (Common use cases)
에이전트가 동작을 실행하기 위해 여러 입력이 필요한 경우 (Agent needs multiple inputs to execute an action)
인라인 폼이 대화에서 필요한 값을 직접 수집합니다. 예: 에이전트가 리소스 생성을 돕고 어떤 정보가 필요한지에 따라 점진적으로 폼을 인라인으로 표시합니다. 단계는 동기적(synchronous)입니다. 이전 단계의 출력이 다음 단계를 결정합니다. 폼은 순차적으로 나타나며 각 단계 사이에 에이전트 응답이 있을 수 있습니다. 완료된 단계는 요약된 읽기 전용 보기를 보여줍니다.
Generative AI assistant
야간 정리 작업을 실행하는 예약 Lambda 설정을 요청하는 사용자와, 필요한 구성 세부 정보를 묻기 위해 인라인 폼(item card 안의 Lambda function setup)을 제시하는 에이전트의 예시입니다. 함수 이름, 런타임, 메모리, 타임아웃, 일정 필드를 포함하며, 완료 시 각 필드가 요약된 읽기 전용 보기로 표시됩니다.
import React, { useState } from 'react';
import Box from '@cloudscape-design/components/box';
import Button from '@cloudscape-design/components/button';
import Container from '@cloudscape-design/components/container';
import ExpandableSection from '@cloudscape-design/components/expandable-section';
import FormField from '@cloudscape-design/components/form-field';
import Header from '@cloudscape-design/components/header';
import Input from '@cloudscape-design/components/input';
import ItemCard from '@cloudscape-design/components/item-card';
import KeyValuePairs from '@cloudscape-design/components/key-value-pairs';
import Select, { SelectProps } from '@cloudscape-design/components/select';
import SpaceBetween from '@cloudscape-design/components/space-between';
import StatusIndicator from '@cloudscape-design/components/status-indicator';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import { genAiAvatar, genAiName, userAvatar, userName } from '../genai-common/avatars';
import CustomGenAIChatFooter from '../gen-ai-response-regeneration/custom-gen-ai-chat-footer';
import '../genai-common/styles.scss';
export default function GenAiInlineChatActionsFormInput() {
const [prompt, setPrompt] = useState('');
const [loading, setLoading] = useState(false);
const [submitted, setSubmitted] = useState(false);
const [expanded, setExpanded] = useState(true);
const [responseReady, setResponseReady] = useState(false);
const [streamedText, setStreamedText] = useState('');
const [streamComplete, setStreamComplete] = useState(false);
const [functionName, setFunctionName] = useState('nightly-cleanup');
const [functionNameError, setFunctionNameError] = useState('');
const [runtime, setRuntime] = useState<SelectProps.Option | null>({ value: 'python312', label: 'Python 3.12' });
const [memory, setMemory] = useState<SelectProps.Option | null>({ value: '256', label: '256 MB' });
const [timeoutSeconds, setTimeoutSeconds] = useState('30');
const [schedule, setSchedule] = useState<SelectProps.Option | null>({
value: 'midnight',
label: 'Every night at midnight UTC',
});
const [targetResource, setTargetResource] = useState('');
const fullResponse =
"Done. I've created nightly-cleanup with Python 3.12, 256 MB memory, and a 30-second timeout. Now that the function exists, I need to configure what triggers it. Since you chose EventBridge, I'll need a few more details about the event source mapping.";
const validateName = () => {
if (!functionName.trim()) {
return 'Function name is required.';
}
if (!/^[a-zA-Z0-9\-_]+$/.test(functionName)) {
return 'Function name can only contain letters, numbers, hyphens, and underscores.';
}
return '';
};
const streamResponse = () => {
setResponseReady(true);
let index = 0;
const interval = window.setInterval(() => {
index += 2;
if (index >= fullResponse.length) {
setStreamedText(fullResponse);
setStreamComplete(true);
window.clearInterval(interval);
} else {
setStreamedText(fullResponse.slice(0, index));
}
}, 20);
};
const handleSubmit = () => {
const error = validateName();
setFunctionNameError(error);
if (error) {
return;
}
setLoading(true);
window.setTimeout(() => {
setLoading(false);
setSubmitted(true);
}, 2000);
window.setTimeout(() => setExpanded(false), 2800);
window.setTimeout(streamResponse, 6000);
};
return (
<Container
header={<Header variant="h3">Generative AI assistant</Header>}
footer={
<CustomGenAIChatFooter
actionButtonIconName="send"
actionButtonAriaLabel="Send message"
message={prompt}
onSendMessage={setPrompt}
/>
}
>
<div role="region" aria-label="Chat" className="chat-region">
<SpaceBetween size="xs">
<ChatBubble type="outgoing" ariaLabel={`${userName} at 10:00am`} avatar={userAvatar}>
Set up a scheduled Lambda that runs a cleanup job nightly.
</ChatBubble>
<ChatBubble type="incoming" ariaLabel={`${genAiName} at 10:00am`} avatar={genAiAvatar}>
<Box variant="p">
I'll create a Lambda function triggered by an EventBridge schedule rule to run your cleanup job every
night. I just need a few configuration details.
</Box>
</ChatBubble>
<div className="chat-bubble-indentation">
<ItemCard variant="embedded">
<ExpandableSection
variant="inline"
expanded={expanded}
onChange={({ detail }) => setExpanded(detail.expanded)}
headerText={
<SpaceBetween direction="horizontal" size="xs" alignItems="center">
<Box fontSize="body-m" fontWeight="bold">
Lambda function setup
</Box>
<StatusIndicator type="success">Complete</StatusIndicator>
</SpaceBetween>
}
headingTagOverride="h4"
>
{!submitted ? (
<SpaceBetween size="s">
<FormField label="Function name" errorText={functionNameError}>
<Input
value={functionName}
onChange={({ detail }) => {
setFunctionName(detail.value);
setFunctionNameError('');
}}
placeholder="my-function-name"
disabled={loading}
invalid={!!functionNameError}
/>
</FormField>
<FormField label="Runtime">
<Select
placeholder="Choose runtime"
selectedOption={runtime}
onChange={({ detail }) => setRuntime(detail.selectedOption)}
options={[
{ value: 'nodejs20', label: 'Node.js 20.x' },
{ value: 'python312', label: 'Python 3.12' },
{ value: 'java21', label: 'Java 21' },
{ value: 'go', label: 'Go 1.x' },
]}
disabled={loading}
/>
</FormField>
<FormField label="Memory (MB)">
<Select
selectedOption={memory}
onChange={({ detail }) => setMemory(detail.selectedOption)}
options={[
{ value: '128', label: '128 MB' },
{ value: '256', label: '256 MB' },
{ value: '512', label: '512 MB' },
{ value: '1024', label: '1024 MB' },
]}
disabled={loading}
/>
</FormField>
<FormField label="Timeout (seconds)">
<Input
value={timeoutSeconds}
onChange={({ detail }) => setTimeoutSeconds(detail.value)}
type="number"
disabled={loading}
/>
</FormField>
<FormField label="Schedule">
<Select
selectedOption={schedule}
onChange={({ detail }) => setSchedule(detail.selectedOption)}
options={[
{ value: 'midnight', label: 'Every night at midnight UTC' },
{ value: '2am', label: 'Every night at 2:00 AM UTC' },
{ value: '4am', label: 'Every night at 4:00 AM UTC' },
{ value: 'custom', label: 'Custom cron expression' },
]}
disabled={loading}
/>
</FormField>
<Box padding={{ top: 's' }} float="right">
<Button variant="primary" onClick={handleSubmit} loading={loading}>
Create function
</Button>
</Box>
</SpaceBetween>
) : (
<KeyValuePairs
columns={2}
items={[
{ label: 'Function name', value: functionName },
{ label: 'Runtime', value: runtime?.label ?? '' },
{ label: 'Memory (MB)', value: memory?.label ?? '' },
{ label: 'Timeout (seconds)', value: timeoutSeconds },
{ label: 'Schedule', value: schedule?.label ?? '' },
]}
/>
)}
</ExpandableSection>
</ItemCard>
</div>
{submitted && !responseReady && (
<ChatBubble type="incoming" ariaLabel={`${genAiName} at 10:01am`} avatar={genAiAvatar} hideAvatar>
<Box color="text-status-inactive">Generating a response</Box>
</ChatBubble>
)}
{responseReady && (
<ChatBubble type="incoming" ariaLabel={`${genAiName} at 10:01am`} avatar={genAiAvatar} hideAvatar>
<Box variant="p">{streamedText}</Box>
</ChatBubble>
)}
{streamComplete && (
<div className="chat-bubble-indentation">
<ItemCard variant="embedded">
<ExpandableSection
variant="inline"
defaultExpanded
headerText={
<Box fontSize="body-m" fontWeight="bold">
Event source mapping
</Box>
}
headingTagOverride="h4"
>
<SpaceBetween size="s">
<FormField label="Source type">
<Select
placeholder="Choose source"
selectedOption={{ value: 'eventbridge', label: 'EventBridge' }}
options={[
{ value: 'eventbridge', label: 'EventBridge' },
{ value: 'sqs', label: 'SQS' },
{ value: 's3', label: 'S3' },
{ value: 'dynamodb', label: 'DynamoDB Streams' },
]}
/>
</FormField>
<FormField label="Target resources">
<Input
value={targetResource}
onChange={({ detail }) => setTargetResource(detail.value)}
placeholder="e.g. arn:aws:s3:::my-bucket"
/>
</FormField>
<Box padding={{ top: 's' }} float="right">
<Button variant="primary">Configure mapping</Button>
</Box>
</SpaceBetween>
</ExpandableSection>
</ItemCard>
</div>
)}
</SpaceBetween>
</div>
</Container>
);
}
다단계 프로세스의 일부로 에이전트가 입력이 필요한 경우 (Agent needs input as part of a multi-step process)
단계는 독립적이며 에이전트는 이전 결과를 기다리지 않고 처리할 수 있습니다. 폼은 대화 내에서 개별적인 접을 수 있는 카드로 나타납니다. 각 단계는 자체적으로 해결되며 비동기 생성처럼 후속 단계를 차단하지 않습니다.
Generative AI assistant
야간 정리 Lambda 함수 설정을 요청하는 사용자와, 설정을 단계별로 안내하는 에이전트의 예시입니다. Lambda function setup, EventBridge schedule, Target resources의 세 단계가 개별 접을 수 있는 카드로 표시되며, 완료된 단계는 요약 보기로 보여집니다.
import React, { useState } from 'react';
import Box from '@cloudscape-design/components/box';
import Button from '@cloudscape-design/components/button';
import Container from '@cloudscape-design/components/container';
import ExpandableSection from '@cloudscape-design/components/expandable-section';
import FormField from '@cloudscape-design/components/form-field';
import Header from '@cloudscape-design/components/header';
import Input from '@cloudscape-design/components/input';
import ItemCard from '@cloudscape-design/components/item-card';
import KeyValuePairs from '@cloudscape-design/components/key-value-pairs';
import Link from '@cloudscape-design/components/link';
import Select, { SelectProps } from '@cloudscape-design/components/select';
import SpaceBetween from '@cloudscape-design/components/space-between';
import StatusIndicator from '@cloudscape-design/components/status-indicator';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import { genAiAvatar, genAiName, userAvatar, userName } from '../genai-common/avatars';
import CustomGenAIChatFooter from '../gen-ai-response-regeneration/custom-gen-ai-chat-footer';
import '../genai-common/styles.scss';
import './styles.scss';
export default function GenAiInlineChatActionsMultiStep() {
const [prompt, setPrompt] = useState('');
const [executionId, setExecutionId] = useState('');
const [region, setRegion] = useState<SelectProps.Option | null>(null);
return (
<Container
header={<Header variant="h3">Generative AI assistant</Header>}
footer={
<CustomGenAIChatFooter
actionButtonIconName="send"
actionButtonAriaLabel="Send message"
message={prompt}
onSendMessage={setPrompt}
/>
}
>
<div role="region" aria-label="Chat" className="chat-region">
<SpaceBetween size="xs">
<ChatBubble type="outgoing" ariaLabel={`${userName} at 10:00am`} avatar={userAvatar}>
Help me set up a nightly cleanup Lambda function.
</ChatBubble>
<ChatBubble type="incoming" ariaLabel={`${genAiName} at 10:00am`} avatar={genAiAvatar}>
<Box variant="p">Happy to help. I'll walk you through the setup step by step.</Box>
</ChatBubble>
<div className="chat-bubble-indentation">
<ol className="step-list">
<li className="step-list-item">
<ItemCard
variant="embedded"
header={
<ExpandableSection
variant="inline"
headerText={
<SpaceBetween direction="horizontal" size="xs" alignItems="center">
<Box fontSize="body-m" fontWeight="bold">
Lambda function setup (1 of 3)
</Box>
<StatusIndicator type="success">Complete</StatusIndicator>
</SpaceBetween>
}
>
<KeyValuePairs
columns={2}
items={[
{ label: 'Function name', value: 'nightly-cleanup' },
{ label: 'Runtime', value: 'Python 3.12' },
{ label: 'Memory', value: '256 MB' },
{ label: 'Timeout', value: '30 seconds' },
]}
/>
</ExpandableSection>
}
/>
</li>
<li className="step-list-item">
<ItemCard
variant="embedded"
header={
<ExpandableSection
variant="inline"
headerText={
<SpaceBetween direction="horizontal" size="xs" alignItems="center">
<Box fontSize="body-m" fontWeight="bold">
EventBridge schedule (2 of 3)
</Box>
<StatusIndicator type="success">Complete</StatusIndicator>
</SpaceBetween>
}
>
<KeyValuePairs
columns={2}
items={[
{ label: 'Schedule', value: 'Every night at midnight UTC' },
{ label: 'Target', value: 'nightly-cleanup' },
]}
/>
</ExpandableSection>
}
/>
</li>
<li className="step-list-item">
<ItemCard
variant="embedded"
header={
<ExpandableSection
variant="inline"
defaultExpanded
headerText={
<Box fontSize="body-m" fontWeight="bold">
Target resources (3 of 3)
</Box>
}
>
<SpaceBetween size="s">
<Box variant="p">Which resources should the cleanup function target?</Box>
<FormField
label="Resource ARN"
description={
View available{' '}
<Link external href="#">
S3 buckets
</Link>
}
>
<Input
value={executionId}
onChange={({ detail }) => setExecutionId(detail.value)}
placeholder="e.g. arn:aws:s3:::my-bucket"
/>
</FormField>
<FormField label="AWS Region">
<Select
placeholder="Choose a region"
selectedOption={region}
onChange={({ detail }) => setRegion(detail.selectedOption)}
options={[
{ value: 'us-east-1', label: 'US East (N. Virginia)' },
{ value: 'us-west-2', label: 'US West (Oregon)' },
{ value: 'eu-west-1', label: 'Europe (Ireland)' },
{ value: 'ap-southeast-1', label: 'Asia Pacific (Singapore)' },
]}
/>
</FormField>
<Box padding={{ top: 's' }} float="right">
<Button variant="primary">Configure</Button>
</Box>
</SpaceBetween>
</ExpandableSection>
}
/>
</li>
</ol>
</div>
</SpaceBetween>
</div>
</Container>
);
}
값 인라인 편집 (Editing values inline)
응답 내 인라인 편집은 사용자가 에이전트가 생성한 값을 검토하고 선택적으로 수정할 수 있게 합니다.
Generative AI assistant
SaaS 제품 랜딩 페이지 구축을 요청하는 사용자와, 프로젝트 환경을 만들고 프로젝트 이름(FreelancerHub)을 인라인 편집할 수 있게 보여주는 에이전트의 예시입니다.
import React, { useState } from 'react';
import Box from '@cloudscape-design/components/box';
import Button from '@cloudscape-design/components/button';
import Container from '@cloudscape-design/components/container';
import Header from '@cloudscape-design/components/header';
import Input from '@cloudscape-design/components/input';
import SpaceBetween from '@cloudscape-design/components/space-between';
import StatusIndicator from '@cloudscape-design/components/status-indicator';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import { genAiAvatar, genAiName, userAvatar, userName } from '../genai-common/avatars';
import CustomGenAIChatFooter from '../gen-ai-response-regeneration/custom-gen-ai-chat-footer';
import '../genai-common/styles.scss';
import './styles.scss';
export default function GenAiInlineChatActionsInlineEdit() {
const [prompt, setPrompt] = useState('');
const [projectName, setProjectName] = useState('FreelancerHub');
const [editValue, setEditValue] = useState('FreelancerHub');
const [editing, setEditing] = useState(false);
const [error, setError] = useState('');
const handleEdit = () => {
setEditValue(projectName);
setEditing(true);
setError('');
};
const handleConfirm = () => {
if (!editValue.trim()) {
setError('Project name is required.');
return;
}
setProjectName(editValue);
setEditing(false);
setError('');
};
const handleCancel = () => {
setEditing(false);
setError('');
};
return (
<Container
header={<Header variant="h3">Generative AI assistant</Header>}
footer={
<CustomGenAIChatFooter
actionButtonIconName="send"
actionButtonAriaLabel="Send message"
message={prompt}
onSendMessage={setPrompt}
/>
}
>
<div role="region" aria-label="Chat" className="chat-region">
<SpaceBetween size="xs">
<ChatBubble type="outgoing" ariaLabel={`${userName} at 10:00am`} avatar={userAvatar}>
I want to build a landing page for my SaaS product. It needs a waitlist signup form and Stripe payment
integration for early access.
</ChatBubble>
<ChatBubble type="incoming" ariaLabel={`${genAiName} at 10:00am`} avatar={genAiAvatar}>
<SpaceBetween size="s">
<Box variant="p">
I've created an environment for you so we have a place to track everything, code, infrastructure,
and deployments.
</Box>
{!editing ? (
<div className="inline-edit-row">
<StatusIndicator type="success">Project {projectName}</StatusIndicator>
<Button iconName="edit" variant="inline-icon" ariaLabel="Edit project name" onClick={handleEdit} />
</div>
) : (
<SpaceBetween size="xxs">
<div className="inline-edit-row">
<StatusIndicator type="success">Project</StatusIndicator>
<div className="inline-edit-content">
<Input
value={editValue}
onChange={({ detail }) => {
setEditValue(detail.value);
setError('');
}}
ariaLabel="Project name"
invalid={!!error}
/>
</div>
<Button iconName="check" variant="inline-icon" ariaLabel="Confirm" onClick={handleConfirm} />
<Button iconName="close" variant="inline-icon" ariaLabel="Cancel" onClick={handleCancel} />
</div>
{error && (
<Box color="text-status-error" fontSize="body-s">
{error}
</Box>
)}
</SpaceBetween>
)}
<Box variant="p">Now a few quick questions so I can set up the right backend for you:</Box>
</SpaceBetween>
</ChatBubble>
</SpaceBetween>
</div>
</Container>
);
}
일반 가이드라인 (General guidelines)
권장 사항 (Do)
- 인지 부하를 낮게 유지하기 위해 폼당 입력 필드를 5개 이하로 제한하세요.
- 응답의 값이 인라인으로 편집 가능할 때는 그 옆에 편집 아이콘 버튼을 표시해 사용자가 수정 가능한 값임을 식별할 수 있게 하세요.
- 단일 폼과의 상호작용에는 제출 후 입력을 비활성화하고 성공 표시기를 보여주세요.
- 가능하면 맥락에서 추론한 값으로 필드를 미리 채워 사용자의 노력을 줄이세요.
권장하지 않는 사항 (Don't)
- 사용자 의도를 명확히 하기 위해 임베디드 흐름을 사용하지 마세요. 인라인 폼 입력은 동작을 실행하기 위한 값을 수집합니다. 사용자 의도를 명확히 해야 한다면 follow-up questions을 대신 사용하세요.
- 선택 사항 필드를 포함하지 마세요. 진행하는 데 필요한 것만 요청하세요.
작성 가이드라인 (Writing guidelines)
일반 작성 가이드라인 (General writing guidelines)
-
문장형 대소문자(sentence case)를 사용하되, 고유명사와 브랜드 이름은 맥락에 맞게 대문자화를 유지하세요.
-
현재형 동사와 능동태를 사용하세요.
-
작성에서 please , thank you , 줄임표( ... ), 앰퍼샌드( & ), e.g. , i.e. , etc. 를 사용하지 마세요.
-
방향을 지시하는 표현은 피하세요.
- 예: above 대신 previous 를, below 대신 following 을 사용하세요.
-
기기 독립적인 표현을 사용하세요.
- 예: click 대신 choose 나 select 를 사용하세요.
컴포넌트별 가이드라인 (Component-specific guidelines)
카드 제목 (Card title)
- 리소스나 동작에 특화되게 하세요. Information required 나 Configuration needed 같은 일반적인 라벨은 피하세요.
접근성 가이드라인 (Accessibility guidelines)
일반 접근성 가이드라인 (General accessibility guidelines)
- 각 컴포넌트에 대한 대체 텍스트와 접근 가능한 리치 인터넷 애플리케이션(ARIA) 영역에 대한 지침을 따르세요.
- 애플리케이션의 언어 맥락에 맞춘 ARIA 라벨을 정의하세요.
- 역할(role)과 랜드마크(landmark)에 불필요한 마크업을 추가하지 마세요. 각 컴포넌트에 대한 지침을 따르세요.
- 논리적이고 예측 가능한 순서로 모든 사용 가능한 콘텐츠에 키보드 기능을 제공하세요. 정보의 흐름이 이해가 되어야 합니다.