@vegintech/langchain-react-agent 0.0.40 → 0.0.41

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.
Files changed (2) hide show
  1. package/dist/index.mjs +11 -2
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -752,11 +752,20 @@ function useToolExecution({ tools, toolCalls, isLoading = false, onExecutionChan
752
752
  //#endregion
753
753
  //#region src/utils/messageUtils.ts
754
754
  /**
755
+ * 生成标准 UUID v4(兼容非 HTTPS 环境,避免使用 crypto.randomUUID)
756
+ */
757
+ function generateId() {
758
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
759
+ const r = Math.random() * 16 | 0;
760
+ return (c === "x" ? r : r & 3 | 8).toString(16);
761
+ });
762
+ }
763
+ /**
755
764
  * 从 BaseMessage 中提取 tool_calls
756
765
  */
757
766
  function extractToolCalls(message) {
758
767
  if ("tool_calls" in message && Array.isArray(message.tool_calls)) return message.tool_calls.map((tc) => ({
759
- id: tc.id || crypto.randomUUID(),
768
+ id: tc.id || generateId(),
760
769
  name: tc.name || tc.function?.name || "",
761
770
  args: typeof tc.function?.args === "string" ? JSON.parse(tc.function.args) : tc.args || {}
762
771
  }));
@@ -807,7 +816,7 @@ function toChatMessage(message, toolResults) {
807
816
  });
808
817
  const reasoningContent = additionalKwargs.reasoning_content;
809
818
  return {
810
- id: message.id || crypto.randomUUID(),
819
+ id: message.id || generateId(),
811
820
  type: msgType,
812
821
  content: extractContent(message),
813
822
  name: message.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vegintech/langchain-react-agent",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "description": "LangChain Agent UI component library for React",
5
5
  "license": "MIT",
6
6
  "files": [