Skip to content

Commit 5f7509b

Browse files
committed
fix ragstack user agent detection
1 parent 5ac2361 commit 5f7509b

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/api/constants.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@
1414

1515
import { LIB_NAME, LIB_VERSION } from '@/src/version';
1616

17-
export const RAG_STACK_REQUESTED_WITH = (() => {
17+
export const RAGSTACK_REQUESTED_WITH = (() => {
1818
try {
1919
// eslint-disable-next-line @typescript-eslint/no-var-requires
20-
const lib = require('ragstack-ai');
21-
22-
if (!lib['LIB_NAME'] || !lib['LIB_VERSION']) {
23-
return '';
24-
}
25-
return lib['LIB_NAME'] + '/' + lib['LIB_VERSION'];
20+
const ragstack = require('@datastax/ragstack-ai');
21+
const version = ragstack['RAGSTACK_VERSION'] || "?";
22+
return `ragstack-ai-ts/${version}`
2623
} catch (e) {
2724
return '';
2825
}

src/api/http-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { CLIENT_USER_AGENT, RAG_STACK_REQUESTED_WITH } from '@/src/api/constants';
15+
import { CLIENT_USER_AGENT, RAGSTACK_REQUESTED_WITH } from '@/src/api/constants';
1616
import { HTTPRequestInfo, InternalFetchCtx, InternalHTTPClientOptions, ResponseWithBody } from '@/src/api/types';
1717
import { Caller, DataAPIClientEvents } from '@/src/client';
1818
import TypedEmitter from 'typed-emitter';
@@ -104,5 +104,5 @@ export function buildUserAgent(caller: Caller | Caller[] | undefined): string {
104104
return c[1] ? `${c[0]}/${c[1]}` : c[0];
105105
}).join(' ');
106106

107-
return `${RAG_STACK_REQUESTED_WITH} ${callerString} ${CLIENT_USER_AGENT}`.trim();
107+
return `${RAGSTACK_REQUESTED_WITH} ${callerString} ${CLIENT_USER_AGENT}`.trim();
108108
}

0 commit comments

Comments
 (0)