@stackfactor/agent-utils 1.0.2 → 1.0.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBAoaQ,MAAM,aACD,MAAM,gBACH,MAAM,SACb,GAAG,EAAE,kBACI,GAAG,UACX,GAAG,qBACO,QAAQ,GAAG,IAAI,eACrB,MAAM,eACN,MAAM,KACjB,GAAG;sBAyCG,GAAG,UACF,MAAM,UACN,GAAG,eACC,QAAQ,GAAG,IAAI,KAC1B,OAAO,CAAC,GAAG,CAAC;wCAioBF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,KACpB,GAAG;oCApfO,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,KACX,OAAO,CAAC,GAAG,CAAC;sDAyyBF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,KACX,OAAO,CAAC,GAAG,CAAC;0CAz2B8B,GAAG,KAAG,MAAM;;AAo6BzD,wBAOE"}
1
+ {"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBAoaQ,MAAM,aACD,MAAM,gBACH,MAAM,SACb,GAAG,EAAE,kBACI,GAAG,UACX,GAAG,qBACO,QAAQ,GAAG,IAAI,eACrB,MAAM,eACN,MAAM,KACjB,GAAG;sBAyCG,GAAG,UACF,MAAM,UACN,GAAG,eACC,QAAQ,GAAG,IAAI,KAC1B,OAAO,CAAC,GAAG,CAAC;wCAuqBF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,KACpB,GAAG;oCA1hBO,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,KACX,OAAO,CAAC,GAAG,CAAC;sDA+0BF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,KACX,OAAO,CAAC,GAAG,CAAC;0CA/4B8B,GAAG,KAAG,MAAM;;AA08BzD,wBAOE"}
@@ -639,7 +639,20 @@ const runPromptWithModel = async (modelName, config, prompt, onProgressReport, m
639
639
  }
640
640
  }
641
641
  if (expectsJsonResponse) {
642
- throw errorHandling_js_1.default.create(const_js_1.default.HTTP_CODES.INTERNAL_SERVER_ERROR, `Agent returned non-JSON response when JSON was expected: ${rawContent.substring(0, 100)}...`);
642
+ let preview = "";
643
+ if (typeof rawContent === "string") {
644
+ preview = rawContent.substring(0, 100);
645
+ }
646
+ else if (typeof rawContent === "object" && rawContent !== null) {
647
+ preview = JSON.stringify(rawContent).substring(0, 100);
648
+ }
649
+ else if (rawContent !== undefined && rawContent !== null) {
650
+ preview = String(rawContent).substring(0, 100);
651
+ }
652
+ else {
653
+ preview = "[empty response]";
654
+ }
655
+ throw errorHandling_js_1.default.create(const_js_1.default.HTTP_CODES.INTERNAL_SERVER_ERROR, `Agent returned non-JSON response when JSON was expected: ${preview}...`);
643
656
  }
644
657
  return rawContent;
645
658
  }
@@ -713,7 +726,20 @@ const runPromptWithModel = async (modelName, config, prompt, onProgressReport, m
713
726
  return JSON.stringify(extracted);
714
727
  }
715
728
  if (expectsJsonResponse) {
716
- throw errorHandling_js_1.default.create(const_js_1.default.HTTP_CODES.INTERNAL_SERVER_ERROR, `LLM returned non-JSON response when JSON was expected: ${rawContent.substring(0, 100)}...`);
729
+ let preview = "";
730
+ if (typeof rawContent === "string") {
731
+ preview = rawContent.substring(0, 100);
732
+ }
733
+ else if (typeof rawContent === "object" && rawContent !== null) {
734
+ preview = JSON.stringify(rawContent).substring(0, 100);
735
+ }
736
+ else if (rawContent !== undefined && rawContent !== null) {
737
+ preview = String(rawContent).substring(0, 100);
738
+ }
739
+ else {
740
+ preview = "[empty response]";
741
+ }
742
+ throw errorHandling_js_1.default.create(const_js_1.default.HTTP_CODES.INTERNAL_SERVER_ERROR, `LLM returned non-JSON response when JSON was expected: ${preview}...`);
717
743
  }
718
744
  return rawContent;
719
745
  }
@@ -841,7 +867,20 @@ const runPromptWithModel = async (modelName, config, prompt, onProgressReport, m
841
867
  return JSON.stringify(extracted);
842
868
  }
843
869
  if (expectsJsonResponse) {
844
- throw errorHandling_js_1.default.create(const_js_1.default.HTTP_CODES.INTERNAL_SERVER_ERROR, `LLM returned non-JSON response when JSON was expected: ${rawContent.substring(0, 100)}...`);
870
+ let preview = "";
871
+ if (typeof rawContent === "string") {
872
+ preview = rawContent.substring(0, 100);
873
+ }
874
+ else if (typeof rawContent === "object" && rawContent !== null) {
875
+ preview = JSON.stringify(rawContent).substring(0, 100);
876
+ }
877
+ else if (rawContent !== undefined && rawContent !== null) {
878
+ preview = String(rawContent).substring(0, 100);
879
+ }
880
+ else {
881
+ preview = "[empty response]";
882
+ }
883
+ throw errorHandling_js_1.default.create(const_js_1.default.HTTP_CODES.INTERNAL_SERVER_ERROR, `LLM returned non-JSON response when JSON was expected: ${preview}...`);
845
884
  }
846
885
  return rawContent;
847
886
  }
@@ -928,7 +967,19 @@ const runPromptWithModel = async (modelName, config, prompt, onProgressReport, m
928
967
  }
929
968
  // Return raw content as last resort - but throw if JSON was expected
930
969
  if (expectsJsonResponse) {
931
- const preview = typeof rawContent === "string" ? rawContent.substring(0, 100) : "";
970
+ let preview = "";
971
+ if (typeof rawContent === "string") {
972
+ preview = rawContent.substring(0, 100);
973
+ }
974
+ else if (typeof rawContent === "object" && rawContent !== null) {
975
+ preview = JSON.stringify(rawContent).substring(0, 100);
976
+ }
977
+ else if (rawContent !== undefined && rawContent !== null) {
978
+ preview = String(rawContent).substring(0, 100);
979
+ }
980
+ else {
981
+ preview = "[empty response]";
982
+ }
932
983
  throw errorHandling_js_1.default.create(const_js_1.default.HTTP_CODES.INTERNAL_SERVER_ERROR, `LLM returned non-JSON response when JSON was expected: ${preview}...`);
933
984
  }
934
985
  return rawContent;
@@ -1 +1 @@
1
- {"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBAoaQ,MAAM,aACD,MAAM,gBACH,MAAM,SACb,GAAG,EAAE,kBACI,GAAG,UACX,GAAG,qBACO,QAAQ,GAAG,IAAI,eACrB,MAAM,eACN,MAAM,KACjB,GAAG;sBAyCG,GAAG,UACF,MAAM,UACN,GAAG,eACC,QAAQ,GAAG,IAAI,KAC1B,OAAO,CAAC,GAAG,CAAC;wCAioBF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,KACpB,GAAG;oCApfO,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,KACX,OAAO,CAAC,GAAG,CAAC;sDAyyBF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,KACX,OAAO,CAAC,GAAG,CAAC;0CAz2B8B,GAAG,KAAG,MAAM;;AAo6BzD,wBAOE"}
1
+ {"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBAoaQ,MAAM,aACD,MAAM,gBACH,MAAM,SACb,GAAG,EAAE,kBACI,GAAG,UACX,GAAG,qBACO,QAAQ,GAAG,IAAI,eACrB,MAAM,eACN,MAAM,KACjB,GAAG;sBAyCG,GAAG,UACF,MAAM,UACN,GAAG,eACC,QAAQ,GAAG,IAAI,KAC1B,OAAO,CAAC,GAAG,CAAC;wCAuqBF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,KACpB,GAAG;oCA1hBO,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,KACX,OAAO,CAAC,GAAG,CAAC;sDA+0BF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,KACX,OAAO,CAAC,GAAG,CAAC;0CA/4B8B,GAAG,KAAG,MAAM;;AA08BzD,wBAOE"}
@@ -634,7 +634,20 @@ const runPromptWithModel = async (modelName, config, prompt, onProgressReport, m
634
634
  }
635
635
  }
636
636
  if (expectsJsonResponse) {
637
- throw errorHandlingHelper.create(constants.HTTP_CODES.INTERNAL_SERVER_ERROR, `Agent returned non-JSON response when JSON was expected: ${rawContent.substring(0, 100)}...`);
637
+ let preview = "";
638
+ if (typeof rawContent === "string") {
639
+ preview = rawContent.substring(0, 100);
640
+ }
641
+ else if (typeof rawContent === "object" && rawContent !== null) {
642
+ preview = JSON.stringify(rawContent).substring(0, 100);
643
+ }
644
+ else if (rawContent !== undefined && rawContent !== null) {
645
+ preview = String(rawContent).substring(0, 100);
646
+ }
647
+ else {
648
+ preview = "[empty response]";
649
+ }
650
+ throw errorHandlingHelper.create(constants.HTTP_CODES.INTERNAL_SERVER_ERROR, `Agent returned non-JSON response when JSON was expected: ${preview}...`);
638
651
  }
639
652
  return rawContent;
640
653
  }
@@ -708,7 +721,20 @@ const runPromptWithModel = async (modelName, config, prompt, onProgressReport, m
708
721
  return JSON.stringify(extracted);
709
722
  }
710
723
  if (expectsJsonResponse) {
711
- throw errorHandlingHelper.create(constants.HTTP_CODES.INTERNAL_SERVER_ERROR, `LLM returned non-JSON response when JSON was expected: ${rawContent.substring(0, 100)}...`);
724
+ let preview = "";
725
+ if (typeof rawContent === "string") {
726
+ preview = rawContent.substring(0, 100);
727
+ }
728
+ else if (typeof rawContent === "object" && rawContent !== null) {
729
+ preview = JSON.stringify(rawContent).substring(0, 100);
730
+ }
731
+ else if (rawContent !== undefined && rawContent !== null) {
732
+ preview = String(rawContent).substring(0, 100);
733
+ }
734
+ else {
735
+ preview = "[empty response]";
736
+ }
737
+ throw errorHandlingHelper.create(constants.HTTP_CODES.INTERNAL_SERVER_ERROR, `LLM returned non-JSON response when JSON was expected: ${preview}...`);
712
738
  }
713
739
  return rawContent;
714
740
  }
@@ -836,7 +862,20 @@ const runPromptWithModel = async (modelName, config, prompt, onProgressReport, m
836
862
  return JSON.stringify(extracted);
837
863
  }
838
864
  if (expectsJsonResponse) {
839
- throw errorHandlingHelper.create(constants.HTTP_CODES.INTERNAL_SERVER_ERROR, `LLM returned non-JSON response when JSON was expected: ${rawContent.substring(0, 100)}...`);
865
+ let preview = "";
866
+ if (typeof rawContent === "string") {
867
+ preview = rawContent.substring(0, 100);
868
+ }
869
+ else if (typeof rawContent === "object" && rawContent !== null) {
870
+ preview = JSON.stringify(rawContent).substring(0, 100);
871
+ }
872
+ else if (rawContent !== undefined && rawContent !== null) {
873
+ preview = String(rawContent).substring(0, 100);
874
+ }
875
+ else {
876
+ preview = "[empty response]";
877
+ }
878
+ throw errorHandlingHelper.create(constants.HTTP_CODES.INTERNAL_SERVER_ERROR, `LLM returned non-JSON response when JSON was expected: ${preview}...`);
840
879
  }
841
880
  return rawContent;
842
881
  }
@@ -923,7 +962,19 @@ const runPromptWithModel = async (modelName, config, prompt, onProgressReport, m
923
962
  }
924
963
  // Return raw content as last resort - but throw if JSON was expected
925
964
  if (expectsJsonResponse) {
926
- const preview = typeof rawContent === "string" ? rawContent.substring(0, 100) : "";
965
+ let preview = "";
966
+ if (typeof rawContent === "string") {
967
+ preview = rawContent.substring(0, 100);
968
+ }
969
+ else if (typeof rawContent === "object" && rawContent !== null) {
970
+ preview = JSON.stringify(rawContent).substring(0, 100);
971
+ }
972
+ else if (rawContent !== undefined && rawContent !== null) {
973
+ preview = String(rawContent).substring(0, 100);
974
+ }
975
+ else {
976
+ preview = "[empty response]";
977
+ }
927
978
  throw errorHandlingHelper.create(constants.HTTP_CODES.INTERNAL_SERVER_ERROR, `LLM returned non-JSON response when JSON was expected: ${preview}...`);
928
979
  }
929
980
  return rawContent;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "restricted"
5
5
  },
6
- "version": "1.0.2",
6
+ "version": "1.0.4",
7
7
  "description": "",
8
8
  "main": "dist/cjs/index.js",
9
9
  "module": "dist/esm/index.js",