From 821cf0e43434819dfb3926e7d561d4bb99fcd9bf Mon Sep 17 00:00:00 2001 From: Andrew Miracle Date: Tue, 9 Jan 2024 16:27:22 +0100 Subject: [PATCH] eslint fix --- node/src/embedding/openai.ts | 16 +++++++--------- node/src/test/embedding/openai.ts | 17 ++++++++--------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/node/src/embedding/openai.ts b/node/src/embedding/openai.ts index 957b6f59..a84d4ba6 100644 --- a/node/src/embedding/openai.ts +++ b/node/src/embedding/openai.ts @@ -20,13 +20,13 @@ export class OpenAIEmbeddingFunction implements EmbeddingFunction { private readonly _modelName: string constructor (sourceColumn: string, openAIKey: string, modelName: string = 'text-embedding-ada-002') { - /** - * @type {import("openai").default} + /** + * @type {import("openai").default} */ - let openai + let Openai try { // eslint-disable-next-line @typescript-eslint/no-var-requires - openai = require('openai') + Openai = require('openai') } catch { throw new Error('please install openai@^4.24.1 using npm install openai') } @@ -34,12 +34,10 @@ export class OpenAIEmbeddingFunction implements EmbeddingFunction { this.sourceColumn = sourceColumn const configuration = { apiKey: openAIKey - }; + } - this._openai = new openai(configuration); + this._openai = new Openai(configuration) this._modelName = modelName - - } async embed (data: string[]): Promise { @@ -50,7 +48,7 @@ export class OpenAIEmbeddingFunction implements EmbeddingFunction { const embeddings: number[][] = [] for (let i = 0; i < response.data.length; i++) { - embeddings.push(response.data[i].embedding as number[]) + embeddings.push(response.data[i].embedding) } return embeddings } diff --git a/node/src/test/embedding/openai.ts b/node/src/test/embedding/openai.ts index 46453571..07a7b57f 100644 --- a/node/src/test/embedding/openai.ts +++ b/node/src/test/embedding/openai.ts @@ -24,16 +24,15 @@ const OpenAIApi = require('openai') const { stub } = require('sinon') describe('OpenAPIEmbeddings', function () { - const stubValue = { - data: [ - { - embedding: Array(1536).fill(1.0) - }, - { - embedding: Array(1536).fill(2.0) - } - ] + data: [ + { + embedding: Array(1536).fill(1.0) + }, + { + embedding: Array(1536).fill(2.0) + } + ] } describe('#embed', function () {