@peam-ai/client 0.1.3 → 0.1.5
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.d.mts +133 -72
- package/dist/index.d.ts +133 -72
- package/dist/index.js +13 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +36 -29
package/dist/index.d.mts
CHANGED
|
@@ -1,87 +1,148 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
import * as
|
|
4
|
-
import {
|
|
5
|
-
import { UIMessage } from '@ai-sdk/react';
|
|
2
|
+
import { HttpChatTransport, UIMessage, FileUIPart, ChatStatus, DefaultChatTransport } from 'ai';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ReactNode, ComponentPropsWithoutRef } from 'react';
|
|
5
|
+
import { UIMessage as UIMessage$1 } from '@ai-sdk/react';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
interface AskAIDialogProps extends AskAIBaseProps {
|
|
12
|
-
}
|
|
13
|
-
declare function AskAIDialog({ suggestedPrompts, button, maxMessages }?: AskAIDialogProps): react_jsx_runtime.JSX.Element;
|
|
14
|
-
|
|
15
|
-
interface AskAISidepaneProps extends AskAIBaseProps {
|
|
16
|
-
}
|
|
17
|
-
declare function AskAISidepane({ suggestedPrompts, button, maxMessages }?: AskAISidepaneProps): react_jsx_runtime.JSX.Element;
|
|
7
|
+
type ChatPersistenceConfig = boolean | {
|
|
8
|
+
key?: string;
|
|
9
|
+
};
|
|
18
10
|
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
interface AskAIRootProps {
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* API endpoint for handling AI requests.
|
|
15
|
+
* @default '/api/peam'
|
|
16
|
+
*/
|
|
17
|
+
endpoint?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Controlled open state.
|
|
20
|
+
*/
|
|
21
|
+
open?: boolean;
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* Uncontrolled initial open state.
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
defaultOpen?: boolean;
|
|
25
26
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @default 10
|
|
27
|
+
* Override the default chat transport.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
chatTransport?: HttpChatTransport<UIMessage>;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```tsx
|
|
35
|
-
* <AskAI
|
|
36
|
-
* type="dialog"
|
|
37
|
-
* button={({ isOpen, toggle, open, close }) => (
|
|
38
|
-
* <button onClick={toggle}>
|
|
39
|
-
* {isOpen ? 'Close' : 'Open'} AI
|
|
40
|
-
* </button>
|
|
41
|
-
* )}
|
|
42
|
-
* />
|
|
43
|
-
* ```
|
|
31
|
+
* Configure chat persistence.
|
|
32
|
+
* @default true
|
|
44
33
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
34
|
+
persistence?: ChatPersistenceConfig;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type AskAIProviderProps = AskAIRootProps;
|
|
38
|
+
declare function AskAIProvider(props: AskAIRootProps): react_jsx_runtime.JSX.Element;
|
|
39
|
+
|
|
40
|
+
type PeamButtonVariant = 'icon' | 'iconLabel';
|
|
41
|
+
|
|
42
|
+
interface AskAITriggerProps extends ComponentPropsWithoutRef<'button'> {
|
|
43
|
+
asChild?: boolean;
|
|
44
|
+
children?: ReactNode;
|
|
45
|
+
inlineButton?: boolean;
|
|
46
|
+
variant?: PeamButtonVariant;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type AskAIProps = AskAIRootProps & {
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* When true, reuses an existing {@link AskAIContext} if present.
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
reuseContext?: boolean;
|
|
56
|
+
} & ComponentPropsWithoutRef<'div'>;
|
|
57
|
+
declare function AskAI$1({ children, className, reuseContext, endpoint, open, defaultOpen, chatTransport, persistence, ...divProps }: AskAIProps): react_jsx_runtime.JSX.Element;
|
|
58
|
+
|
|
59
|
+
interface AskAIChatProps extends ComponentPropsWithoutRef<'div'> {
|
|
60
|
+
children?: ReactNode;
|
|
51
61
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
declare function AskAIChat({ children, className, ...props }: AskAIChatProps): react_jsx_runtime.JSX.Element | null;
|
|
63
|
+
|
|
64
|
+
interface AskAIDialogProps extends ComponentPropsWithoutRef<'div'> {
|
|
65
|
+
children?: ReactNode;
|
|
66
|
+
}
|
|
67
|
+
declare function AskAIDialog({ children, className, ...props }: AskAIDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
68
|
+
|
|
69
|
+
interface AskAIHeaderProps extends ComponentPropsWithoutRef<'div'> {
|
|
70
|
+
heading?: ReactNode;
|
|
71
|
+
closeLabel?: string;
|
|
72
|
+
}
|
|
73
|
+
declare function AskAIHeader({ heading, closeLabel, ...props }: AskAIHeaderProps): react_jsx_runtime.JSX.Element;
|
|
74
|
+
|
|
75
|
+
type AskAIInlineProps = ComponentPropsWithoutRef<'div'>;
|
|
76
|
+
declare function AskAIInline({ className, ...props }: AskAIInlineProps): react_jsx_runtime.JSX.Element;
|
|
77
|
+
|
|
78
|
+
type AskAIInputProps = ComponentPropsWithoutRef<'div'>;
|
|
79
|
+
declare function AskAIInput({ className, ...props }: AskAIInputProps): react_jsx_runtime.JSX.Element;
|
|
80
|
+
|
|
81
|
+
type AskAIMessagesProps = ComponentPropsWithoutRef<'div'>;
|
|
82
|
+
declare function AskAIMessages({ className, ...props }: AskAIMessagesProps): react_jsx_runtime.JSX.Element;
|
|
83
|
+
|
|
84
|
+
interface AskAISidepaneProps extends ComponentPropsWithoutRef<'div'> {
|
|
85
|
+
children?: ReactNode;
|
|
86
|
+
}
|
|
87
|
+
declare function AskAISidepane({ children, className, ...props }: AskAISidepaneProps): react_jsx_runtime.JSX.Element | null;
|
|
88
|
+
|
|
89
|
+
interface AskAISuggestionsProps extends ComponentPropsWithoutRef<'div'> {
|
|
90
|
+
prompts?: string[];
|
|
91
|
+
onPromptClick?: (prompt: string) => void;
|
|
92
|
+
onlyWhenEmpty?: boolean;
|
|
93
|
+
}
|
|
94
|
+
declare function AskAISuggestions({ prompts, onPromptClick, onlyWhenEmpty, className, ...props }: AskAISuggestionsProps): react_jsx_runtime.JSX.Element | null;
|
|
95
|
+
|
|
96
|
+
declare const AskAI: typeof AskAI$1 & {
|
|
97
|
+
Trigger: React.ForwardRefExoticComponent<AskAITriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
98
|
+
Header: typeof AskAIHeader;
|
|
99
|
+
Dialog: typeof AskAIDialog;
|
|
100
|
+
Chat: typeof AskAIChat;
|
|
101
|
+
Sidepane: typeof AskAISidepane;
|
|
102
|
+
Inline: typeof AskAIInline;
|
|
103
|
+
Messages: typeof AskAIMessages;
|
|
104
|
+
Suggestions: typeof AskAISuggestions;
|
|
105
|
+
Input: typeof AskAIInput;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
interface PromptInputMessage {
|
|
109
|
+
text: string;
|
|
110
|
+
files: FileUIPart[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface AskAIContextValue {
|
|
114
|
+
open: boolean;
|
|
115
|
+
setOpen: (open: boolean) => void;
|
|
116
|
+
toggleOpen: () => void;
|
|
117
|
+
input: string;
|
|
118
|
+
setInput: (value: string, options?: AskAIActionOptions) => void;
|
|
119
|
+
messages: UIMessage[];
|
|
120
|
+
status: ChatStatus;
|
|
121
|
+
error: Error | undefined;
|
|
70
122
|
isLoading: boolean;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
123
|
+
sendMessage: (message: {
|
|
124
|
+
text: string;
|
|
125
|
+
}, options?: AskAIActionOptions) => void;
|
|
126
|
+
handleSubmit: (message: PromptInputMessage) => void;
|
|
127
|
+
regenerate: (options?: {
|
|
128
|
+
messageId?: string;
|
|
129
|
+
}) => void;
|
|
130
|
+
clearMessages: () => void | Promise<void>;
|
|
131
|
+
}
|
|
132
|
+
type AskAIActionOptions = {
|
|
133
|
+
open?: boolean;
|
|
76
134
|
};
|
|
77
135
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
136
|
+
declare function useAskAI(): AskAIContextValue;
|
|
137
|
+
|
|
138
|
+
interface BoundedChatTransportOptions {
|
|
139
|
+
endpoint: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Custom chat transport that implements bounded context.
|
|
143
|
+
*/
|
|
144
|
+
declare class BoundedChatTransport extends DefaultChatTransport<UIMessage$1> {
|
|
145
|
+
constructor({ endpoint }: BoundedChatTransportOptions);
|
|
84
146
|
}
|
|
85
|
-
declare const Chat: ({ chatPersistence, suggestedPrompts, onClearRef, chatTransport, maxMessages }: ChatProps) => react_jsx_runtime.JSX.Element;
|
|
86
147
|
|
|
87
|
-
export { AskAI, type
|
|
148
|
+
export { AskAI, type AskAIChatProps, type AskAIDialogProps, type AskAIHeaderProps, type AskAIInlineProps, type AskAIInputProps, type AskAIMessagesProps, type AskAIProps, AskAIProvider, type AskAIProviderProps, type AskAISidepaneProps, type AskAISuggestionsProps, BoundedChatTransport, useAskAI };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,87 +1,148 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
import * as
|
|
4
|
-
import {
|
|
5
|
-
import { UIMessage } from '@ai-sdk/react';
|
|
2
|
+
import { HttpChatTransport, UIMessage, FileUIPart, ChatStatus, DefaultChatTransport } from 'ai';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ReactNode, ComponentPropsWithoutRef } from 'react';
|
|
5
|
+
import { UIMessage as UIMessage$1 } from '@ai-sdk/react';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
interface AskAIDialogProps extends AskAIBaseProps {
|
|
12
|
-
}
|
|
13
|
-
declare function AskAIDialog({ suggestedPrompts, button, maxMessages }?: AskAIDialogProps): react_jsx_runtime.JSX.Element;
|
|
14
|
-
|
|
15
|
-
interface AskAISidepaneProps extends AskAIBaseProps {
|
|
16
|
-
}
|
|
17
|
-
declare function AskAISidepane({ suggestedPrompts, button, maxMessages }?: AskAISidepaneProps): react_jsx_runtime.JSX.Element;
|
|
7
|
+
type ChatPersistenceConfig = boolean | {
|
|
8
|
+
key?: string;
|
|
9
|
+
};
|
|
18
10
|
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
interface AskAIRootProps {
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* API endpoint for handling AI requests.
|
|
15
|
+
* @default '/api/peam'
|
|
16
|
+
*/
|
|
17
|
+
endpoint?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Controlled open state.
|
|
20
|
+
*/
|
|
21
|
+
open?: boolean;
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* Uncontrolled initial open state.
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
defaultOpen?: boolean;
|
|
25
26
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @default 10
|
|
27
|
+
* Override the default chat transport.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
chatTransport?: HttpChatTransport<UIMessage>;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```tsx
|
|
35
|
-
* <AskAI
|
|
36
|
-
* type="dialog"
|
|
37
|
-
* button={({ isOpen, toggle, open, close }) => (
|
|
38
|
-
* <button onClick={toggle}>
|
|
39
|
-
* {isOpen ? 'Close' : 'Open'} AI
|
|
40
|
-
* </button>
|
|
41
|
-
* )}
|
|
42
|
-
* />
|
|
43
|
-
* ```
|
|
31
|
+
* Configure chat persistence.
|
|
32
|
+
* @default true
|
|
44
33
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
34
|
+
persistence?: ChatPersistenceConfig;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type AskAIProviderProps = AskAIRootProps;
|
|
38
|
+
declare function AskAIProvider(props: AskAIRootProps): react_jsx_runtime.JSX.Element;
|
|
39
|
+
|
|
40
|
+
type PeamButtonVariant = 'icon' | 'iconLabel';
|
|
41
|
+
|
|
42
|
+
interface AskAITriggerProps extends ComponentPropsWithoutRef<'button'> {
|
|
43
|
+
asChild?: boolean;
|
|
44
|
+
children?: ReactNode;
|
|
45
|
+
inlineButton?: boolean;
|
|
46
|
+
variant?: PeamButtonVariant;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type AskAIProps = AskAIRootProps & {
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* When true, reuses an existing {@link AskAIContext} if present.
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
reuseContext?: boolean;
|
|
56
|
+
} & ComponentPropsWithoutRef<'div'>;
|
|
57
|
+
declare function AskAI$1({ children, className, reuseContext, endpoint, open, defaultOpen, chatTransport, persistence, ...divProps }: AskAIProps): react_jsx_runtime.JSX.Element;
|
|
58
|
+
|
|
59
|
+
interface AskAIChatProps extends ComponentPropsWithoutRef<'div'> {
|
|
60
|
+
children?: ReactNode;
|
|
51
61
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
declare function AskAIChat({ children, className, ...props }: AskAIChatProps): react_jsx_runtime.JSX.Element | null;
|
|
63
|
+
|
|
64
|
+
interface AskAIDialogProps extends ComponentPropsWithoutRef<'div'> {
|
|
65
|
+
children?: ReactNode;
|
|
66
|
+
}
|
|
67
|
+
declare function AskAIDialog({ children, className, ...props }: AskAIDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
68
|
+
|
|
69
|
+
interface AskAIHeaderProps extends ComponentPropsWithoutRef<'div'> {
|
|
70
|
+
heading?: ReactNode;
|
|
71
|
+
closeLabel?: string;
|
|
72
|
+
}
|
|
73
|
+
declare function AskAIHeader({ heading, closeLabel, ...props }: AskAIHeaderProps): react_jsx_runtime.JSX.Element;
|
|
74
|
+
|
|
75
|
+
type AskAIInlineProps = ComponentPropsWithoutRef<'div'>;
|
|
76
|
+
declare function AskAIInline({ className, ...props }: AskAIInlineProps): react_jsx_runtime.JSX.Element;
|
|
77
|
+
|
|
78
|
+
type AskAIInputProps = ComponentPropsWithoutRef<'div'>;
|
|
79
|
+
declare function AskAIInput({ className, ...props }: AskAIInputProps): react_jsx_runtime.JSX.Element;
|
|
80
|
+
|
|
81
|
+
type AskAIMessagesProps = ComponentPropsWithoutRef<'div'>;
|
|
82
|
+
declare function AskAIMessages({ className, ...props }: AskAIMessagesProps): react_jsx_runtime.JSX.Element;
|
|
83
|
+
|
|
84
|
+
interface AskAISidepaneProps extends ComponentPropsWithoutRef<'div'> {
|
|
85
|
+
children?: ReactNode;
|
|
86
|
+
}
|
|
87
|
+
declare function AskAISidepane({ children, className, ...props }: AskAISidepaneProps): react_jsx_runtime.JSX.Element | null;
|
|
88
|
+
|
|
89
|
+
interface AskAISuggestionsProps extends ComponentPropsWithoutRef<'div'> {
|
|
90
|
+
prompts?: string[];
|
|
91
|
+
onPromptClick?: (prompt: string) => void;
|
|
92
|
+
onlyWhenEmpty?: boolean;
|
|
93
|
+
}
|
|
94
|
+
declare function AskAISuggestions({ prompts, onPromptClick, onlyWhenEmpty, className, ...props }: AskAISuggestionsProps): react_jsx_runtime.JSX.Element | null;
|
|
95
|
+
|
|
96
|
+
declare const AskAI: typeof AskAI$1 & {
|
|
97
|
+
Trigger: React.ForwardRefExoticComponent<AskAITriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
98
|
+
Header: typeof AskAIHeader;
|
|
99
|
+
Dialog: typeof AskAIDialog;
|
|
100
|
+
Chat: typeof AskAIChat;
|
|
101
|
+
Sidepane: typeof AskAISidepane;
|
|
102
|
+
Inline: typeof AskAIInline;
|
|
103
|
+
Messages: typeof AskAIMessages;
|
|
104
|
+
Suggestions: typeof AskAISuggestions;
|
|
105
|
+
Input: typeof AskAIInput;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
interface PromptInputMessage {
|
|
109
|
+
text: string;
|
|
110
|
+
files: FileUIPart[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface AskAIContextValue {
|
|
114
|
+
open: boolean;
|
|
115
|
+
setOpen: (open: boolean) => void;
|
|
116
|
+
toggleOpen: () => void;
|
|
117
|
+
input: string;
|
|
118
|
+
setInput: (value: string, options?: AskAIActionOptions) => void;
|
|
119
|
+
messages: UIMessage[];
|
|
120
|
+
status: ChatStatus;
|
|
121
|
+
error: Error | undefined;
|
|
70
122
|
isLoading: boolean;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
123
|
+
sendMessage: (message: {
|
|
124
|
+
text: string;
|
|
125
|
+
}, options?: AskAIActionOptions) => void;
|
|
126
|
+
handleSubmit: (message: PromptInputMessage) => void;
|
|
127
|
+
regenerate: (options?: {
|
|
128
|
+
messageId?: string;
|
|
129
|
+
}) => void;
|
|
130
|
+
clearMessages: () => void | Promise<void>;
|
|
131
|
+
}
|
|
132
|
+
type AskAIActionOptions = {
|
|
133
|
+
open?: boolean;
|
|
76
134
|
};
|
|
77
135
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
136
|
+
declare function useAskAI(): AskAIContextValue;
|
|
137
|
+
|
|
138
|
+
interface BoundedChatTransportOptions {
|
|
139
|
+
endpoint: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Custom chat transport that implements bounded context.
|
|
143
|
+
*/
|
|
144
|
+
declare class BoundedChatTransport extends DefaultChatTransport<UIMessage$1> {
|
|
145
|
+
constructor({ endpoint }: BoundedChatTransportOptions);
|
|
84
146
|
}
|
|
85
|
-
declare const Chat: ({ chatPersistence, suggestedPrompts, onClearRef, chatTransport, maxMessages }: ChatProps) => react_jsx_runtime.JSX.Element;
|
|
86
147
|
|
|
87
|
-
export { AskAI, type
|
|
148
|
+
export { AskAI, type AskAIChatProps, type AskAIDialogProps, type AskAIHeaderProps, type AskAIInlineProps, type AskAIInputProps, type AskAIMessagesProps, type AskAIProps, AskAIProvider, type AskAIProviderProps, type AskAISidepaneProps, type AskAISuggestionsProps, BoundedChatTransport, useAskAI };
|