@socialgouv/cdtn-elasticsearch 1.11.1 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socialgouv/cdtn-elasticsearch",
|
|
3
3
|
"description": "SocialGouv - Code du travail numerique - Infrastructure - Elasticsearch",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.12.0",
|
|
5
5
|
"babel": {
|
|
6
6
|
"plugins": [
|
|
7
7
|
"@babel/plugin-transform-modules-commonjs"
|
|
8
8
|
]
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@socialgouv/cdtn-logger": "^1.
|
|
11
|
+
"@socialgouv/cdtn-logger": "^1.12.0",
|
|
12
12
|
"got": "^11.8.2"
|
|
13
13
|
},
|
|
14
14
|
"license": "Apache-2.0",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
},
|
|
47
47
|
"sideEffects": false,
|
|
48
48
|
"typings": "src/index.d.ts",
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "8dd7a3dcc1f7bd2dabe982eadb00e869fe840685"
|
|
50
50
|
}
|
package/src/vectorizer/index.js
CHANGED
|
@@ -36,13 +36,15 @@ async function callTFServe(json) {
|
|
|
36
36
|
cache,
|
|
37
37
|
json,
|
|
38
38
|
responseType: "json",
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
retry: {
|
|
40
|
+
limit: 15,
|
|
41
|
+
methods: ["POST"],
|
|
42
|
+
},
|
|
41
43
|
});
|
|
42
44
|
return response.body["outputs"];
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
async function vectorizeDocument(
|
|
47
|
+
async function vectorizeDocument(title, content) {
|
|
46
48
|
if (title == undefined || title == "") {
|
|
47
49
|
throw new Error("Cannot vectorize document with empty title.");
|
|
48
50
|
}
|
|
@@ -54,9 +56,7 @@ async function vectorizeDocument(id, title, content) {
|
|
|
54
56
|
inputs: { context, input },
|
|
55
57
|
signature_name: "response_encoder",
|
|
56
58
|
};
|
|
57
|
-
console.time(`CALL TF SERVER ${id}`);
|
|
58
59
|
const vectors = await callTFServe(body);
|
|
59
|
-
console.timeEnd(`CALL TF SERVER ${id}`);
|
|
60
60
|
|
|
61
61
|
return vectors[0];
|
|
62
62
|
}
|
|
@@ -5,12 +5,12 @@ const timeout = 10000;
|
|
|
5
5
|
test(
|
|
6
6
|
"Should vectorize document",
|
|
7
7
|
async () => {
|
|
8
|
-
const vector1 = await vectorizeDocument("
|
|
8
|
+
const vector1 = await vectorizeDocument("titre", "contenu");
|
|
9
9
|
expect(vector1).toBeDefined();
|
|
10
10
|
expect(vector1).toMatchSnapshot();
|
|
11
11
|
|
|
12
12
|
// preprocessing should make those embeddings equal
|
|
13
|
-
const vector2 = await vectorizeDocument("
|
|
13
|
+
const vector2 = await vectorizeDocument("le titre", "et le contènu");
|
|
14
14
|
expect(vector2).toEqual(vector1);
|
|
15
15
|
},
|
|
16
16
|
timeout
|