Skip to content

Commit 2229351

Browse files
committed
feat(ui/dictionary): add feature index input and update dictionary select styling
1 parent d6c56b2 commit 2229351

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

ui-ssr/src/components/dictionary/dictionary-select.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const DictionarySelect = memo(
146146
<Select open={open} onOpenChange={setOpen}>
147147
<SelectTrigger
148148
className={cn(
149-
'flex h-12 w-[400px] items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 select-none',
149+
'flex h-12 w-[400px] items-center justify-between rounded-md border border-input bg-white px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 select-none',
150150
)}
151151
>
152152
<div className="flex flex-col items-start text-left gap-0.5">

ui-ssr/src/routes/dictionaries.$dictionaryName.index.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { DictionaryCard } from '@/components/dictionary/dictionary-card'
44
import { Button } from '@/components/ui/button'
55
import { fetchAdminSaes } from '@/api/admin'
66
import { DictionarySelect } from '@/components/dictionary/dictionary-select'
7+
import { LabeledInput } from '@/components/ui/labeled-input'
78

89
export const Route = createFileRoute('/dictionaries/$dictionaryName/')({
910
component: DictionaryIndexPage,
@@ -23,6 +24,7 @@ function DictionaryIndexPage() {
2324
const { saes, dictionaryName } = Route.useLoaderData()
2425

2526
const [selectedDictionary, setSelectedDictionary] = useState(dictionaryName)
27+
const [selectedFeatureIndex, setSelectedFeatureIndex] = useState('0')
2628

2729
return (
2830
<div className="h-full overflow-y-auto pt-4 pb-20 px-20 flex flex-col items-center gap-6">
@@ -46,6 +48,31 @@ function DictionaryIndexPage() {
4648
Go
4749
</Button>
4850
)}
51+
52+
<div className="w-[100px] ml-4">
53+
<LabeledInput
54+
label="Index"
55+
id="feature-input"
56+
value={selectedFeatureIndex}
57+
onChange={(e) => setSelectedFeatureIndex(e.target.value)}
58+
/>
59+
</div>
60+
61+
{!isNaN(Number(selectedFeatureIndex)) ? (
62+
<Link
63+
to="/dictionaries/$dictionaryName/features/$featureIndex"
64+
params={{
65+
dictionaryName: selectedDictionary,
66+
featureIndex: selectedFeatureIndex,
67+
}}
68+
>
69+
<Button className="h-12 px-4">View Feature</Button>
70+
</Link>
71+
) : (
72+
<Button className="h-12 px-4" disabled>
73+
View Feature
74+
</Button>
75+
)}
4976
</div>
5077
</div>
5178
<DictionaryCard dictionaryName={dictionaryName} />

ui-ssr/src/utils/circuit.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export function formatFeatureId(node: Node, verbose: boolean = true): string {
6161
return `A${Math.floor(layerIdx / 2)}Error@${node.ctxIdx}`
6262
} else if (node.featureType === 'logit') {
6363
return `Logit@${node.ctxIdx}: ${node.token} (${(node.tokenProb * 100).toFixed(1)}%)`
64+
} else if (node.featureType === 'bias') {
65+
return `Bias@${node.ctxIdx}`
6466
}
6567
return 'Unknown feature type'
6668
}

0 commit comments

Comments
 (0)