Skip to content

Commit cda4ae8

Browse files
committed
chore: add AI recommendations to topic field and simplify concept URI IDs
1 parent 4b43801 commit cda4ae8

2 files changed

Lines changed: 144 additions & 116 deletions

File tree

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {defineType, defineField} from 'sanity'
2-
import {RiGitCommitLine, RiBubbleChartFill} from 'react-icons/ri'
3-
import {schemeFilter, ArrayHierarchyInput} from 'sanity-plugin-taxonomy-manager'
1+
import { defineType, defineField, type ArrayFieldProps } from 'sanity';
2+
import { RiGitCommitLine, RiBubbleChartFill } from 'react-icons/ri';
3+
import { schemeFilter, ArrayHierarchyInput } from 'sanity-plugin-taxonomy-manager';
44
// import MetaDescription from '../../components/MetaDescription'
55

66
/**
@@ -43,21 +43,30 @@ export default defineType({
4343
of: [
4444
{
4545
type: 'reference',
46-
to: [{type: 'skosConcept'}],
46+
to: [{ type: 'skosConcept' }],
4747
options: {
48-
filter: schemeFilter({schemeId: 'Mfji21', browseOnly: true}),
49-
aiAssist:{
50-
embeddingsIndex: 'io-taxonomy',
51-
},
52-
embeddingsIndex: {
53-
indexName: 'io-taxonomy',
54-
maxResults: 10,
55-
searchMode: 'embeddings'
56-
}
48+
filter: schemeFilter({ schemeId: '693450', browseOnly: true}),
49+
// aiAssist:{
50+
// embeddingsIndex: 'io-taxonomy',
51+
// },
52+
// embeddingsIndex: {
53+
// indexName: 'io-taxonomy',
54+
// maxResults: 10,
55+
// searchMode: 'embeddings'
56+
// }
5757
},
5858
},
5959
],
60-
components: { field: ArrayHierarchyInput },
60+
components: {
61+
// field: ArrayHierarchyInput
62+
field: (props: ArrayFieldProps) => <ArrayHierarchyInput
63+
{...props}
64+
embeddingsIndex={{
65+
"indexName": "io-taxonomy",
66+
"fieldReferences": ["title", "metaDescription"],
67+
"maxResults": 4,
68+
}} />
69+
},
6170
}),
6271
defineField({
6372
name: 'uri',
@@ -93,7 +102,7 @@ export default defineType({
93102
type: 'array',
94103
title: 'Discipline(s)',
95104
description: 'List the disciplines in which this method is most commonly used.',
96-
of: [{type: 'referencedDiscipline'}],
105+
of: [{ type: 'referencedDiscipline' }],
97106
}),
98107
defineField({
99108
name: 'overview',
@@ -104,7 +113,7 @@ export default defineType({
104113
name: 'overviewSources',
105114
type: 'array',
106115
title: 'Overview Sources',
107-
of: [{type: 'source'}],
116+
of: [{ type: 'source' }],
108117
}),
109118
defineField({
110119
name: 'steps',
@@ -115,7 +124,7 @@ export default defineType({
115124
name: 'stepSources',
116125
type: 'array',
117126
title: 'Step Sources',
118-
of: [{type: 'source'}],
127+
of: [{ type: 'source' }],
119128
}),
120129
defineField({
121130
name: 'input',
@@ -126,10 +135,10 @@ export default defineType({
126135
of: [
127136
{
128137
type: 'reference',
129-
to: [{type: 'skosConcept'}],
138+
to: [{ type: 'skosConcept' }],
130139
options: {
131-
filter: schemeFilter({schemeId: 'Mfji21'}),
132-
aiAssist:{
140+
filter: schemeFilter({ schemeId: '693450' }),
141+
aiAssist: {
133142
embeddingsIndex: 'io-taxonomy',
134143
},
135144
embeddingsIndex: {
@@ -150,10 +159,10 @@ export default defineType({
150159
of: [
151160
{
152161
type: 'reference',
153-
to: [{type: 'skosConcept'}],
162+
to: [{ type: 'skosConcept' }],
154163
options: {
155-
filter: schemeFilter({schemeId: 'Mfji21'}),
156-
aiAssist:{
164+
filter: schemeFilter({ schemeId: '693450' }),
165+
aiAssist: {
157166
embeddingsIndex: 'io-taxonomy',
158167
},
159168
embeddingsIndex: {
@@ -177,14 +186,14 @@ export default defineType({
177186
discipline3: 'disciplinesReference.3.title',
178187
},
179188
prepare(selection) {
180-
const {title, discipline0, discipline1, discipline2, discipline3, thumb} = selection
181-
const disciplines = [discipline0, discipline1, discipline2, discipline3].filter(Boolean)
182-
const subtitle = disciplines.length > 0 ? `${disciplines.join(', ')}` : ''
189+
const { title, discipline0, discipline1, discipline2, discipline3, thumb } = selection;
190+
const disciplines = [discipline0, discipline1, discipline2, discipline3].filter(Boolean);
191+
const subtitle = disciplines.length > 0 ? `${disciplines.join(', ')}` : '';
183192
return {
184193
title: title,
185194
subtitle: subtitle,
186195
media: thumb ? thumb : RiGitCommitLine,
187-
}
196+
};
188197
},
189198
},
190-
})
199+
});
Lines changed: 107 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineType, defineField } from 'sanity';
2+
import type { ArrayFieldProps, ObjectFieldProps, Reference } from 'sanity';
23
import { NodeTree } from '../../static/NodeTree';
34
import { ArrayHierarchyInput, ReferenceHierarchyInput } from 'sanity-plugin-taxonomy-manager';
45
import { branchFilter, schemeFilter } from 'sanity-plugin-taxonomy-manager';
@@ -40,95 +41,113 @@ export default defineType({
4041
filter: schemeFilter({ schemeId: schemeIdWithTop, expanded: false }),
4142
disableNew: true,
4243
// aiAssist:{
43-
// embeddingsIndex: 'io-taxonomy',
44-
// },
45-
// embeddingsIndex: {
46-
// indexName: 'io-taxonomy',
47-
// maxResults: 10,
48-
// searchMode: 'embeddings'
49-
// }
44+
// embeddingsIndex: 'io-taxonomy',
45+
// },
46+
// embeddingsIndex: {
47+
// indexName: 'io-taxonomy',
48+
// maxResults: 10,
49+
// searchMode: 'embeddings'
50+
// }
51+
},
52+
components: {
53+
// field: ReferenceHierarchyInput
54+
field: (props: ObjectFieldProps<Reference>) => <ReferenceHierarchyInput
55+
{...props}
56+
embeddingsIndex={{
57+
"indexName": "io-taxonomy",
58+
"fieldReferences": ["title", "metaDescription"],
59+
"maxResults": 4,
60+
}} />
61+
},
62+
}),
63+
defineField({
64+
name: 'testField',
65+
type: 'text',
66+
title: 'Test Field',
67+
rows: 1,
68+
}),
69+
defineField({
70+
name: 'singleTermFromSchemeNoTop',
71+
title: 'Single Term Reference from Scheme, No Top Concept',
72+
type: 'reference',
73+
to: [{ type: 'skosConcept' }],
74+
options: {
75+
filter: schemeFilter({ schemeId: schemeIdNoTop }),
76+
disableNew: true,
77+
},
78+
components: { field: ReferenceHierarchyInput },
79+
}),
80+
defineField({
81+
name: 'singleTermFromBranchNoTop',
82+
title: 'Single Term Reference from Branch, No Top Concept',
83+
type: 'reference',
84+
to: [{ type: 'skosConcept' }],
85+
options: {
86+
filter: branchFilter({ schemeId: schemeIdNoTop, branchId: branchIdNoTop }),
87+
disableNew: true,
88+
},
89+
components: { field: ReferenceHierarchyInput },
90+
}),
91+
defineField({
92+
name: 'singleTermFromBranch',
93+
title: 'Single Term Reference from Branch with Top Concept',
94+
type: 'reference',
95+
to: [{ type: 'skosConcept' }],
96+
options: {
97+
filter: branchFilter({ schemeId: schemeIdWithTop, branchId: branchIdWithTop }),
98+
disableNew: true,
99+
},
100+
components: { field: ReferenceHierarchyInput },
101+
}),
102+
defineField({
103+
name: 'arrayFromScheme',
104+
title: 'Array of Terms from Scheme',
105+
type: 'array',
106+
of: [
107+
{
108+
type: 'reference',
109+
to: { type: 'skosConcept' },
110+
options: {
111+
filter: schemeFilter({ schemeId: schemeIdWithTop, expanded: true, browseOnly: true }),
112+
disableNew: true,
113+
},
50114
},
51-
components: {
52-
field: ReferenceHierarchyInput
53-
// (props) => <ReferenceHierarchyInput
54-
// {...props}
55-
// embeddingsIndex={{
56-
// "indexName": "io-taxonomy",
57-
// "fieldReferences": ["title", "metaDescription"],
58-
// "maxResults": 4,
59-
// }} />
115+
],
116+
components: {
117+
// field: ArrayHierarchyInput
118+
field: (props: ArrayFieldProps) => <ArrayHierarchyInput
119+
{...props}
120+
embeddingsIndex={{
121+
"indexName": "io-taxonomy",
122+
"fieldReferences": ["title", "metaDescription"],
123+
"maxResults": 4,
124+
}} />
125+
},
126+
}),
127+
defineField({
128+
name: 'arrayFromBranch',
129+
title: 'Array of Terms from Branch',
130+
type: 'array',
131+
of: [
132+
{
133+
type: 'reference',
134+
to: { type: 'skosConcept' },
135+
options: {
136+
filter: branchFilter({ schemeId: schemeIdWithTop, branchId: branchIdWithTop }),
137+
disableNew: true,
138+
},
60139
},
61-
}),
62-
defineField({
63-
name: 'testField',
64-
type: 'text',
65-
title: 'Test Field',
66-
rows: 1,
67-
}),
68-
// defineField({
69-
// name: 'singleTermFromSchemeNoTop',
70-
// title: 'Single Term Reference from Scheme, No Top Concept',
71-
// type: 'reference',
72-
// to: [{type: 'skosConcept'}],
73-
// options: {
74-
// filter: schemeFilter({schemeId: schemeIdNoTop}),
75-
// disableNew: true,
76-
// },
77-
// components: {field: ReferenceHierarchyInput},
78-
// }),
79-
// defineField({
80-
// name: 'singleTermFromBranchNoTop',
81-
// title: 'Single Term Reference from Branch, No Top Concept',
82-
// type: 'reference',
83-
// to: [{type: 'skosConcept'}],
84-
// options: {
85-
// filter: branchFilter({schemeId: schemeIdNoTop, branchId: branchIdNoTop}),
86-
// disableNew: true,
87-
// },
88-
// components: {field: ReferenceHierarchyInput},
89-
// }),
90-
// defineField({
91-
// name: 'singleTermFromBranch',
92-
// title: 'Single Term Reference from Branch with Top Concept',
93-
// type: 'reference',
94-
// to: [{type: 'skosConcept'}],
95-
// options: {
96-
// filter: branchFilter({schemeId: schemeIdWithTop, branchId: branchIdWithTop}),
97-
// disableNew: true,
98-
// },
99-
// components: {field: ReferenceHierarchyInput},
100-
// }),
101-
// defineField({
102-
// name: 'arrayFromScheme',
103-
// title: 'Array of Terms from Scheme',
104-
// type: 'array',
105-
// of: [
106-
// {
107-
// type: 'reference',
108-
// to: {type: 'skosConcept'},
109-
// options: {
110-
// filter: schemeFilter({schemeId: schemeIdWithTop}),
111-
// disableNew: true,
112-
// },
113-
// },
114-
// ],
115-
// components: {field: ArrayHierarchyInput},
116-
// }),
117-
// defineField({
118-
// name: 'arrayFromBranch',
119-
// title: 'Array of Terms from Branch',
120-
// type: 'array',
121-
// of: [
122-
// {
123-
// type: 'reference',
124-
// to: {type: 'skosConcept'},
125-
// options: {
126-
// filter: branchFilter({schemeId: schemeIdWithTop, branchId: branchIdWithTop}),
127-
// disableNew: true,
128-
// },
129-
// },
130-
// ],
131-
// components: {field: ArrayHierarchyInput},
132-
// }),
140+
],
141+
components: {
142+
// field: ArrayHierarchyInput
143+
field: (props: ArrayFieldProps) => <ArrayHierarchyInput
144+
{...props}
145+
embeddingsIndex={{
146+
"indexName": "io-taxonomy",
147+
"fieldReferences": ["title", "metaDescription"],
148+
"maxResults": 4,
149+
}} />
150+
},
151+
}),
133152
],
134153
});

0 commit comments

Comments
 (0)