@superinterface/react 3.27.3 → 3.28.1

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.cjs CHANGED
@@ -39692,7 +39692,18 @@ function _toPrimitive6(t, r) {
39692
39692
  var content = function(_ref) {
39693
39693
  var newMessage = _ref.newMessage;
39694
39694
  if ((0, import_radash2.isArray)(newMessage.content)) {
39695
- return newMessage.content;
39695
+ return newMessage.content.map(function(item) {
39696
+ if (item.type === "text") {
39697
+ return {
39698
+ type: "text",
39699
+ text: {
39700
+ annotations: [],
39701
+ value: item.text
39702
+ }
39703
+ };
39704
+ }
39705
+ return item;
39706
+ });
39696
39707
  }
39697
39708
  return [
39698
39709
  {
@@ -44936,8 +44947,7 @@ var Root8 = function(_ref) {
44936
44947
  var latestMessage = useLatestMessage().latestMessage;
44937
44948
  var isDisabled = (0, import_react51.useMemo)(function() {
44938
44949
  var _latestMessage$metada;
44939
- return(// @ts-ignore-next-line
44940
- (latestMessage === null || latestMessage === void 0 || (_latestMessage$metada = latestMessage.metadata) === null || _latestMessage$metada === void 0 ? void 0 : _latestMessage$metada.isBlocking) || isDisabledArg);
44950
+ return !!(latestMessage !== null && latestMessage !== void 0 && (_latestMessage$metada = latestMessage.metadata) !== null && _latestMessage$metada !== void 0 && _latestMessage$metada.isBlocking) || !!isDisabledArg;
44941
44951
  }, [
44942
44952
  latestMessage,
44943
44953
  isDisabledArg
@@ -44947,7 +44957,7 @@ var Root8 = function(_ref) {
44947
44957
  createMessage: createMessage
44948
44958
  }) : /* @__PURE__ */ function() {
44949
44959
  var _ref2 = _asyncToGenerator6(function(data2) {
44950
- var attachments;
44960
+ var attachments, imageFileContentParts, content2;
44951
44961
  return _ts_generator(this, function(_state) {
44952
44962
  switch(_state.label){
44953
44963
  case 0:
@@ -44962,9 +44972,11 @@ var Root8 = function(_ref) {
44962
44972
  ];
44963
44973
  reset();
44964
44974
  setFiles([]);
44965
- attachments = files.map(function(file_0) {
44975
+ attachments = files.filter(function(file_0) {
44976
+ return file_0.purpose === "assistants";
44977
+ }).map(function(file_1) {
44966
44978
  return {
44967
- file_id: file_0.id,
44979
+ file_id: file_1.id,
44968
44980
  tools: [
44969
44981
  {
44970
44982
  type: "file_search"
@@ -44972,11 +44984,26 @@ var Root8 = function(_ref) {
44972
44984
  ]
44973
44985
  };
44974
44986
  });
44987
+ imageFileContentParts = files.filter(function(file_2) {
44988
+ return file_2.purpose === "vision";
44989
+ }).map(function(file_3) {
44990
+ return {
44991
+ type: "image_file",
44992
+ image_file: {
44993
+ file_id: file_3.id
44994
+ }
44995
+ };
44996
+ });
44997
+ content2 = _to_consumable_array(imageFileContentParts).concat([
44998
+ {
44999
+ type: "text",
45000
+ text: data2.content
45001
+ }
45002
+ ]);
44975
45003
  return [
44976
45004
  4,
44977
45005
  createMessage(_objectSpread29({
44978
- // @ts-ignore-next-line
44979
- content: data2.content
45006
+ content: content2
44980
45007
  }, attachments.length ? {
44981
45008
  attachments: attachments
44982
45009
  } : {}))
@@ -44993,7 +45020,7 @@ var Root8 = function(_ref) {
44993
45020
  return _ref2.apply(this, arguments);
44994
45021
  };
44995
45022
  }();
44996
- var content2 = watch("content");
45023
+ var content_0 = watch("content");
44997
45024
  return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(MessageFormContext.Provider, {
44998
45025
  value: {
44999
45026
  isDisabled: isDisabled,
@@ -45001,7 +45028,7 @@ var Root8 = function(_ref) {
45001
45028
  files: files,
45002
45029
  setFiles: setFiles,
45003
45030
  isFileLoading: isFileLoading,
45004
- content: content2
45031
+ content: content_0
45005
45032
  },
45006
45033
  children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_react_hook_form.FormProvider, _objectSpread29(_objectSpread29({}, formProps), {}, {
45007
45034
  children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_themes47.Box, {
@@ -45881,13 +45908,20 @@ function AsyncFromSyncIterator(r) {
45881
45908
  }
45882
45909
  }, new AsyncFromSyncIterator(r);
45883
45910
  }
45884
- var accept = ".c,text/x-c,\n.cs,text/x-csharp,\n.cpp,text/x-c++,\n.doc,application/msword,\n.docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document,\n.html,text/html,\n.java,text/x-java,\n.json,application/json,\n.md,text/markdown,\n.pdf,application/pdf,\n.php,text/x-php,\n.pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation,\n.py,text/x-python,\n.py,text/x-script.python,\n.rb,text/x-ruby,\n.tex,text/x-tex,\n.txt,text/plain,\n.css,text/css,\n.js,text/javascript,\n.sh,application/x-sh,\n.ts,application/typescript";
45911
+ var accept = ".c,text/x-c,\n.cs,text/x-csharp,\n.cpp,text/x-c++,\n.doc,application/msword,\n.docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document,\n.html,text/html,\n.java,text/x-java,\n.json,application/json,\n.md,text/markdown,\n.pdf,application/pdf,\n.php,text/x-php,\n.pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation,\n.py,text/x-python,\n.py,text/x-script.python,\n.rb,text/x-ruby,\n.tex,text/x-tex,\n.txt,text/plain,\n.css,text/css,\n.js,text/javascript,\n.sh,application/x-sh,\n.ts,application/typescript,\n.png,image/png,\n.jpeg,image/jpeg,\n.jpg,image/jpeg,\n.webp,image/webp,\n.gif,image/gif";
45912
+ var purpose = function(_ref) {
45913
+ var fileObject = _ref.fileObject;
45914
+ if (fileObject.type.startsWith("image/")) {
45915
+ return "vision";
45916
+ }
45917
+ return "assistants";
45918
+ };
45885
45919
  var Control2 = function(props) {
45886
45920
  var _useMessageFormContext = useMessageFormContext(), isDisabled = _useMessageFormContext.isDisabled, isLoading = _useMessageFormContext.isLoading, setFiles = _useMessageFormContext.setFiles;
45887
45921
  var createFile = useCreateFile().createFile;
45888
45922
  var addToast = useToasts().addToast;
45889
45923
  var onChange = (0, import_react55.useCallback)(/* @__PURE__ */ function() {
45890
- var _ref = _asyncToGenerator8(function(event) {
45924
+ var _ref2 = _asyncToGenerator8(function(event) {
45891
45925
  var fileObjects, newFiles, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step, err;
45892
45926
  return _ts_generator(this, function(_state) {
45893
45927
  switch(_state.label){
@@ -45901,7 +45935,9 @@ var Control2 = function(props) {
45901
45935
  id: optimisticId(),
45902
45936
  filename: fileObject.name,
45903
45937
  object: "file",
45904
- purpose: "assistants",
45938
+ purpose: purpose({
45939
+ fileObject: fileObject
45940
+ }),
45905
45941
  created_at: (0, import_dayjs2.default)().unix(),
45906
45942
  bytes: fileObject.size,
45907
45943
  status: "processed",
@@ -45934,10 +45970,11 @@ var Control2 = function(props) {
45934
45970
  return [
45935
45971
  4,
45936
45972
  createFile({
45937
- file: newFile.fileObject
45973
+ file: newFile.fileObject,
45974
+ purpose: newFile.purpose
45938
45975
  }, {
45939
- onSuccess: function(_ref2) {
45940
- var file = _ref2.file;
45976
+ onSuccess: function(_ref3) {
45977
+ var file = _ref3.file;
45941
45978
  return setFiles(function(prev) {
45942
45979
  return _to_consumable_array(prev.filter(function(prevFile) {
45943
45980
  return prevFile.id !== newFile.id;
@@ -46047,7 +46084,7 @@ var Control2 = function(props) {
46047
46084
  });
46048
46085
  });
46049
46086
  return function(_x) {
46050
- return _ref.apply(this, arguments);
46087
+ return _ref2.apply(this, arguments);
46051
46088
  };
46052
46089
  }(), [
46053
46090
  addToast,