@pickaxeproject/react 0.0.0 → 0.0.2

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 (78) hide show
  1. package/README.md +3 -11
  2. package/dist/cjs/_virtual/_tslib.js +1 -1
  3. package/dist/cjs/common/api/index.d.ts +2 -0
  4. package/dist/cjs/common/api/index.js +1 -0
  5. package/dist/cjs/common/api/streamer.d.ts +7 -0
  6. package/dist/cjs/common/api/utils.d.ts +2 -0
  7. package/dist/cjs/common/cn.d.ts +3 -0
  8. package/dist/cjs/common/cn.js +1 -0
  9. package/dist/cjs/common/env.d.ts +2 -0
  10. package/dist/cjs/common/env.js +1 -0
  11. package/dist/cjs/common/utils.d.ts +1 -0
  12. package/dist/cjs/components/Pickaxe/index.d.ts +6 -0
  13. package/dist/cjs/components/Pickaxe/index.js +1 -0
  14. package/dist/cjs/hooks/useConversation.d.ts +8 -0
  15. package/dist/cjs/hooks/useHistory.d.ts +11 -0
  16. package/dist/cjs/hooks/usePickaxe.d.ts +7 -0
  17. package/dist/cjs/hooks/usePickaxe.js +1 -0
  18. package/dist/cjs/hooks/usePickaxeContext.d.ts +16 -0
  19. package/dist/cjs/hooks/usePickaxeContext.js +1 -0
  20. package/dist/cjs/hooks/useSubmit.d.ts +23 -0
  21. package/dist/cjs/hooks/useSubmitDocument.d.ts +16 -0
  22. package/dist/cjs/hooks/useSubmitResult.d.ts +27 -0
  23. package/dist/cjs/index.d.ts +1 -2
  24. package/dist/cjs/index.js +1 -1
  25. package/dist/cjs/providers/PickaxeProvider.d.ts +25 -0
  26. package/dist/cjs/providers/PickaxeProvider.js +1 -0
  27. package/dist/cjs/types/chat.d.ts +8 -0
  28. package/dist/cjs/types/common.d.ts +2 -0
  29. package/dist/cjs/types/form.d.ts +37 -0
  30. package/dist/cjs/types/history.d.ts +37 -0
  31. package/dist/cjs/types/pickaxe.d.ts +59 -0
  32. package/dist/esm/_virtual/_tslib.js +1 -1
  33. package/dist/esm/common/api/index.d.ts +2 -0
  34. package/dist/esm/common/api/index.js +1 -0
  35. package/dist/esm/common/api/streamer.d.ts +7 -0
  36. package/dist/esm/common/api/utils.d.ts +2 -0
  37. package/dist/esm/common/cn.d.ts +3 -0
  38. package/dist/esm/common/cn.js +1 -0
  39. package/dist/esm/common/env.d.ts +2 -0
  40. package/dist/esm/common/env.js +1 -0
  41. package/dist/esm/common/utils.d.ts +1 -0
  42. package/dist/esm/components/Pickaxe/index.d.ts +6 -0
  43. package/dist/esm/components/Pickaxe/index.js +1 -0
  44. package/dist/esm/hooks/useConversation.d.ts +8 -0
  45. package/dist/esm/hooks/useHistory.d.ts +11 -0
  46. package/dist/esm/hooks/usePickaxe.d.ts +7 -0
  47. package/dist/esm/hooks/usePickaxe.js +1 -0
  48. package/dist/esm/hooks/usePickaxeContext.d.ts +16 -0
  49. package/dist/esm/hooks/usePickaxeContext.js +1 -0
  50. package/dist/esm/hooks/useSubmit.d.ts +23 -0
  51. package/dist/esm/hooks/useSubmitDocument.d.ts +16 -0
  52. package/dist/esm/hooks/useSubmitResult.d.ts +27 -0
  53. package/dist/esm/index.d.ts +1 -2
  54. package/dist/esm/index.js +1 -1
  55. package/dist/esm/providers/PickaxeProvider.d.ts +25 -0
  56. package/dist/esm/providers/PickaxeProvider.js +1 -0
  57. package/dist/esm/types/chat.d.ts +8 -0
  58. package/dist/esm/types/common.d.ts +2 -0
  59. package/dist/esm/types/form.d.ts +37 -0
  60. package/dist/esm/types/history.d.ts +37 -0
  61. package/dist/esm/types/pickaxe.d.ts +59 -0
  62. package/package.json +21 -5
  63. package/dist/cjs/components/button/Button.d.ts +0 -5
  64. package/dist/cjs/components/button/Button.js +0 -1
  65. package/dist/cjs/components/button/index.d.ts +0 -1
  66. package/dist/cjs/components/container/Container.d.ts +0 -5
  67. package/dist/cjs/components/container/Container.js +0 -1
  68. package/dist/cjs/components/container/index.d.ts +0 -1
  69. package/dist/cjs/constants/colors.d.ts +0 -2
  70. package/dist/cjs/utils/cn.d.ts +0 -7
  71. package/dist/esm/components/button/Button.d.ts +0 -5
  72. package/dist/esm/components/button/Button.js +0 -1
  73. package/dist/esm/components/button/index.d.ts +0 -1
  74. package/dist/esm/components/container/Container.d.ts +0 -5
  75. package/dist/esm/components/container/Container.js +0 -1
  76. package/dist/esm/components/container/index.d.ts +0 -1
  77. package/dist/esm/constants/colors.d.ts +0 -2
  78. package/dist/esm/utils/cn.d.ts +0 -7
package/README.md CHANGED
@@ -2,16 +2,8 @@
2
2
 
3
3
  > Client utility library for Pickaxe
4
4
 
5
- ## Development
5
+ ## How to publish
6
6
 
7
- - Build the library:
7
+ - push to main branhc
8
8
 
9
- ```sh
10
- pnpm build
11
- ```
12
-
13
- - Create changeset:
14
-
15
- ```sh
16
- pnpm changeset
17
- ```
9
+ - merge auto-generated PR
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),"function"==typeof SuppressedError&&SuppressedError,exports.__rest=function(e,r){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&r.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var p=0;for(o=Object.getOwnPropertySymbols(e);p<o.length;p++)r.indexOf(o[p])<0&&Object.prototype.propertyIsEnumerable.call(e,o[p])&&(t[o[p]]=e[o[p]])}return t};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),"function"==typeof SuppressedError&&SuppressedError,exports.__awaiter=function(e,t,n,r){return new(n||(n=Promise))((function(o,u){function c(e){try{s(r.next(e))}catch(e){u(e)}}function i(e){try{s(r.throw(e))}catch(e){u(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,i)}s((r=r.apply(e,t||[])).next())}))};
@@ -0,0 +1,2 @@
1
+ declare const api: import("axios").AxiosInstance;
2
+ export default api;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("axios"),t=require("../env.js");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e);const o=t.getEnv("API_URL");if(!o)throw new Error("[px/react] API_URL is not defined");const s=t.getEnv("PICKAXE_SESSION_TOKEN");if(!s)throw new Error("[px/react] SESSION_TOKEN is not defined");const i=n.default.create(Object.assign({baseURL:o},t.isDevelopment&&s&&{headers:{"x-pickaxe-session-token":s}}));exports.default=i;
@@ -0,0 +1,7 @@
1
+ interface StreamerOptions {
2
+ formId: string;
3
+ responseId: string;
4
+ data: string;
5
+ }
6
+ export declare const streamer: (payload: StreamerOptions) => Promise<Response>;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const apiUtils: import("axios").AxiosInstance;
2
+ export default apiUtils;
@@ -0,0 +1,3 @@
1
+ import { type ClassValue } from "clsx";
2
+ declare const cn: (...inputs: ClassValue[]) => string;
3
+ export default cn;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("clsx"),r=require("tailwind-merge");exports.default=(...t)=>r.twMerge(e.clsx(t));
@@ -0,0 +1,2 @@
1
+ export declare const getEnv: (key: string) => string | null;
2
+ export declare const isDevelopment: boolean;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>process.env[e]||process.env[`NEXT_PUBLIC_${e}`]||process.env[`VITE_${e}"`]||process.env[`REACT_APP_${e}`]||null,s="development"===e("NODE_ENV");exports.getEnv=e,exports.isDevelopment=s;
@@ -0,0 +1 @@
1
+ export declare const generateId: (length: number, prefix?: string, suffix?: string) => string;
@@ -0,0 +1,6 @@
1
+ export interface PickaxeProps {
2
+ formId: string;
3
+ chatId?: string;
4
+ className?: string;
5
+ }
6
+ export declare const Pickaxe: ({ formId, chatId, className }: PickaxeProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../hooks/usePickaxe.js"),s=require("react"),a=require("../../hooks/usePickaxeContext.js"),r=require("../../common/cn.js");exports.Pickaxe=({formId:c,chatId:i,className:u})=>{const{setFormId:o,setChatId:d,setPickaxe:n}=a.usePickaxeContext(),x=t.usePickaxe();return s.useEffect((()=>{o(c)}),[c]),s.useEffect((()=>{"string"==typeof i&&d(i)}),[i]),s.useEffect((()=>{x.data&&n(x.data)}),[x.data]),e.jsx("div",Object.assign({className:r.default("flex flex-col",u)},{children:x.data?e.jsx("pre",{children:JSON.stringify(x.data,null,2)}):"Loading..."}))};
@@ -0,0 +1,8 @@
1
+ import type { ChatMessage } from "../types/chat";
2
+ interface QueryResponse {
3
+ success: boolean;
4
+ messages: ChatMessage[];
5
+ error?: boolean;
6
+ }
7
+ export declare const useConversation: () => import("@tanstack/react-query/build/legacy/types").UseQueryResult<QueryResponse, Error>;
8
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { PickaxeHistory } from "../types/history";
2
+ import { InfiniteData, UseInfiniteQueryResult } from "@tanstack/react-query";
3
+ type QueryInfiniteResponse = {
4
+ next: number | undefined;
5
+ data: PickaxeHistory[];
6
+ };
7
+ interface UseHistoryQueryProps {
8
+ enabled?: boolean;
9
+ }
10
+ export declare const useHistory: ({ enabled }?: UseHistoryQueryProps) => UseInfiniteQueryResult<InfiniteData<QueryInfiniteResponse, unknown>, Error>;
11
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { Pickaxe } from "../types/pickaxe";
2
+ export type QueryResponse = {
3
+ success: boolean;
4
+ pickaxe: Pickaxe;
5
+ error?: string;
6
+ };
7
+ export declare const usePickaxe: () => import("@tanstack/react-query/build/legacy/types").UseQueryResult<Pickaxe | null, Error>;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),r=require("@tanstack/react-query"),t=require("./usePickaxeContext.js"),i=require("../common/api/index.js");exports.usePickaxe=()=>{const{formId:a}=t.usePickaxeContext();return r.useQuery({queryKey:["form",a],queryFn:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return(r=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!r)return null;const e=yield i.default.get(`/pickaxe?formid=${r}`),t=e.data;if(200!==e.status)throw new Error("[_getPickaxe] Failed to fetch pickaxe "+t);return t.pickaxe})))(a||"")})),enabled:!!a,staleTime:18e4})};
@@ -0,0 +1,16 @@
1
+ export declare const usePickaxeContext: () => {
2
+ formId: string;
3
+ chatId: string;
4
+ pickaxe: import("../types/pickaxe").Pickaxe | null;
5
+ status: import("../types/pickaxe").PickaxeStatus;
6
+ isNewChat: boolean;
7
+ isShowIceBreaker: boolean;
8
+ isShowHistory: boolean;
9
+ setFormId: import("../types/common").SetState<string>;
10
+ setChatId: import("../types/common").SetState<string>;
11
+ setPickaxe: import("../types/common").SetState<import("../types/pickaxe").Pickaxe | null>;
12
+ setStatus: import("../types/common").SetState<import("../types/pickaxe").PickaxeStatus>;
13
+ setIsNewChat: import("../types/common").SetState<boolean>;
14
+ setIsShowIceBreaker: import("../types/common").SetState<boolean>;
15
+ setIsShowHistory: import("../types/common").SetState<boolean>;
16
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("../providers/PickaxeProvider.js");exports.usePickaxeContext=()=>e.useContext(r.PickaxeContext);
@@ -0,0 +1,23 @@
1
+ import type { Pickaxe } from "../types/pickaxe";
2
+ type MutationParams = {
3
+ formId: string;
4
+ responseId?: string;
5
+ documentId?: string;
6
+ pickaxe?: Partial<Pickaxe>;
7
+ value?: string;
8
+ valueObj?: Record<string, string>;
9
+ };
10
+ type MutationResponse = {
11
+ success: boolean;
12
+ data: string;
13
+ responseId: string;
14
+ usedDocumentIds: string[];
15
+ newDocumentId: string;
16
+ newDocumentName: string;
17
+ rawUserInput: string;
18
+ isInsertedFile: boolean;
19
+ isCountedAsOwnerUse: boolean;
20
+ error?: string;
21
+ };
22
+ export declare const useSubmit: () => import("@tanstack/react-query/build/legacy/types").UseMutationResult<MutationResponse, Error, MutationParams, unknown>;
23
+ export {};
@@ -0,0 +1,16 @@
1
+ export declare const useSubmitDocument: () => {
2
+ document: (file: File) => Promise<{
3
+ success: boolean;
4
+ documentid: string;
5
+ error?: string | undefined;
6
+ }>;
7
+ website: (website: string) => Promise<{
8
+ success: boolean;
9
+ numchunks: number;
10
+ pages: number;
11
+ documentid: string;
12
+ name: string;
13
+ call_id: string;
14
+ error?: string | undefined;
15
+ }>;
16
+ };
@@ -0,0 +1,27 @@
1
+ import type { ChatRole } from "../types/chat";
2
+ type MutationParams = {
3
+ formId: string;
4
+ responseId: string;
5
+ documentIds?: string[];
6
+ userId?: string;
7
+ studioId?: string;
8
+ studioUserId?: string;
9
+ messages?: {
10
+ role: ChatRole;
11
+ message: string;
12
+ sentAt: Date;
13
+ }[];
14
+ questions?: {
15
+ id?: string;
16
+ question: string;
17
+ answer: string;
18
+ }[];
19
+ questionPrompt?: string;
20
+ questionResponse?: string;
21
+ };
22
+ type MutationResponse = {
23
+ success: boolean;
24
+ error?: string;
25
+ };
26
+ export declare const useSubmitResult: () => import("@tanstack/react-query/build/legacy/types").UseMutationResult<MutationResponse, Error, MutationParams, unknown>;
27
+ export {};
@@ -1,2 +1 @@
1
- export * from './components/button';
2
- export * from './components/container';
1
+ export * from "./components/Pickaxe";
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./components/button/Button.js"),t=require("./components/container/Container.js");exports.Button=e.Button,exports.Container=t.Container;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./components/Pickaxe/index.js");exports.Pickaxe=e.Pickaxe;
@@ -0,0 +1,25 @@
1
+ import type { SetState } from "../types/common";
2
+ import type { Pickaxe, PickaxeStatus } from "../types/pickaxe";
3
+ import { type ReactNode } from "react";
4
+ type PickaxeContextType = {
5
+ formId: string;
6
+ chatId: string;
7
+ pickaxe: Pickaxe | null;
8
+ status: PickaxeStatus;
9
+ isNewChat: boolean;
10
+ isShowIceBreaker: boolean;
11
+ isShowHistory: boolean;
12
+ setFormId: SetState<string>;
13
+ setChatId: SetState<string>;
14
+ setPickaxe: SetState<Pickaxe | null>;
15
+ setStatus: SetState<PickaxeStatus>;
16
+ setIsNewChat: SetState<boolean>;
17
+ setIsShowIceBreaker: SetState<boolean>;
18
+ setIsShowHistory: SetState<boolean>;
19
+ };
20
+ interface IPickaxeProviderProps {
21
+ children: ReactNode;
22
+ }
23
+ export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
24
+ export declare const PickaxeProvider: ({ children }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
25
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("react/jsx-runtime");const e=require("react").createContext({});exports.PickaxeContext=e;
@@ -0,0 +1,8 @@
1
+ export type ChatRole = "user" | "assistant";
2
+ export type ChatMessage = {
3
+ role: ChatRole;
4
+ content: string;
5
+ };
6
+ export type MemoryStoredChatMessage = {
7
+ id: number;
8
+ } & ChatMessage;
@@ -0,0 +1,2 @@
1
+ import type { Dispatch, SetStateAction } from "react";
2
+ export type SetState<T> = Dispatch<SetStateAction<T>>;
@@ -0,0 +1,37 @@
1
+ import type { MemoryStoredChatMessage } from "./chat";
2
+ import type { PickaxeHistoryQuestion } from "./history";
3
+ export type PickaxeQuestionType = "Short Answer" | "short" | "Long Answer" | "long" | "Multiple Choice" | "multiple" | "Checkbox" | "Knowledge Upload";
4
+ export type CachedPickaxeQuestion = {
5
+ id: string;
6
+ answerlength: string;
7
+ example: string;
8
+ main: string;
9
+ secondary: string;
10
+ type: PickaxeQuestionType;
11
+ isRequired?: boolean;
12
+ isDropdown?: boolean;
13
+ };
14
+ export type MemoryStoredQuestionField = {
15
+ order: number;
16
+ id: string;
17
+ type: PickaxeQuestionType;
18
+ main: string;
19
+ maxLength: number;
20
+ length: number;
21
+ input: string;
22
+ example: string;
23
+ documentId?: string;
24
+ isRequired?: boolean;
25
+ isDropdown?: boolean;
26
+ };
27
+ export type MemoryStoredResponse = {
28
+ formId: string;
29
+ responseId: string;
30
+ documentIds: string[];
31
+ messages: MemoryStoredChatMessage[];
32
+ questions: PickaxeHistoryQuestion[];
33
+ questionPrompt: string;
34
+ questionResponse: string;
35
+ userId?: string;
36
+ createdAt: Date;
37
+ };
@@ -0,0 +1,37 @@
1
+ import type { ChatRole } from "./chat";
2
+ export type PickaxeHistoryType = "chat" | "form";
3
+ export type PickaxeHistoryQuestion = {
4
+ id: string;
5
+ question: string;
6
+ answer: string;
7
+ };
8
+ export type PickaxeHistoryMessage = {
9
+ message: string;
10
+ role: ChatRole;
11
+ sentAt: Date;
12
+ };
13
+ export type PickaxeHistoryChat = {
14
+ type: "chat";
15
+ messages: PickaxeHistoryMessage[];
16
+ };
17
+ export type PickaxeHistoryForm = {
18
+ type: "form";
19
+ questions: PickaxeHistoryQuestion[];
20
+ questionPrompt: string;
21
+ questionResponse: string;
22
+ };
23
+ export type PickaxeHistory = {
24
+ _id: string;
25
+ historyId: string;
26
+ responseId: string;
27
+ formId: string;
28
+ userId?: string;
29
+ studioId?: string;
30
+ studioUserId?: string;
31
+ type: PickaxeHistoryType;
32
+ documentIds: string[];
33
+ clientIPAddress?: string;
34
+ timestamp: number;
35
+ createdAt: Date;
36
+ updatedAt: Date;
37
+ } & (PickaxeHistoryChat | PickaxeHistoryForm);
@@ -0,0 +1,59 @@
1
+ import type { CachedPickaxeQuestion } from "./form";
2
+ export type PickaxeImageOrText = "text" | "image";
3
+ export type PickaxePrivacySetting = "public" | "unlisted" | "private" | "deleted";
4
+ export type PickaxeCloneable = "true" | "false";
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";
7
+ export type Pickaxe = {
8
+ _id: string;
9
+ formid: string;
10
+ adminid: string;
11
+ workspaceid?: string;
12
+ studioid?: string;
13
+ apikey: string;
14
+ category: string;
15
+ coverphoto: string;
16
+ chatflag: boolean;
17
+ chatinputlength: number;
18
+ chaticon: string;
19
+ documentprompt: string;
20
+ documentuploadtype: PickaxeDocumentUploadType;
21
+ embedlink: string;
22
+ enablechatresponses: boolean;
23
+ featured: boolean;
24
+ formdescription: string;
25
+ formtitle: string;
26
+ freqpenalty: number;
27
+ imageortext: PickaxeImageOrText;
28
+ ip_address: string;
29
+ knowledgetokens: number;
30
+ endusertokens?: number;
31
+ maxlength: number;
32
+ membuffer: number;
33
+ model: PickaxeModel;
34
+ owner: string;
35
+ placeholdertext: string;
36
+ prespenalty: number;
37
+ privacysetting: PickaxePrivacySetting;
38
+ public: PickaxeCloneable;
39
+ rawpromptframe?: string;
40
+ relevancethreshold: number;
41
+ responseprefix: string;
42
+ role: string;
43
+ special: string;
44
+ stopwords: string;
45
+ streaming: boolean;
46
+ temperature: number;
47
+ wordbiasless: string;
48
+ wordbiasmore: string;
49
+ icebreakers: string[];
50
+ submittext?: string;
51
+ previewimage?: string;
52
+ linked: boolean;
53
+ usestoday: number;
54
+ usestotal: number;
55
+ useslimit: number;
56
+ timestamp: number;
57
+ _questions?: CachedPickaxeQuestion[];
58
+ };
59
+ export type PickaxeStatus = "fetching" | "streaming" | "idle";
@@ -1 +1 @@
1
- function r(r,e){var t={};for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&e.indexOf(o)<0&&(t[o]=r[o]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(r);n<o.length;n++)e.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(r,o[n])&&(t[o[n]]=r[o[n]])}return t}"function"==typeof SuppressedError&&SuppressedError;export{r as __rest};
1
+ function n(n,t,e,r){return new(e||(e=Promise))((function(o,c){function u(n){try{i(r.next(n))}catch(n){c(n)}}function f(n){try{i(r.throw(n))}catch(n){c(n)}}function i(n){var t;n.done?o(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(u,f)}i((r=r.apply(n,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;export{n as __awaiter};
@@ -0,0 +1,2 @@
1
+ declare const api: import("axios").AxiosInstance;
2
+ export default api;
@@ -0,0 +1 @@
1
+ import e from"axios";import{getEnv as o,isDevelopment as r}from"../env.js";const t=o("API_URL");if(!t)throw new Error("[px/react] API_URL is not defined");const s=o("PICKAXE_SESSION_TOKEN");if(!s)throw new Error("[px/react] SESSION_TOKEN is not defined");const n=e.create(Object.assign({baseURL:t},r&&s&&{headers:{"x-pickaxe-session-token":s}}));export{n as default};
@@ -0,0 +1,7 @@
1
+ interface StreamerOptions {
2
+ formId: string;
3
+ responseId: string;
4
+ data: string;
5
+ }
6
+ export declare const streamer: (payload: StreamerOptions) => Promise<Response>;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const apiUtils: import("axios").AxiosInstance;
2
+ export default apiUtils;
@@ -0,0 +1,3 @@
1
+ import { type ClassValue } from "clsx";
2
+ declare const cn: (...inputs: ClassValue[]) => string;
3
+ export default cn;
@@ -0,0 +1 @@
1
+ import{clsx as o}from"clsx";import{twMerge as r}from"tailwind-merge";const t=(...t)=>r(o(t));export{t as default};
@@ -0,0 +1,2 @@
1
+ export declare const getEnv: (key: string) => string | null;
2
+ export declare const isDevelopment: boolean;
@@ -0,0 +1 @@
1
+ const e=e=>process.env[e]||process.env[`NEXT_PUBLIC_${e}`]||process.env[`VITE_${e}"`]||process.env[`REACT_APP_${e}`]||null,s="development"===e("NODE_ENV");export{e as getEnv,s as isDevelopment};
@@ -0,0 +1 @@
1
+ export declare const generateId: (length: number, prefix?: string, suffix?: string) => string;
@@ -0,0 +1,6 @@
1
+ export interface PickaxeProps {
2
+ formId: string;
3
+ chatId?: string;
4
+ className?: string;
5
+ }
6
+ export declare const Pickaxe: ({ formId, chatId, className }: PickaxeProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ import{jsx as t}from"react/jsx-runtime";import{usePickaxe as o}from"../../hooks/usePickaxe.js";import{useEffect as a}from"react";import{usePickaxeContext as e}from"../../hooks/usePickaxeContext.js";import r from"../../common/cn.js";const s=({formId:s,chatId:i,className:m})=>{const{setFormId:c,setChatId:n,setPickaxe:d}=e(),f=o();return a((()=>{c(s)}),[s]),a((()=>{"string"==typeof i&&n(i)}),[i]),a((()=>{f.data&&d(f.data)}),[f.data]),t("div",Object.assign({className:r("flex flex-col",m)},{children:f.data?t("pre",{children:JSON.stringify(f.data,null,2)}):"Loading..."}))};export{s as Pickaxe};
@@ -0,0 +1,8 @@
1
+ import type { ChatMessage } from "../types/chat";
2
+ interface QueryResponse {
3
+ success: boolean;
4
+ messages: ChatMessage[];
5
+ error?: boolean;
6
+ }
7
+ export declare const useConversation: () => import("@tanstack/react-query/build/legacy/types").UseQueryResult<QueryResponse, Error>;
8
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { PickaxeHistory } from "../types/history";
2
+ import { InfiniteData, UseInfiniteQueryResult } from "@tanstack/react-query";
3
+ type QueryInfiniteResponse = {
4
+ next: number | undefined;
5
+ data: PickaxeHistory[];
6
+ };
7
+ interface UseHistoryQueryProps {
8
+ enabled?: boolean;
9
+ }
10
+ export declare const useHistory: ({ enabled }?: UseHistoryQueryProps) => UseInfiniteQueryResult<InfiniteData<QueryInfiniteResponse, unknown>, Error>;
11
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { Pickaxe } from "../types/pickaxe";
2
+ export type QueryResponse = {
3
+ success: boolean;
4
+ pickaxe: Pickaxe;
5
+ error?: string;
6
+ };
7
+ export declare const usePickaxe: () => import("@tanstack/react-query/build/legacy/types").UseQueryResult<Pickaxe | null, Error>;
@@ -0,0 +1 @@
1
+ import{__awaiter as t}from"../_virtual/_tslib.js";import{useQuery as e}from"@tanstack/react-query";import{usePickaxeContext as o}from"./usePickaxeContext.js";import r from"../common/api/index.js";const i=()=>{const{formId:i}=o();return e({queryKey:["form",i],queryFn:()=>t(void 0,void 0,void 0,(function*(){return(e=>t(void 0,void 0,void 0,(function*(){if(!e)return null;const t=yield r.get(`/pickaxe?formid=${e}`),o=t.data;if(200!==t.status)throw new Error("[_getPickaxe] Failed to fetch pickaxe "+o);return o.pickaxe})))(i||"")})),enabled:!!i,staleTime:18e4})};export{i as usePickaxe};
@@ -0,0 +1,16 @@
1
+ export declare const usePickaxeContext: () => {
2
+ formId: string;
3
+ chatId: string;
4
+ pickaxe: import("../types/pickaxe").Pickaxe | null;
5
+ status: import("../types/pickaxe").PickaxeStatus;
6
+ isNewChat: boolean;
7
+ isShowIceBreaker: boolean;
8
+ isShowHistory: boolean;
9
+ setFormId: import("../types/common").SetState<string>;
10
+ setChatId: import("../types/common").SetState<string>;
11
+ setPickaxe: import("../types/common").SetState<import("../types/pickaxe").Pickaxe | null>;
12
+ setStatus: import("../types/common").SetState<import("../types/pickaxe").PickaxeStatus>;
13
+ setIsNewChat: import("../types/common").SetState<boolean>;
14
+ setIsShowIceBreaker: import("../types/common").SetState<boolean>;
15
+ setIsShowHistory: import("../types/common").SetState<boolean>;
16
+ };
@@ -0,0 +1 @@
1
+ import{useContext as r}from"react";import{PickaxeContext as o}from"../providers/PickaxeProvider.js";const e=()=>r(o);export{e as usePickaxeContext};
@@ -0,0 +1,23 @@
1
+ import type { Pickaxe } from "../types/pickaxe";
2
+ type MutationParams = {
3
+ formId: string;
4
+ responseId?: string;
5
+ documentId?: string;
6
+ pickaxe?: Partial<Pickaxe>;
7
+ value?: string;
8
+ valueObj?: Record<string, string>;
9
+ };
10
+ type MutationResponse = {
11
+ success: boolean;
12
+ data: string;
13
+ responseId: string;
14
+ usedDocumentIds: string[];
15
+ newDocumentId: string;
16
+ newDocumentName: string;
17
+ rawUserInput: string;
18
+ isInsertedFile: boolean;
19
+ isCountedAsOwnerUse: boolean;
20
+ error?: string;
21
+ };
22
+ export declare const useSubmit: () => import("@tanstack/react-query/build/legacy/types").UseMutationResult<MutationResponse, Error, MutationParams, unknown>;
23
+ export {};
@@ -0,0 +1,16 @@
1
+ export declare const useSubmitDocument: () => {
2
+ document: (file: File) => Promise<{
3
+ success: boolean;
4
+ documentid: string;
5
+ error?: string | undefined;
6
+ }>;
7
+ website: (website: string) => Promise<{
8
+ success: boolean;
9
+ numchunks: number;
10
+ pages: number;
11
+ documentid: string;
12
+ name: string;
13
+ call_id: string;
14
+ error?: string | undefined;
15
+ }>;
16
+ };
@@ -0,0 +1,27 @@
1
+ import type { ChatRole } from "../types/chat";
2
+ type MutationParams = {
3
+ formId: string;
4
+ responseId: string;
5
+ documentIds?: string[];
6
+ userId?: string;
7
+ studioId?: string;
8
+ studioUserId?: string;
9
+ messages?: {
10
+ role: ChatRole;
11
+ message: string;
12
+ sentAt: Date;
13
+ }[];
14
+ questions?: {
15
+ id?: string;
16
+ question: string;
17
+ answer: string;
18
+ }[];
19
+ questionPrompt?: string;
20
+ questionResponse?: string;
21
+ };
22
+ type MutationResponse = {
23
+ success: boolean;
24
+ error?: string;
25
+ };
26
+ export declare const useSubmitResult: () => import("@tanstack/react-query/build/legacy/types").UseMutationResult<MutationResponse, Error, MutationParams, unknown>;
27
+ export {};
@@ -1,2 +1 @@
1
- export * from './components/button';
2
- export * from './components/container';
1
+ export * from "./components/Pickaxe";
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export{Button}from"./components/button/Button.js";export{Container}from"./components/container/Container.js";
1
+ export{Pickaxe}from"./components/Pickaxe/index.js";
@@ -0,0 +1,25 @@
1
+ import type { SetState } from "../types/common";
2
+ import type { Pickaxe, PickaxeStatus } from "../types/pickaxe";
3
+ import { type ReactNode } from "react";
4
+ type PickaxeContextType = {
5
+ formId: string;
6
+ chatId: string;
7
+ pickaxe: Pickaxe | null;
8
+ status: PickaxeStatus;
9
+ isNewChat: boolean;
10
+ isShowIceBreaker: boolean;
11
+ isShowHistory: boolean;
12
+ setFormId: SetState<string>;
13
+ setChatId: SetState<string>;
14
+ setPickaxe: SetState<Pickaxe | null>;
15
+ setStatus: SetState<PickaxeStatus>;
16
+ setIsNewChat: SetState<boolean>;
17
+ setIsShowIceBreaker: SetState<boolean>;
18
+ setIsShowHistory: SetState<boolean>;
19
+ };
20
+ interface IPickaxeProviderProps {
21
+ children: ReactNode;
22
+ }
23
+ export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
24
+ export declare const PickaxeProvider: ({ children }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
25
+ export {};
@@ -0,0 +1 @@
1
+ import"react/jsx-runtime";import{createContext as r}from"react";const t=r({});export{t as PickaxeContext};
@@ -0,0 +1,8 @@
1
+ export type ChatRole = "user" | "assistant";
2
+ export type ChatMessage = {
3
+ role: ChatRole;
4
+ content: string;
5
+ };
6
+ export type MemoryStoredChatMessage = {
7
+ id: number;
8
+ } & ChatMessage;
@@ -0,0 +1,2 @@
1
+ import type { Dispatch, SetStateAction } from "react";
2
+ export type SetState<T> = Dispatch<SetStateAction<T>>;
@@ -0,0 +1,37 @@
1
+ import type { MemoryStoredChatMessage } from "./chat";
2
+ import type { PickaxeHistoryQuestion } from "./history";
3
+ export type PickaxeQuestionType = "Short Answer" | "short" | "Long Answer" | "long" | "Multiple Choice" | "multiple" | "Checkbox" | "Knowledge Upload";
4
+ export type CachedPickaxeQuestion = {
5
+ id: string;
6
+ answerlength: string;
7
+ example: string;
8
+ main: string;
9
+ secondary: string;
10
+ type: PickaxeQuestionType;
11
+ isRequired?: boolean;
12
+ isDropdown?: boolean;
13
+ };
14
+ export type MemoryStoredQuestionField = {
15
+ order: number;
16
+ id: string;
17
+ type: PickaxeQuestionType;
18
+ main: string;
19
+ maxLength: number;
20
+ length: number;
21
+ input: string;
22
+ example: string;
23
+ documentId?: string;
24
+ isRequired?: boolean;
25
+ isDropdown?: boolean;
26
+ };
27
+ export type MemoryStoredResponse = {
28
+ formId: string;
29
+ responseId: string;
30
+ documentIds: string[];
31
+ messages: MemoryStoredChatMessage[];
32
+ questions: PickaxeHistoryQuestion[];
33
+ questionPrompt: string;
34
+ questionResponse: string;
35
+ userId?: string;
36
+ createdAt: Date;
37
+ };
@@ -0,0 +1,37 @@
1
+ import type { ChatRole } from "./chat";
2
+ export type PickaxeHistoryType = "chat" | "form";
3
+ export type PickaxeHistoryQuestion = {
4
+ id: string;
5
+ question: string;
6
+ answer: string;
7
+ };
8
+ export type PickaxeHistoryMessage = {
9
+ message: string;
10
+ role: ChatRole;
11
+ sentAt: Date;
12
+ };
13
+ export type PickaxeHistoryChat = {
14
+ type: "chat";
15
+ messages: PickaxeHistoryMessage[];
16
+ };
17
+ export type PickaxeHistoryForm = {
18
+ type: "form";
19
+ questions: PickaxeHistoryQuestion[];
20
+ questionPrompt: string;
21
+ questionResponse: string;
22
+ };
23
+ export type PickaxeHistory = {
24
+ _id: string;
25
+ historyId: string;
26
+ responseId: string;
27
+ formId: string;
28
+ userId?: string;
29
+ studioId?: string;
30
+ studioUserId?: string;
31
+ type: PickaxeHistoryType;
32
+ documentIds: string[];
33
+ clientIPAddress?: string;
34
+ timestamp: number;
35
+ createdAt: Date;
36
+ updatedAt: Date;
37
+ } & (PickaxeHistoryChat | PickaxeHistoryForm);
@@ -0,0 +1,59 @@
1
+ import type { CachedPickaxeQuestion } from "./form";
2
+ export type PickaxeImageOrText = "text" | "image";
3
+ export type PickaxePrivacySetting = "public" | "unlisted" | "private" | "deleted";
4
+ export type PickaxeCloneable = "true" | "false";
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";
7
+ export type Pickaxe = {
8
+ _id: string;
9
+ formid: string;
10
+ adminid: string;
11
+ workspaceid?: string;
12
+ studioid?: string;
13
+ apikey: string;
14
+ category: string;
15
+ coverphoto: string;
16
+ chatflag: boolean;
17
+ chatinputlength: number;
18
+ chaticon: string;
19
+ documentprompt: string;
20
+ documentuploadtype: PickaxeDocumentUploadType;
21
+ embedlink: string;
22
+ enablechatresponses: boolean;
23
+ featured: boolean;
24
+ formdescription: string;
25
+ formtitle: string;
26
+ freqpenalty: number;
27
+ imageortext: PickaxeImageOrText;
28
+ ip_address: string;
29
+ knowledgetokens: number;
30
+ endusertokens?: number;
31
+ maxlength: number;
32
+ membuffer: number;
33
+ model: PickaxeModel;
34
+ owner: string;
35
+ placeholdertext: string;
36
+ prespenalty: number;
37
+ privacysetting: PickaxePrivacySetting;
38
+ public: PickaxeCloneable;
39
+ rawpromptframe?: string;
40
+ relevancethreshold: number;
41
+ responseprefix: string;
42
+ role: string;
43
+ special: string;
44
+ stopwords: string;
45
+ streaming: boolean;
46
+ temperature: number;
47
+ wordbiasless: string;
48
+ wordbiasmore: string;
49
+ icebreakers: string[];
50
+ submittext?: string;
51
+ previewimage?: string;
52
+ linked: boolean;
53
+ usestoday: number;
54
+ usestotal: number;
55
+ useslimit: number;
56
+ timestamp: number;
57
+ _questions?: CachedPickaxeQuestion[];
58
+ };
59
+ export type PickaxeStatus = "fetching" | "streaming" | "idle";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "0.0.0",
3
+ "version": "0.0.2",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,18 +42,23 @@
42
42
  "@babel/preset-env": "^7.20.2",
43
43
  "@babel/preset-react": "^7.18.6",
44
44
  "@changesets/cli": "^2.26.0",
45
- "@mdx-js/react": "^1.6.22",
46
45
  "@rollup/plugin-babel": "^6.0.3",
47
46
  "@rollup/plugin-commonjs": "^24.0.0",
48
47
  "@rollup/plugin-node-resolve": "^15.0.1",
49
48
  "@rollup/plugin-terser": "^0.3.0",
49
+ "@tailwindcss/container-queries": "^0.1.1",
50
+ "@tanstack/react-query": "^5.63.0",
50
51
  "@types/node": "^18.11.18",
51
52
  "@types/react": "^18.0.26",
52
53
  "@types/react-dom": "^18.0.10",
53
54
  "@typescript-eslint/eslint-plugin": "^5.48.1",
54
55
  "@typescript-eslint/parser": "^5.48.1",
55
56
  "@zerollup/ts-transform-paths": "^1.7.18",
57
+ "autoprefixer": "^10.4.20",
58
+ "axios": "^1.7.9",
56
59
  "babel-loader": "^9.1.2",
60
+ "clsx": "^2.1.1",
61
+ "cross-env": "^7.0.3",
57
62
  "eslint": "8.31.0",
58
63
  "eslint-config-prettier": "^8.6.0",
59
64
  "eslint-plugin-jsx-a11y": "^6.7.1",
@@ -62,6 +67,7 @@
62
67
  "eslint-plugin-react-hooks": "^4.6.0",
63
68
  "husky": "^8.0.3",
64
69
  "lint-staged": "^13.1.0",
70
+ "postcss": "^8.4.49",
65
71
  "prettier": "^2.8.2",
66
72
  "react": "^18.2.0",
67
73
  "react-dom": "^18.2.0",
@@ -69,6 +75,9 @@
69
75
  "rollup-plugin-delete": "^2.0.0",
70
76
  "rollup-plugin-peer-deps-external": "^2.2.4",
71
77
  "rollup-plugin-typescript2": "^0.34.1",
78
+ "tailwind-merge": "^2.6.0",
79
+ "tailwind-scrollbar": "^3.1.0",
80
+ "tailwindcss": "^3.4.17",
72
81
  "tslib": "^2.4.1",
73
82
  "ttypescript": "^1.5.15",
74
83
  "typescript": "^4.9.4",
@@ -77,16 +86,23 @@
77
86
  "webpack-cli": "^5.0.1"
78
87
  },
79
88
  "peerDependencies": {
89
+ "@tailwindcss/container-queries": "^0.1.1",
90
+ "@tanstack/react-query": "^5.63.0",
91
+ "axios": "^1.7.9",
92
+ "clsx": "^2.1.1",
80
93
  "react": "^16.8.0 || ^17 || ^18",
81
- "react-dom": "^16.8.0 || ^17 || ^18"
94
+ "react-dom": "^16.8.0 || ^17 || ^18",
95
+ "tailwind-merge": "^2.6.0",
96
+ "tailwind-scrollbar": "^3.1.0"
82
97
  },
83
98
  "engines": {
84
99
  "node": ">=18"
85
100
  },
86
101
  "scripts": {
87
- "build": "NODE_ENV=production rollup -c",
102
+ "build": "cross-env NODE_ENV=production rollup -c",
88
103
  "lint": "eslint . --ext .ts,.tsx,.js,.jsx",
89
104
  "changeset": "changeset",
90
- "release": "changeset publish"
105
+ "release": "changeset publish",
106
+ "format": "prettier --write ."
91
107
  }
92
108
  }
@@ -1,5 +0,0 @@
1
- import { type ButtonHTMLAttributes } from "react";
2
- export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
3
- test: string;
4
- }
5
- export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),r=require("react/jsx-runtime");const t=require("react").forwardRef(((t,s)=>{var{children:i}=t,u=e.__rest(t,["children"]);return r.jsx("button",Object.assign({ref:s},u,{children:i}))}));t.displayName="Button",exports.Button=t;
@@ -1 +0,0 @@
1
- export * from './Button';
@@ -1,5 +0,0 @@
1
- import type { HTMLAttributes } from "react";
2
- export interface ContainerProps extends HTMLAttributes<HTMLDivElement> {
3
- test: string;
4
- }
5
- export declare const Container: ({ children, ...props }: ContainerProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),r=require("react/jsx-runtime");exports.Container=t=>{var{children:i}=t,s=e.__rest(t,["children"]);return r.jsx("div",Object.assign({},s,{children:i}))};
@@ -1 +0,0 @@
1
- export * from './Container';
@@ -1,2 +0,0 @@
1
- export declare const BLACK = "#000000";
2
- export declare const WHITE = "#ffffff";
@@ -1,7 +0,0 @@
1
- /**
2
- * Conditionally joining classNames together.
3
- *
4
- * @param names list names that need to be concat.
5
- * @returns a concat classNames string.
6
- */
7
- export declare const classNames: (...names: (string | undefined)[]) => string;
@@ -1,5 +0,0 @@
1
- import { type ButtonHTMLAttributes } from "react";
2
- export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
3
- test: string;
4
- }
5
- export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -1 +0,0 @@
1
- import{__rest as r}from"../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import{forwardRef as e}from"react";const i=e(((e,i)=>{var{children:o}=e,n=r(e,["children"]);return t("button",Object.assign({ref:i},n,{children:o}))}));i.displayName="Button";export{i as Button};
@@ -1 +0,0 @@
1
- export * from './Button';
@@ -1,5 +0,0 @@
1
- import type { HTMLAttributes } from "react";
2
- export interface ContainerProps extends HTMLAttributes<HTMLDivElement> {
3
- test: string;
4
- }
5
- export declare const Container: ({ children, ...props }: ContainerProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- import{__rest as r}from"../../_virtual/_tslib.js";import{jsx as i}from"react/jsx-runtime";const t=t=>{var{children:e}=t,n=r(t,["children"]);return i("div",Object.assign({},n,{children:e}))};export{t as Container};
@@ -1 +0,0 @@
1
- export * from './Container';
@@ -1,2 +0,0 @@
1
- export declare const BLACK = "#000000";
2
- export declare const WHITE = "#ffffff";
@@ -1,7 +0,0 @@
1
- /**
2
- * Conditionally joining classNames together.
3
- *
4
- * @param names list names that need to be concat.
5
- * @returns a concat classNames string.
6
- */
7
- export declare const classNames: (...names: (string | undefined)[]) => string;