Skip to content

Commit 901844a

Browse files
committed
added embeddings experiment
1 parent a5149b4 commit 901844a

3 files changed

Lines changed: 37 additions & 1 deletion

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { SolrNamespaces } from '../../../solr'
2+
import { ImpressoApplication } from '../../../types'
3+
import { ExperimentBase } from './base'
4+
5+
interface RequestBody {
6+
solrPayload: Record<string, any>
7+
}
8+
9+
interface ResponseBody {
10+
solrResponse: Record<string, any>
11+
}
12+
13+
export class EntityProfilesExperiment implements ExperimentBase<RequestBody, ResponseBody> {
14+
id = 'entity-profiles'
15+
name = 'Experiment with entity profiles and their embeddings'
16+
description = `
17+
Generates embeddings for subdocuments using a specified model.
18+
The body must contain a 'solrPayload' field with a
19+
JSON API Solr query (see https://solr.apache.org/guide/solr/latest/query-guide/json-request-api.html).
20+
`
21+
22+
async execute(body: RequestBody, app: ImpressoApplication): Promise<ResponseBody> {
23+
if (body.solrPayload == null) {
24+
throw new Error("Request body must contain a 'solrPayload' field with a Solr JSON API query.")
25+
}
26+
const solrResponse = await app.service('simpleSolrClient').select(SolrNamespaces.EntityProfiles, {
27+
body: body.solrPayload as any,
28+
})
29+
return {
30+
solrResponse,
31+
}
32+
}
33+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { EntityProfilesExperiment } from './entityProfiles'
12
import { SubdocEmbeddingsExperiment } from './subdocEmbeddings'
23

3-
export const experiments = [new SubdocEmbeddingsExperiment()]
4+
export const experiments = [new SubdocEmbeddingsExperiment(), new EntityProfilesExperiment()]

src/solr.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type SolrNamespace =
1616
| 'entities_mentions'
1717
| 'collection_items'
1818
| 'subdoc_embeddings_experiment'
19+
| 'entity_profiles'
1920

2021
export const SolrNamespaces = Object.freeze({
2122
Search: 'search',
@@ -32,6 +33,7 @@ export const SolrNamespaces = Object.freeze({
3233
EntitiesMentions: 'entities_mentions',
3334
CollectionItems: 'collection_items',
3435
SubdocEmbeddingsExperiment: 'subdoc_embeddings_experiment',
36+
EntityProfiles: 'entity_profiles',
3537
}) satisfies Record<string, SolrNamespace>
3638

3739
/**

0 commit comments

Comments
 (0)