Skip to content

Commit 4916531

Browse files
committed
Revert "use a workaround"
This reverts commit 035b126.
1 parent 035b126 commit 4916531

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/api/constants.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,13 @@
1313
// limitations under the License.
1414

1515
import { LIB_NAME, LIB_VERSION } from '@/src/version';
16-
import * as path from "path";
17-
import * as fs from "fs";
1816

1917
export const RAGSTACK_REQUESTED_WITH = (() => {
20-
/**
21-
* Do not use require() here, it will break the build in some environments such as NextJS application
22-
* if @datastax/ragstack-ai is not installed (which is perfectly fine).
23-
*/
2418
try {
25-
const expectedFilePath = path.join('@datastax', 'ragstack-ai', 'package.json');
26-
for (const nodeModulesPath of module.paths) {
27-
const fullFilePath = path.join(nodeModulesPath, expectedFilePath);
28-
if (fs.existsSync(fullFilePath)) {
29-
const packageJson = JSON.parse(fs.readFileSync(fullFilePath, 'utf8'))
30-
return `ragstack-ai-ts/${packageJson.version}`
31-
}
32-
}
33-
return ''
19+
// eslint-disable-next-line @typescript-eslint/no-var-requires
20+
const ragstack = require('@datastax/ragstack-ai');
21+
const version = ragstack['RAGSTACK_VERSION'] || "?";
22+
return `ragstack-ai-ts/${version}`
3423
} catch (e) {
3524
return '';
3625
}

0 commit comments

Comments
 (0)