@pickaxeproject/react 0.0.1 → 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.
- package/README.md +6 -0
- package/dist/cjs/_virtual/_tslib.js +1 -0
- package/dist/cjs/common/api/index.d.ts +2 -0
- package/dist/cjs/common/api/index.js +1 -0
- package/dist/cjs/common/api/streamer.d.ts +7 -0
- package/dist/cjs/common/api/utils.d.ts +2 -0
- package/dist/cjs/common/cn.js +1 -0
- package/dist/cjs/common/env.d.ts +2 -0
- package/dist/cjs/common/env.js +1 -0
- package/dist/cjs/common/utils.d.ts +1 -0
- package/dist/cjs/components/Pickaxe/index.d.ts +4 -2
- package/dist/cjs/components/Pickaxe/index.js +1 -1
- package/dist/cjs/hooks/useConversation.d.ts +8 -0
- package/dist/cjs/hooks/useHistory.d.ts +11 -0
- package/dist/cjs/hooks/usePickaxe.d.ts +7 -0
- package/dist/cjs/hooks/usePickaxe.js +1 -0
- package/dist/cjs/hooks/usePickaxeContext.d.ts +16 -0
- package/dist/cjs/hooks/usePickaxeContext.js +1 -0
- package/dist/cjs/hooks/useSubmit.d.ts +23 -0
- package/dist/cjs/hooks/useSubmitDocument.d.ts +16 -0
- package/dist/cjs/hooks/useSubmitResult.d.ts +27 -0
- package/dist/cjs/providers/PickaxeProvider.d.ts +25 -0
- package/dist/cjs/providers/PickaxeProvider.js +1 -0
- package/dist/cjs/types/chat.d.ts +8 -0
- package/dist/cjs/types/common.d.ts +2 -0
- package/dist/cjs/types/form.d.ts +37 -0
- package/dist/cjs/types/history.d.ts +37 -0
- package/dist/cjs/types/pickaxe.d.ts +59 -0
- package/dist/esm/_virtual/_tslib.js +1 -0
- package/dist/esm/common/api/index.d.ts +2 -0
- package/dist/esm/common/api/index.js +1 -0
- package/dist/esm/common/api/streamer.d.ts +7 -0
- package/dist/esm/common/api/utils.d.ts +2 -0
- package/dist/esm/common/cn.js +1 -0
- package/dist/esm/common/env.d.ts +2 -0
- package/dist/esm/common/env.js +1 -0
- package/dist/esm/common/utils.d.ts +1 -0
- package/dist/esm/components/Pickaxe/index.d.ts +4 -2
- package/dist/esm/components/Pickaxe/index.js +1 -1
- package/dist/esm/hooks/useConversation.d.ts +8 -0
- package/dist/esm/hooks/useHistory.d.ts +11 -0
- package/dist/esm/hooks/usePickaxe.d.ts +7 -0
- package/dist/esm/hooks/usePickaxe.js +1 -0
- package/dist/esm/hooks/usePickaxeContext.d.ts +16 -0
- package/dist/esm/hooks/usePickaxeContext.js +1 -0
- package/dist/esm/hooks/useSubmit.d.ts +23 -0
- package/dist/esm/hooks/useSubmitDocument.d.ts +16 -0
- package/dist/esm/hooks/useSubmitResult.d.ts +27 -0
- package/dist/esm/providers/PickaxeProvider.d.ts +25 -0
- package/dist/esm/providers/PickaxeProvider.js +1 -0
- package/dist/esm/types/chat.d.ts +8 -0
- package/dist/esm/types/common.d.ts +2 -0
- package/dist/esm/types/form.d.ts +37 -0
- package/dist/esm/types/history.d.ts +37 -0
- package/dist/esm/types/pickaxe.d.ts +59 -0
- package/package.json +7 -2
- /package/dist/cjs/{utils → common}/cn.d.ts +0 -0
- /package/dist/esm/{utils → common}/cn.d.ts +0 -0
package/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export interface PickaxeProps {
|
|
2
|
-
|
|
2
|
+
formId: string;
|
|
3
|
+
chatId?: string;
|
|
4
|
+
className?: string;
|
|
3
5
|
}
|
|
4
|
-
export declare const Pickaxe: ({
|
|
6
|
+
export declare const Pickaxe: ({ formId, chatId, className }: PickaxeProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");exports.Pickaxe=({
|
|
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 {};
|
|
@@ -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,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";
|
|
@@ -0,0 +1 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export interface PickaxeProps {
|
|
2
|
-
|
|
2
|
+
formId: string;
|
|
3
|
+
chatId?: string;
|
|
4
|
+
className?: string;
|
|
3
5
|
}
|
|
4
|
-
export declare const Pickaxe: ({
|
|
6
|
+
export declare const Pickaxe: ({ formId, chatId, className }: PickaxeProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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 {};
|
|
@@ -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,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.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Client utility library for Pickaxe",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
48
48
|
"@rollup/plugin-terser": "^0.3.0",
|
|
49
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",
|
|
@@ -54,8 +55,10 @@
|
|
|
54
55
|
"@typescript-eslint/parser": "^5.48.1",
|
|
55
56
|
"@zerollup/ts-transform-paths": "^1.7.18",
|
|
56
57
|
"autoprefixer": "^10.4.20",
|
|
58
|
+
"axios": "^1.7.9",
|
|
57
59
|
"babel-loader": "^9.1.2",
|
|
58
60
|
"clsx": "^2.1.1",
|
|
61
|
+
"cross-env": "^7.0.3",
|
|
59
62
|
"eslint": "8.31.0",
|
|
60
63
|
"eslint-config-prettier": "^8.6.0",
|
|
61
64
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
@@ -84,6 +87,8 @@
|
|
|
84
87
|
},
|
|
85
88
|
"peerDependencies": {
|
|
86
89
|
"@tailwindcss/container-queries": "^0.1.1",
|
|
90
|
+
"@tanstack/react-query": "^5.63.0",
|
|
91
|
+
"axios": "^1.7.9",
|
|
87
92
|
"clsx": "^2.1.1",
|
|
88
93
|
"react": "^16.8.0 || ^17 || ^18",
|
|
89
94
|
"react-dom": "^16.8.0 || ^17 || ^18",
|
|
@@ -94,7 +99,7 @@
|
|
|
94
99
|
"node": ">=18"
|
|
95
100
|
},
|
|
96
101
|
"scripts": {
|
|
97
|
-
"build": "NODE_ENV=production rollup -c",
|
|
102
|
+
"build": "cross-env NODE_ENV=production rollup -c",
|
|
98
103
|
"lint": "eslint . --ext .ts,.tsx,.js,.jsx",
|
|
99
104
|
"changeset": "changeset",
|
|
100
105
|
"release": "changeset publish",
|
|
File without changes
|
|
File without changes
|