File tree Expand file tree Collapse file tree 1 file changed +4
-15
lines changed Expand file tree Collapse file tree 1 file changed +4
-15
lines changed Original file line number Diff line number Diff line change 13
13
// limitations under the License.
14
14
15
15
import { LIB_NAME , LIB_VERSION } from '@/src/version' ;
16
- import * as path from "path" ;
17
- import * as fs from "fs" ;
18
16
19
17
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
- */
24
18
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 } `
34
23
} catch ( e ) {
35
24
return '' ;
36
25
}
You can’t perform that action at this time.
0 commit comments