Skip to content

Commit 9887e5a

Browse files
authored
feat(toolkit): hide instruction textarea for new assistants (#736)
add instruction button
1 parent b43a684 commit 9887e5a

File tree

3 files changed

+47
-22
lines changed

3 files changed

+47
-22
lines changed
Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1+
'use client';
2+
13
import Link from 'next/link';
4+
import { useState } from 'react';
25

36
import { AgentSettingsFields } from '@/components/AgentSettingsForm';
4-
import { Input, Text, Textarea } from '@/components/UI';
7+
import { Button, Input, Text, Textarea } from '@/components/UI';
58

69
type Props = {
710
fields: AgentSettingsFields;
11+
isNewAssistant: boolean;
812
nameError?: string;
913
setFields: (fields: AgentSettingsFields) => void;
1014
};
1115

12-
export const DefineAssistantStep: React.FC<Props> = ({ fields, nameError, setFields }) => {
16+
export const DefineAssistantStep: React.FC<Props> = ({
17+
fields,
18+
isNewAssistant,
19+
nameError,
20+
setFields,
21+
}) => {
22+
const [showInstructions, setShowInstructions] = useState(!isNewAssistant);
23+
1324
return (
1425
<div className="flex flex-col space-y-4">
1526
<Input
@@ -26,24 +37,33 @@ export const DefineAssistantStep: React.FC<Props> = ({ fields, nameError, setFie
2637
value={fields.description ?? ''}
2738
onChange={(e) => setFields({ ...fields, description: e.target.value })}
2839
/>
29-
<Textarea
30-
label="Instructions"
31-
labelTooltip={
32-
<Text>
33-
Learn about writing a custom assistant instructions with{' '}
34-
<Link
35-
href="https://docs.cohere.com/docs/preambles#advanced-techniques-for-writing-a-preamble"
36-
className="underline"
37-
>
38-
Cohere&apos;s guide
39-
</Link>
40-
</Text>
41-
}
42-
placeholder="e.g., You are friendly and helpful. You answer questions based on files in Google Drive."
43-
defaultRows={8}
44-
value={fields.preamble || ''}
45-
onChange={(e) => setFields({ ...fields, preamble: e.target.value })}
46-
/>
40+
{showInstructions ? (
41+
<Textarea
42+
label="Instructions"
43+
labelTooltip={
44+
<Text>
45+
Learn about writing a custom assistant instructions with{' '}
46+
<Link
47+
href="https://docs.cohere.com/docs/preambles#advanced-techniques-for-writing-a-preamble"
48+
className="underline"
49+
>
50+
Cohere&apos;s guide
51+
</Link>
52+
</Text>
53+
}
54+
placeholder="e.g., You are friendly and helpful. You answer questions based on files in Google Drive."
55+
defaultRows={8}
56+
value={fields.preamble || ''}
57+
onChange={(e) => setFields({ ...fields, preamble: e.target.value })}
58+
/>
59+
) : (
60+
<Button
61+
label="Custom assistant instructions"
62+
icon="add"
63+
kind="secondary"
64+
onClick={() => setShowInstructions(true)}
65+
/>
66+
)}
4767
</div>
4868
);
4969
};

src/interfaces/assistants_web/src/components/AgentSettingsForm/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,12 @@ export const AgentSettingsForm: React.FC<Props> = (props) => {
186186
isExpanded={currentStep === 'define'}
187187
setIsExpanded={(expanded) => setCurrentStep(expanded ? 'define' : undefined)}
188188
>
189-
<DefineAssistantStep fields={fields} setFields={setFields} nameError={nameError} />
189+
<DefineAssistantStep
190+
fields={fields}
191+
setFields={setFields}
192+
nameError={nameError}
193+
isNewAssistant={source === 'create'}
194+
/>
190195
<StepButtons
191196
handleNext={() => setCurrentStep('dataSources')}
192197
hide={source !== 'create'}

src/interfaces/assistants_web/src/components/UI/Tooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export const Tooltip: React.FC<TooltipProps> = ({
129129
{
130130
'max-w-[400px] rounded-sm border-none bg-mushroom-150 px-1 py-0.5 dark:bg-volcanic-300':
131131
size === 'sm',
132-
'max-w-[300px] rounded border border-marble-950 bg-marble-980 px-4 py-2.5':
132+
'max-w-[300px] rounded border border-marble-950 bg-marble-980 px-4 py-2.5 dark:border-volcanic-400 dark:bg-volcanic-300':
133133
size === 'md',
134134
},
135135
className

0 commit comments

Comments
 (0)