@axiom-lattice/react-sdk 2.1.68 → 2.1.69
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/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -408,16 +408,22 @@ function AxiomLatticeProvider({
|
|
|
408
408
|
}) {
|
|
409
409
|
const authContext = (0, import_react2.useContext)(AuthContext);
|
|
410
410
|
const tenantId = authContext?.currentTenant?.id;
|
|
411
|
+
const effectiveApiKey = (0, import_react2.useMemo)(() => {
|
|
412
|
+
if (authContext?.isAuthenticated) {
|
|
413
|
+
return sessionStorage.getItem("lattice_token") || config.apiKey;
|
|
414
|
+
}
|
|
415
|
+
return config.apiKey;
|
|
416
|
+
}, [authContext?.isAuthenticated, authContext?.currentTenant?.id, config.apiKey]);
|
|
411
417
|
const clientCacheRef = (0, import_react2.useRef)(/* @__PURE__ */ new Map());
|
|
412
418
|
const baseConfig = (0, import_react2.useMemo)(
|
|
413
419
|
() => ({
|
|
414
420
|
baseURL: config.baseURL,
|
|
415
|
-
apiKey:
|
|
421
|
+
apiKey: effectiveApiKey,
|
|
416
422
|
assistantId: "__BASE__",
|
|
417
423
|
// 占位符,不会被直接使用
|
|
418
424
|
transport: config.transport
|
|
419
425
|
}),
|
|
420
|
-
[config.baseURL,
|
|
426
|
+
[config.baseURL, effectiveApiKey, config.transport]
|
|
421
427
|
);
|
|
422
428
|
const baseClient = (0, import_react2.useMemo)(() => {
|
|
423
429
|
const client = new import_client_sdk.Client(baseConfig);
|