@pickaxeproject/react 0.0.71 → 0.0.72

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
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),o=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),n=require("./useDocumentContext.js"),i=require("../../../../../common/documents.js"),r=require("../../../../../common/error.js");const a=["gpt-4o","gpt-4o-mini"];exports.useDocument=({onQuestionChange:u}={})=>{const{formId:d,chatId:l,pickaxe:c}=o.usePickaxeContext(),m=n.useDocumentContext(),p=s.useSubmitDocument(),f=t.useMemo((()=>{var e;return a.includes(null!==(e=null==c?void 0:c.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[c]);return Object.assign(Object.assign({},m),{isImageUploadAllowed:f,onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(m.setDocumentError(""),!t.length)return null;const e=t[0];try{const o=[...i.allowedFileMimeTypes,...f?i.allowedImageMimeTypes:[]],s=t.some((e=>!o.includes(e.type)));if(s){throw new Error(f?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again.")}m.setIsUploading(!0),m.setIsShowList(!0),m.upsertDocuments([{type:"document",id:e.name,name:e.name,status:"uploading"}]);const n=yield p.document({formId:d,responseId:l,file:e}),{success:r,documentId:a,error:c}=n;if(!r)throw new Error(null!=c?c:"Document processing failed, please try again.");null==u||u({input:e.name,documentId:a});const y=a.startsWith("IMAGE-")?"image":"document";return m.upsertDocuments([{type:y,id:e.name,name:e.name,status:"finished",documentId:a}]),{type:y,id:e.name,name:e.name,status:"finished",documentId:a}}catch(t){const o=r.default(t);return console.log("[onFileUpload] Error",o),o.includes("You can only upload")?(m.setDocumentError(o),null):(m.editDocument({type:"document",id:e.name,name:e.name,status:"failed",error:o}),{type:"document",id:e.name,name:e.name,status:"failed",error:o})}finally{m.setIsUploading(!1)}})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){m.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");m.setIsUploading(!0),m.setIsShowList(!0),m.setWebsiteLink(""),m.upsertDocuments([{type:"website",id:e,name:e,status:"uploading"}]);const t=yield p.website({formId:d,responseId:l,website:e}),{success:o,documentId:s}=t;if(!o)throw new Error("Website processing failed, please try again.");return m.upsertDocuments([{type:"website",id:e,name:e,status:"finished",documentId:s}]),{type:"website",id:e,name:e,status:"finished",documentId:s}}catch(t){const o=r.default(t);return console.log("[onWebsiteUpload] Error",o),o.includes("Please paste a valid website URL")?(m.setDocumentError(o),null):(m.editDocument({type:"website",id:e,name:e,status:"failed",error:o}),{type:"website",id:e,name:e,status:"failed",error:o})}finally{m.setIsUploading(!1)}})),onEditDocumentByDocId:m.editDocumentByDocId})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),o=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),n=require("./useDocumentContext.js"),i=require("../../../../../common/documents.js"),r=require("../../../../../common/error.js");const a=["gpt-4o-mini","gpt-4o","gpt-4.5-preview","o1"];exports.useDocument=({onQuestionChange:u}={})=>{const{formId:d,chatId:l,pickaxe:c}=o.usePickaxeContext(),m=n.useDocumentContext(),p=s.useSubmitDocument(),f=t.useMemo((()=>{var e;return a.includes(null!==(e=null==c?void 0:c.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[c]);return Object.assign(Object.assign({},m),{isImageUploadAllowed:f,onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(m.setDocumentError(""),!t.length)return null;const e=t[0];try{const o=[...i.allowedFileMimeTypes,...f?i.allowedImageMimeTypes:[]],s=t.some((e=>!o.includes(e.type)));if(s){throw new Error(f?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again.")}m.setIsUploading(!0),m.setIsShowList(!0),m.upsertDocuments([{type:"document",id:e.name,name:e.name,status:"uploading"}]);const n=yield p.document({formId:d,responseId:l,file:e}),{success:r,documentId:a,error:c}=n;if(!r)throw new Error(null!=c?c:"Document processing failed, please try again.");null==u||u({input:e.name,documentId:a});const y=a.startsWith("IMAGE-")?"image":"document";return m.upsertDocuments([{type:y,id:e.name,name:e.name,status:"finished",documentId:a}]),{type:y,id:e.name,name:e.name,status:"finished",documentId:a}}catch(t){const o=r.default(t);return console.log("[onFileUpload] Error",o),o.includes("You can only upload")?(m.setDocumentError(o),null):(m.editDocument({type:"document",id:e.name,name:e.name,status:"failed",error:o}),{type:"document",id:e.name,name:e.name,status:"failed",error:o})}finally{m.setIsUploading(!1)}})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){m.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");m.setIsUploading(!0),m.setIsShowList(!0),m.setWebsiteLink(""),m.upsertDocuments([{type:"website",id:e,name:e,status:"uploading"}]);const t=yield p.website({formId:d,responseId:l,website:e}),{success:o,documentId:s}=t;if(!o)throw new Error("Website processing failed, please try again.");return m.upsertDocuments([{type:"website",id:e,name:e,status:"finished",documentId:s}]),{type:"website",id:e,name:e,status:"finished",documentId:s}}catch(t){const o=r.default(t);return console.log("[onWebsiteUpload] Error",o),o.includes("Please paste a valid website URL")?(m.setDocumentError(o),null):(m.editDocument({type:"website",id:e,name:e,status:"failed",error:o}),{type:"website",id:e,name:e,status:"failed",error:o})}finally{m.setIsUploading(!1)}})),onEditDocumentByDocId:m.editDocumentByDocId})};
@@ -3,7 +3,7 @@ export type PickaxeImageOrText = "text" | "image";
3
3
  export type PickaxePrivacySetting = "public" | "unlisted" | "private" | "deleted";
4
4
  export type PickaxeCloneable = "true" | "false";
5
5
  export type PickaxeDocumentUploadType = "ownerupload" | "enduserupload";
6
- export type PickaxeModel = "gpt-4o-mini" | "gpt-4o" | "gpt-4-1106-preview" | "gpt-4" | "gpt-3.5-turbo" | "mistral-small" | "mistral-large-latest" | "claude-3-opus-20240229" | "claude-3-5-sonnet-20240620";
6
+ export type PickaxeModel = "gpt-4o-mini" | "gpt-4o" | "gpt-4-1106-preview" | "gpt-4" | "gpt-3.5-turbo" | "gpt-4.5-preview" | "o1" | "o3-mini" | "deepseek-chat" | "mistral-small" | "mistral-large-latest" | "claude-3-opus-20240229" | "claude-3-5-sonnet-20240620" | "claude-3-7-sonnet-20250219" | "llama-3-uncensored";
7
7
  export type Pickaxe = {
8
8
  _id: string;
9
9
  formid: string;
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useMemo as t}from"react";import{usePickaxeContext as o}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useSubmitDocument as n}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as s}from"./useDocumentContext.js";import{allowedFileMimeTypes as i,allowedImageMimeTypes as r}from"../../../../../common/documents.js";import a from"../../../../../common/error.js";const d=["gpt-4o","gpt-4o-mini"],u=({onQuestionChange:u}={})=>{const{formId:l,chatId:m,pickaxe:c}=o(),p=s(),f=n(),h=t((()=>{var e;return d.includes(null!==(e=null==c?void 0:c.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[c]);return Object.assign(Object.assign({},p),{isImageUploadAllowed:h,onFileUpload:t=>e(void 0,void 0,void 0,(function*(){if(p.setDocumentError(""),!t.length)return null;const e=t[0];try{const o=[...i,...h?r:[]],n=t.some((e=>!o.includes(e.type)));if(n){throw new Error(h?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again.")}p.setIsUploading(!0),p.setIsShowList(!0),p.upsertDocuments([{type:"document",id:e.name,name:e.name,status:"uploading"}]);const s=yield f.document({formId:l,responseId:m,file:e}),{success:a,documentId:d,error:c}=s;if(!a)throw new Error(null!=c?c:"Document processing failed, please try again.");null==u||u({input:e.name,documentId:d});const y=d.startsWith("IMAGE-")?"image":"document";return p.upsertDocuments([{type:y,id:e.name,name:e.name,status:"finished",documentId:d}]),{type:y,id:e.name,name:e.name,status:"finished",documentId:d}}catch(t){const o=a(t);return console.log("[onFileUpload] Error",o),o.includes("You can only upload")?(p.setDocumentError(o),null):(p.editDocument({type:"document",id:e.name,name:e.name,status:"failed",error:o}),{type:"document",id:e.name,name:e.name,status:"failed",error:o})}finally{p.setIsUploading(!1)}})),onWebsiteUpload:t=>e(void 0,void 0,void 0,(function*(){p.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");p.setIsUploading(!0),p.setIsShowList(!0),p.setWebsiteLink(""),p.upsertDocuments([{type:"website",id:e,name:e,status:"uploading"}]);const t=yield f.website({formId:l,responseId:m,website:e}),{success:o,documentId:n}=t;if(!o)throw new Error("Website processing failed, please try again.");return p.upsertDocuments([{type:"website",id:e,name:e,status:"finished",documentId:n}]),{type:"website",id:e,name:e,status:"finished",documentId:n}}catch(t){const o=a(t);return console.log("[onWebsiteUpload] Error",o),o.includes("Please paste a valid website URL")?(p.setDocumentError(o),null):(p.editDocument({type:"website",id:e,name:e,status:"failed",error:o}),{type:"website",id:e,name:e,status:"failed",error:o})}finally{p.setIsUploading(!1)}})),onEditDocumentByDocId:p.editDocumentByDocId})};export{u as useDocument};
1
+ import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useMemo as t}from"react";import{usePickaxeContext as o}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useSubmitDocument as n}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as s}from"./useDocumentContext.js";import{allowedFileMimeTypes as i,allowedImageMimeTypes as r}from"../../../../../common/documents.js";import a from"../../../../../common/error.js";const d=["gpt-4o-mini","gpt-4o","gpt-4.5-preview","o1"],u=({onQuestionChange:u}={})=>{const{formId:l,chatId:m,pickaxe:c}=o(),p=s(),f=n(),h=t((()=>{var e;return d.includes(null!==(e=null==c?void 0:c.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[c]);return Object.assign(Object.assign({},p),{isImageUploadAllowed:h,onFileUpload:t=>e(void 0,void 0,void 0,(function*(){if(p.setDocumentError(""),!t.length)return null;const e=t[0];try{const o=[...i,...h?r:[]],n=t.some((e=>!o.includes(e.type)));if(n){throw new Error(h?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again.")}p.setIsUploading(!0),p.setIsShowList(!0),p.upsertDocuments([{type:"document",id:e.name,name:e.name,status:"uploading"}]);const s=yield f.document({formId:l,responseId:m,file:e}),{success:a,documentId:d,error:c}=s;if(!a)throw new Error(null!=c?c:"Document processing failed, please try again.");null==u||u({input:e.name,documentId:d});const y=d.startsWith("IMAGE-")?"image":"document";return p.upsertDocuments([{type:y,id:e.name,name:e.name,status:"finished",documentId:d}]),{type:y,id:e.name,name:e.name,status:"finished",documentId:d}}catch(t){const o=a(t);return console.log("[onFileUpload] Error",o),o.includes("You can only upload")?(p.setDocumentError(o),null):(p.editDocument({type:"document",id:e.name,name:e.name,status:"failed",error:o}),{type:"document",id:e.name,name:e.name,status:"failed",error:o})}finally{p.setIsUploading(!1)}})),onWebsiteUpload:t=>e(void 0,void 0,void 0,(function*(){p.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");p.setIsUploading(!0),p.setIsShowList(!0),p.setWebsiteLink(""),p.upsertDocuments([{type:"website",id:e,name:e,status:"uploading"}]);const t=yield f.website({formId:l,responseId:m,website:e}),{success:o,documentId:n}=t;if(!o)throw new Error("Website processing failed, please try again.");return p.upsertDocuments([{type:"website",id:e,name:e,status:"finished",documentId:n}]),{type:"website",id:e,name:e,status:"finished",documentId:n}}catch(t){const o=a(t);return console.log("[onWebsiteUpload] Error",o),o.includes("Please paste a valid website URL")?(p.setDocumentError(o),null):(p.editDocument({type:"website",id:e,name:e,status:"failed",error:o}),{type:"website",id:e,name:e,status:"failed",error:o})}finally{p.setIsUploading(!1)}})),onEditDocumentByDocId:p.editDocumentByDocId})};export{u as useDocument};
@@ -3,7 +3,7 @@ export type PickaxeImageOrText = "text" | "image";
3
3
  export type PickaxePrivacySetting = "public" | "unlisted" | "private" | "deleted";
4
4
  export type PickaxeCloneable = "true" | "false";
5
5
  export type PickaxeDocumentUploadType = "ownerupload" | "enduserupload";
6
- export type PickaxeModel = "gpt-4o-mini" | "gpt-4o" | "gpt-4-1106-preview" | "gpt-4" | "gpt-3.5-turbo" | "mistral-small" | "mistral-large-latest" | "claude-3-opus-20240229" | "claude-3-5-sonnet-20240620";
6
+ export type PickaxeModel = "gpt-4o-mini" | "gpt-4o" | "gpt-4-1106-preview" | "gpt-4" | "gpt-3.5-turbo" | "gpt-4.5-preview" | "o1" | "o3-mini" | "deepseek-chat" | "mistral-small" | "mistral-large-latest" | "claude-3-opus-20240229" | "claude-3-5-sonnet-20240620" | "claude-3-7-sonnet-20250219" | "llama-3-uncensored";
7
7
  export type Pickaxe = {
8
8
  _id: string;
9
9
  formid: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "0.0.71",
3
+ "version": "0.0.72",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",