@copilotkit/react-textarea 0.18.0 → 0.19.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +303 -189
- package/CHANGELOG.md +19 -0
- package/dist/chunk-2NURR2DX.mjs +47 -0
- package/dist/chunk-2NURR2DX.mjs.map +1 -0
- package/dist/chunk-3YJ63D5D.mjs +106 -0
- package/dist/chunk-3YJ63D5D.mjs.map +1 -0
- package/dist/chunk-4S5ZJH3I.mjs +18 -0
- package/dist/chunk-4S5ZJH3I.mjs.map +1 -0
- package/dist/chunk-55EGOC5T.mjs +87 -0
- package/dist/chunk-55EGOC5T.mjs.map +1 -0
- package/dist/{chunk-3A2CNIG5.mjs → chunk-5ARCOTW3.mjs} +8 -5
- package/dist/chunk-5ARCOTW3.mjs.map +1 -0
- package/dist/chunk-5EJ5XOGP.mjs +22 -0
- package/dist/chunk-5EJ5XOGP.mjs.map +1 -0
- package/dist/chunk-5FO6ISW4.mjs +3 -0
- package/dist/{chunk-5GGCWNTT.mjs → chunk-5SL5L4VS.mjs} +67 -29
- package/dist/chunk-5SL5L4VS.mjs.map +1 -0
- package/dist/{chunk-JWN2VEE3.mjs → chunk-A2RRLD23.mjs} +13 -12
- package/dist/chunk-A2RRLD23.mjs.map +1 -0
- package/dist/chunk-CDB7HFCY.mjs +65 -0
- package/dist/chunk-CDB7HFCY.mjs.map +1 -0
- package/dist/{chunk-MFJNLKRC.mjs → chunk-D7SEV5PR.mjs} +4 -3
- package/dist/chunk-D7SEV5PR.mjs.map +1 -0
- package/dist/chunk-HAFHLU4N.mjs +55 -0
- package/dist/chunk-HAFHLU4N.mjs.map +1 -0
- package/dist/chunk-ITZHK3YV.mjs +477 -0
- package/dist/chunk-ITZHK3YV.mjs.map +1 -0
- package/dist/{chunk-3UQM3NLM.mjs → chunk-IXJ2HCOA.mjs} +42 -7
- package/dist/chunk-IXJ2HCOA.mjs.map +1 -0
- package/dist/{chunk-UW3ITU2Y.mjs → chunk-JAFCXEPU.mjs} +1 -1
- package/dist/chunk-JAFCXEPU.mjs.map +1 -0
- package/dist/chunk-KDFCAQGV.mjs +44 -0
- package/dist/chunk-KDFCAQGV.mjs.map +1 -0
- package/dist/chunk-L7VVZH4Q.mjs +3 -0
- package/dist/chunk-ND5PXTAW.mjs +17 -0
- package/dist/chunk-ND5PXTAW.mjs.map +1 -0
- package/dist/chunk-O5OWT5GE.mjs +114 -0
- package/dist/chunk-O5OWT5GE.mjs.map +1 -0
- package/dist/chunk-OD7ZMOVE.mjs +45 -0
- package/dist/chunk-OD7ZMOVE.mjs.map +1 -0
- package/dist/chunk-OM5WQQOU.mjs +47 -0
- package/dist/chunk-OM5WQQOU.mjs.map +1 -0
- package/dist/chunk-QL2GYGG5.mjs +19 -0
- package/dist/chunk-QL2GYGG5.mjs.map +1 -0
- package/dist/chunk-RPDVSCLO.mjs +107 -0
- package/dist/chunk-RPDVSCLO.mjs.map +1 -0
- package/dist/{chunk-HZGSG7ST.mjs → chunk-UHD44NC5.mjs} +10 -5
- package/dist/chunk-UHD44NC5.mjs.map +1 -0
- package/dist/chunk-VBIJPE3H.mjs +108 -0
- package/dist/chunk-VBIJPE3H.mjs.map +1 -0
- package/dist/chunk-XDT7BF3V.mjs +81 -0
- package/dist/chunk-XDT7BF3V.mjs.map +1 -0
- package/dist/chunk-XHUMROEY.mjs +91 -0
- package/dist/chunk-XHUMROEY.mjs.map +1 -0
- package/dist/{chunk-LWVCQYWV.mjs → chunk-YQU7WG7T.mjs} +2 -2
- package/dist/chunk-YTOPHPSG.mjs +45 -0
- package/dist/chunk-YTOPHPSG.mjs.map +1 -0
- package/dist/chunk-YW3REYX6.mjs +23 -0
- package/dist/chunk-YW3REYX6.mjs.map +1 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.d.ts +3 -5
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +21 -7
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.d.ts +6 -0
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +5 -0
- package/dist/components/copilot-textarea/copilot-textarea.d.ts +13 -10
- package/dist/components/copilot-textarea/copilot-textarea.mjs +31 -12
- package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +13 -0
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +4 -0
- package/dist/components/hovering-toolbar/hovering-toolbar-components.d.ts +18 -0
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +4 -0
- package/dist/components/hovering-toolbar/hovering-toolbar.d.ts +8 -0
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +17 -0
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.d.ts +12 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +12 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.d.ts +3 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +13 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/mode-pre-suggestion.d.ts +16 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/mode-pre-suggestion.mjs +5 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/mode-pre-suggestion.mjs.map +1 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/mode-suggestion-appearing.d.ts +37 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/mode-suggestion-appearing.mjs +10 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/mode-suggestion-appearing.mjs.map +1 -0
- package/dist/components/index.d.ts +9 -4
- package/dist/components/index.mjs +31 -12
- package/dist/components/manual-ui/chip-with-icon.d.ts +10 -0
- package/dist/components/manual-ui/chip-with-icon.mjs +29 -0
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -0
- package/dist/components/source-search-box/source-search-box.d.ts +17 -0
- package/dist/components/source-search-box/source-search-box.mjs +10 -0
- package/dist/components/source-search-box/source-search-box.mjs.map +1 -0
- package/dist/components/ui/button.d.ts +14 -0
- package/dist/components/ui/button.mjs +5 -0
- package/dist/components/ui/button.mjs.map +1 -0
- package/dist/components/ui/card.d.ts +10 -0
- package/dist/components/ui/card.mjs +63 -0
- package/dist/components/ui/card.mjs.map +1 -0
- package/dist/components/ui/command.d.ts +48 -0
- package/dist/components/ui/command.mjs +6 -0
- package/dist/components/ui/command.mjs.map +1 -0
- package/dist/components/ui/dialog.d.ts +18 -0
- package/dist/components/ui/dialog.mjs +5 -0
- package/dist/components/ui/dialog.mjs.map +1 -0
- package/dist/components/ui/label.d.ts +8 -0
- package/dist/components/ui/label.mjs +5 -0
- package/dist/components/ui/label.mjs.map +1 -0
- package/dist/components/ui/separator.d.ts +6 -0
- package/dist/components/ui/separator.mjs +26 -0
- package/dist/components/ui/separator.mjs.map +1 -0
- package/dist/components/ui/textarea.d.ts +7 -0
- package/dist/components/ui/textarea.mjs +22 -0
- package/dist/components/ui/textarea.mjs.map +1 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +2 -2
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.d.ts +2 -2
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +2 -2
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.d.ts +5 -7
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +2 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.d.ts +23 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +5 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -0
- package/dist/hooks/misc/use-autosize-textarea.d.ts +5 -0
- package/dist/hooks/misc/use-autosize-textarea.mjs +4 -0
- package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -0
- package/dist/index.css +674 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.mjs +31 -12
- package/dist/lib/editor-to-text.mjs +1 -42
- package/dist/lib/editor-to-text.mjs.map +1 -1
- package/dist/lib/get-text-around-cursor.d.ts +10 -3
- package/dist/lib/get-text-around-cursor.mjs +1 -1
- package/dist/lib/retry.d.ts +3 -0
- package/dist/lib/retry.mjs +4 -0
- package/dist/lib/retry.mjs.map +1 -0
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.d.ts +25 -0
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +3 -0
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -0
- package/dist/types/autosuggestions-config/autosuggestions-config.d.ts +20 -0
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +10 -0
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -0
- package/dist/types/autosuggestions-config/editing-api-config.d.ts +17 -0
- package/dist/types/autosuggestions-config/editing-api-config.mjs +5 -0
- package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -0
- package/dist/types/autosuggestions-config/index.d.ts +10 -0
- package/dist/types/autosuggestions-config/index.mjs +11 -0
- package/dist/types/autosuggestions-config/index.mjs.map +1 -0
- package/dist/types/autosuggestions-config/insertions-api-config.d.ts +17 -0
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +5 -0
- package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -0
- package/dist/types/{standard-autosuggestions → autosuggestions-config/subtypes}/chatlike-api-endpoint.d.ts +7 -4
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +4 -0
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs.map +1 -0
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.d.ts +3 -0
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +3 -0
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -0
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -0
- package/dist/types/autosuggestions-config/suggestions-api-config.d.ts +17 -0
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +5 -0
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -0
- package/dist/types/base/autosuggestions-bare-function.d.ts +16 -2
- package/dist/types/base/base-autosuggestions-config.d.ts +5 -1
- package/dist/types/base/base-autosuggestions-config.mjs +1 -1
- package/dist/types/base/base-copilot-textarea-props.d.ts +3 -1
- package/dist/types/base/editor-autocomplete-state.mjs +1 -1
- package/dist/types/base/index.mjs +1 -1
- package/dist/types/index.d.ts +8 -3
- package/dist/types/index.mjs +7 -4
- package/package.json +19 -5
- package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +64 -13
- package/src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx +61 -0
- package/src/components/copilot-textarea/copilot-textarea.tsx +29 -17
- package/src/components/hovering-toolbar/hovering-editor-provider.tsx +29 -0
- package/src/components/hovering-toolbar/hovering-toolbar-components.tsx +115 -0
- package/src/components/hovering-toolbar/hovering-toolbar.tsx +156 -0
- package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx +73 -0
- package/src/components/hovering-toolbar/text-insertion-prompt-box/index.ts +2 -0
- package/src/components/hovering-toolbar/text-insertion-prompt-box/mode-pre-suggestion.tsx +83 -0
- package/src/components/hovering-toolbar/text-insertion-prompt-box/mode-suggestion-appearing.tsx +410 -0
- package/src/components/manual-ui/chip-with-icon.tsx +28 -0
- package/src/components/source-search-box/source-search-box.tsx +133 -0
- package/src/components/ui/button.tsx +56 -0
- package/src/components/ui/card.tsx +86 -0
- package/src/components/ui/command.tsx +155 -0
- package/src/components/ui/dialog.tsx +123 -0
- package/src/components/ui/label.tsx +26 -0
- package/src/components/ui/separator.tsx +31 -0
- package/src/components/ui/textarea.tsx +24 -0
- package/src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts +10 -3
- package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +29 -44
- package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +150 -0
- package/src/hooks/misc/use-autosize-textarea.tsx +21 -0
- package/src/lib/get-text-around-cursor.ts +71 -6
- package/src/lib/retry.tsx +23 -0
- package/src/styles.css +2 -0
- package/src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx +27 -0
- package/src/types/autosuggestions-config/autosuggestions-config.tsx +43 -0
- package/src/types/autosuggestions-config/editing-api-config.tsx +102 -0
- package/src/types/autosuggestions-config/index.ts +11 -0
- package/src/types/autosuggestions-config/insertions-api-config.tsx +95 -0
- package/src/types/{standard-autosuggestions → autosuggestions-config/subtypes}/chatlike-api-endpoint.tsx +19 -7
- package/src/types/autosuggestions-config/subtypes/make-system-prompt.ts +4 -0
- package/src/types/{standard-autosuggestions/autosuggestions-config.tsx → autosuggestions-config/suggestions-api-config.tsx} +12 -23
- package/src/types/base/autosuggestions-bare-function.ts +24 -2
- package/src/types/base/base-autosuggestions-config.tsx +7 -2
- package/src/types/base/base-copilot-textarea-props.tsx +3 -1
- package/src/types/base/editor-autocomplete-state.ts +1 -0
- package/src/types/index.ts +1 -1
- package/tailwind.config.js +2 -0
- package/dist/chunk-3A2CNIG5.mjs.map +0 -1
- package/dist/chunk-3UQM3NLM.mjs.map +0 -1
- package/dist/chunk-5GGCWNTT.mjs.map +0 -1
- package/dist/chunk-BLRD23HM.mjs +0 -32
- package/dist/chunk-BLRD23HM.mjs.map +0 -1
- package/dist/chunk-BTAUKCBN.mjs +0 -60
- package/dist/chunk-BTAUKCBN.mjs.map +0 -1
- package/dist/chunk-HZGSG7ST.mjs.map +0 -1
- package/dist/chunk-JWN2VEE3.mjs.map +0 -1
- package/dist/chunk-MFJNLKRC.mjs.map +0 -1
- package/dist/chunk-SL4J5HMW.mjs +0 -3
- package/dist/chunk-UW3ITU2Y.mjs.map +0 -1
- package/dist/types/standard-autosuggestions/autosuggestions-config.d.ts +0 -19
- package/dist/types/standard-autosuggestions/autosuggestions-config.mjs +0 -6
- package/dist/types/standard-autosuggestions/chatlike-api-endpoint.mjs +0 -4
- package/dist/types/standard-autosuggestions/index.d.ts +0 -4
- package/dist/types/standard-autosuggestions/index.mjs +0 -8
- package/src/types/standard-autosuggestions/index.ts +0 -14
- /package/dist/{chunk-SL4J5HMW.mjs.map → chunk-5FO6ISW4.mjs.map} +0 -0
- /package/dist/{types/standard-autosuggestions/autosuggestions-config.mjs.map → chunk-L7VVZH4Q.mjs.map} +0 -0
- /package/dist/{chunk-LWVCQYWV.mjs.map → chunk-YQU7WG7T.mjs.map} +0 -0
- /package/dist/{types/standard-autosuggestions/chatlike-api-endpoint.mjs.map → components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map} +0 -0
- /package/dist/{types/standard-autosuggestions/index.mjs.map → components/hovering-toolbar/hovering-editor-provider.mjs.map} +0 -0
- /package/dist/{types/standard-autosuggestions/minimal-chat-gpt-message.mjs.map → components/hovering-toolbar/hovering-toolbar-components.mjs.map} +0 -0
- /package/dist/types/{standard-autosuggestions → autosuggestions-config/subtypes}/minimal-chat-gpt-message.d.ts +0 -0
- /package/dist/types/{standard-autosuggestions → autosuggestions-config/subtypes}/minimal-chat-gpt-message.mjs +0 -0
- /package/src/types/{standard-autosuggestions → autosuggestions-config/subtypes}/minimal-chat-gpt-message.tsx +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../lib/utils";
|
|
4
|
+
|
|
5
|
+
const Card = React.forwardRef<
|
|
6
|
+
HTMLDivElement,
|
|
7
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<div
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn(
|
|
12
|
+
"rounded-lg border bg-card text-card-foreground shadow-sm",
|
|
13
|
+
className
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
));
|
|
18
|
+
Card.displayName = "Card";
|
|
19
|
+
|
|
20
|
+
const CardHeader = React.forwardRef<
|
|
21
|
+
HTMLDivElement,
|
|
22
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
23
|
+
>(({ className, ...props }, ref) => (
|
|
24
|
+
<div
|
|
25
|
+
ref={ref}
|
|
26
|
+
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
));
|
|
30
|
+
CardHeader.displayName = "CardHeader";
|
|
31
|
+
|
|
32
|
+
const CardTitle = React.forwardRef<
|
|
33
|
+
HTMLParagraphElement,
|
|
34
|
+
React.HTMLAttributes<HTMLHeadingElement>
|
|
35
|
+
>(({ className, ...props }, ref) => (
|
|
36
|
+
<h3
|
|
37
|
+
ref={ref}
|
|
38
|
+
className={cn(
|
|
39
|
+
"text-2xl font-semibold leading-none tracking-tight",
|
|
40
|
+
className
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
));
|
|
45
|
+
CardTitle.displayName = "CardTitle";
|
|
46
|
+
|
|
47
|
+
const CardDescription = React.forwardRef<
|
|
48
|
+
HTMLParagraphElement,
|
|
49
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
50
|
+
>(({ className, ...props }, ref) => (
|
|
51
|
+
<p
|
|
52
|
+
ref={ref}
|
|
53
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
54
|
+
{...props}
|
|
55
|
+
/>
|
|
56
|
+
));
|
|
57
|
+
CardDescription.displayName = "CardDescription";
|
|
58
|
+
|
|
59
|
+
const CardContent = React.forwardRef<
|
|
60
|
+
HTMLDivElement,
|
|
61
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
62
|
+
>(({ className, ...props }, ref) => (
|
|
63
|
+
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
|
64
|
+
));
|
|
65
|
+
CardContent.displayName = "CardContent";
|
|
66
|
+
|
|
67
|
+
const CardFooter = React.forwardRef<
|
|
68
|
+
HTMLDivElement,
|
|
69
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
70
|
+
>(({ className, ...props }, ref) => (
|
|
71
|
+
<div
|
|
72
|
+
ref={ref}
|
|
73
|
+
className={cn("flex items-center p-6 pt-0", className)}
|
|
74
|
+
{...props}
|
|
75
|
+
/>
|
|
76
|
+
));
|
|
77
|
+
CardFooter.displayName = "CardFooter";
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
Card,
|
|
81
|
+
CardHeader,
|
|
82
|
+
CardFooter,
|
|
83
|
+
CardTitle,
|
|
84
|
+
CardDescription,
|
|
85
|
+
CardContent,
|
|
86
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { DialogProps } from "@radix-ui/react-dialog";
|
|
5
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
6
|
+
import { Search } from "lucide-react";
|
|
7
|
+
|
|
8
|
+
import { cn } from "../../lib/utils";
|
|
9
|
+
import { Dialog, DialogContent } from "./dialog";
|
|
10
|
+
|
|
11
|
+
const Command = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof CommandPrimitive>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
|
|
14
|
+
>(({ className, ...props }, ref) => (
|
|
15
|
+
<CommandPrimitive
|
|
16
|
+
ref={ref}
|
|
17
|
+
className={cn(
|
|
18
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
|
19
|
+
className
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
));
|
|
24
|
+
Command.displayName = CommandPrimitive.displayName;
|
|
25
|
+
|
|
26
|
+
interface CommandDialogProps extends DialogProps {}
|
|
27
|
+
|
|
28
|
+
const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
|
|
29
|
+
return (
|
|
30
|
+
<Dialog {...props}>
|
|
31
|
+
<DialogContent className="overflow-hidden p-0 shadow-lg">
|
|
32
|
+
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
33
|
+
{children}
|
|
34
|
+
</Command>
|
|
35
|
+
</DialogContent>
|
|
36
|
+
</Dialog>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const CommandInput = React.forwardRef<
|
|
41
|
+
React.ElementRef<typeof CommandPrimitive.Input>,
|
|
42
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
|
|
43
|
+
>(({ className, ...props }, ref) => (
|
|
44
|
+
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
|
|
45
|
+
{/* <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" /> */}
|
|
46
|
+
<CommandPrimitive.Input
|
|
47
|
+
ref={ref}
|
|
48
|
+
className={cn(
|
|
49
|
+
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
50
|
+
className
|
|
51
|
+
)}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
));
|
|
56
|
+
|
|
57
|
+
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
|
58
|
+
|
|
59
|
+
const CommandList = React.forwardRef<
|
|
60
|
+
React.ElementRef<typeof CommandPrimitive.List>,
|
|
61
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
|
62
|
+
>(({ className, ...props }, ref) => (
|
|
63
|
+
<CommandPrimitive.List
|
|
64
|
+
ref={ref}
|
|
65
|
+
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
));
|
|
69
|
+
|
|
70
|
+
CommandList.displayName = CommandPrimitive.List.displayName;
|
|
71
|
+
|
|
72
|
+
const CommandEmpty = React.forwardRef<
|
|
73
|
+
React.ElementRef<typeof CommandPrimitive.Empty>,
|
|
74
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
|
75
|
+
>((props, ref) => (
|
|
76
|
+
<CommandPrimitive.Empty
|
|
77
|
+
ref={ref}
|
|
78
|
+
className="py-6 text-center text-sm"
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
));
|
|
82
|
+
|
|
83
|
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
84
|
+
|
|
85
|
+
const CommandGroup = React.forwardRef<
|
|
86
|
+
React.ElementRef<typeof CommandPrimitive.Group>,
|
|
87
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
|
88
|
+
>(({ className, ...props }, ref) => (
|
|
89
|
+
<CommandPrimitive.Group
|
|
90
|
+
ref={ref}
|
|
91
|
+
className={cn(
|
|
92
|
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
93
|
+
className
|
|
94
|
+
)}
|
|
95
|
+
{...props}
|
|
96
|
+
/>
|
|
97
|
+
));
|
|
98
|
+
|
|
99
|
+
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
|
100
|
+
|
|
101
|
+
const CommandSeparator = React.forwardRef<
|
|
102
|
+
React.ElementRef<typeof CommandPrimitive.Separator>,
|
|
103
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
|
104
|
+
>(({ className, ...props }, ref) => (
|
|
105
|
+
<CommandPrimitive.Separator
|
|
106
|
+
ref={ref}
|
|
107
|
+
className={cn("-mx-1 h-px bg-border", className)}
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
));
|
|
111
|
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
|
112
|
+
|
|
113
|
+
const CommandItem = React.forwardRef<
|
|
114
|
+
React.ElementRef<typeof CommandPrimitive.Item>,
|
|
115
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
|
|
116
|
+
>(({ className, ...props }, ref) => (
|
|
117
|
+
<CommandPrimitive.Item
|
|
118
|
+
ref={ref}
|
|
119
|
+
className={cn(
|
|
120
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
121
|
+
className
|
|
122
|
+
)}
|
|
123
|
+
{...props}
|
|
124
|
+
/>
|
|
125
|
+
));
|
|
126
|
+
|
|
127
|
+
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
|
128
|
+
|
|
129
|
+
const CommandShortcut = ({
|
|
130
|
+
className,
|
|
131
|
+
...props
|
|
132
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
133
|
+
return (
|
|
134
|
+
<span
|
|
135
|
+
className={cn(
|
|
136
|
+
"ml-auto text-xs tracking-widest text-muted-foreground",
|
|
137
|
+
className
|
|
138
|
+
)}
|
|
139
|
+
{...props}
|
|
140
|
+
/>
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
CommandShortcut.displayName = "CommandShortcut";
|
|
144
|
+
|
|
145
|
+
export {
|
|
146
|
+
Command,
|
|
147
|
+
CommandDialog,
|
|
148
|
+
CommandInput,
|
|
149
|
+
CommandList,
|
|
150
|
+
CommandEmpty,
|
|
151
|
+
CommandGroup,
|
|
152
|
+
CommandItem,
|
|
153
|
+
CommandShortcut,
|
|
154
|
+
CommandSeparator,
|
|
155
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
5
|
+
import { X } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "../../lib/utils";
|
|
8
|
+
|
|
9
|
+
const Dialog = DialogPrimitive.Root;
|
|
10
|
+
|
|
11
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
12
|
+
|
|
13
|
+
const DialogPortal = ({
|
|
14
|
+
className,
|
|
15
|
+
...props
|
|
16
|
+
}: DialogPrimitive.DialogPortalProps) => (
|
|
17
|
+
<DialogPrimitive.Portal className={cn(className)} {...props} />
|
|
18
|
+
);
|
|
19
|
+
DialogPortal.displayName = DialogPrimitive.Portal.displayName;
|
|
20
|
+
|
|
21
|
+
const DialogOverlay = React.forwardRef<
|
|
22
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
23
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
24
|
+
>(({ className, ...props }, ref) => (
|
|
25
|
+
<DialogPrimitive.Overlay
|
|
26
|
+
ref={ref}
|
|
27
|
+
className={cn(
|
|
28
|
+
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
29
|
+
className
|
|
30
|
+
)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
));
|
|
34
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
35
|
+
|
|
36
|
+
const DialogContent = React.forwardRef<
|
|
37
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
38
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
39
|
+
>(({ className, children, ...props }, ref) => (
|
|
40
|
+
<DialogPortal>
|
|
41
|
+
<DialogOverlay />
|
|
42
|
+
<DialogPrimitive.Content
|
|
43
|
+
ref={ref}
|
|
44
|
+
className={cn(
|
|
45
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
|
52
|
+
<X className="h-4 w-4" />
|
|
53
|
+
<span className="sr-only">Close</span>
|
|
54
|
+
</DialogPrimitive.Close>
|
|
55
|
+
</DialogPrimitive.Content>
|
|
56
|
+
</DialogPortal>
|
|
57
|
+
));
|
|
58
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
59
|
+
|
|
60
|
+
const DialogHeader = ({
|
|
61
|
+
className,
|
|
62
|
+
...props
|
|
63
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
64
|
+
<div
|
|
65
|
+
className={cn(
|
|
66
|
+
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
67
|
+
className
|
|
68
|
+
)}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
DialogHeader.displayName = "DialogHeader";
|
|
73
|
+
|
|
74
|
+
const DialogFooter = ({
|
|
75
|
+
className,
|
|
76
|
+
...props
|
|
77
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
78
|
+
<div
|
|
79
|
+
className={cn(
|
|
80
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
81
|
+
className
|
|
82
|
+
)}
|
|
83
|
+
{...props}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
DialogFooter.displayName = "DialogFooter";
|
|
87
|
+
|
|
88
|
+
const DialogTitle = React.forwardRef<
|
|
89
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
90
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
91
|
+
>(({ className, ...props }, ref) => (
|
|
92
|
+
<DialogPrimitive.Title
|
|
93
|
+
ref={ref}
|
|
94
|
+
className={cn(
|
|
95
|
+
"text-lg font-semibold leading-none tracking-tight",
|
|
96
|
+
className
|
|
97
|
+
)}
|
|
98
|
+
{...props}
|
|
99
|
+
/>
|
|
100
|
+
));
|
|
101
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
102
|
+
|
|
103
|
+
const DialogDescription = React.forwardRef<
|
|
104
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
105
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
106
|
+
>(({ className, ...props }, ref) => (
|
|
107
|
+
<DialogPrimitive.Description
|
|
108
|
+
ref={ref}
|
|
109
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
110
|
+
{...props}
|
|
111
|
+
/>
|
|
112
|
+
));
|
|
113
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
Dialog,
|
|
117
|
+
DialogTrigger,
|
|
118
|
+
DialogContent,
|
|
119
|
+
DialogHeader,
|
|
120
|
+
DialogFooter,
|
|
121
|
+
DialogTitle,
|
|
122
|
+
DialogDescription,
|
|
123
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
5
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
|
+
|
|
7
|
+
import { cn } from "../../lib/utils";
|
|
8
|
+
|
|
9
|
+
const labelVariants = cva(
|
|
10
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const Label = React.forwardRef<
|
|
14
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
16
|
+
VariantProps<typeof labelVariants>
|
|
17
|
+
>(({ className, ...props }, ref) => (
|
|
18
|
+
<LabelPrimitive.Root
|
|
19
|
+
ref={ref}
|
|
20
|
+
className={cn(labelVariants(), className)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
));
|
|
24
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
25
|
+
|
|
26
|
+
export { Label };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
|
|
8
|
+
const Separator = React.forwardRef<
|
|
9
|
+
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
|
10
|
+
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
|
|
11
|
+
>(
|
|
12
|
+
(
|
|
13
|
+
{ className, orientation = "horizontal", decorative = true, ...props },
|
|
14
|
+
ref
|
|
15
|
+
) => (
|
|
16
|
+
<SeparatorPrimitive.Root
|
|
17
|
+
ref={ref}
|
|
18
|
+
decorative={decorative}
|
|
19
|
+
orientation={orientation}
|
|
20
|
+
className={cn(
|
|
21
|
+
"shrink-0 bg-border",
|
|
22
|
+
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
30
|
+
|
|
31
|
+
export { Separator };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../lib/utils";
|
|
4
|
+
|
|
5
|
+
export interface TextareaProps
|
|
6
|
+
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
|
|
7
|
+
|
|
8
|
+
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
9
|
+
({ className, ...props }, ref) => {
|
|
10
|
+
return (
|
|
11
|
+
<textarea
|
|
12
|
+
className={cn(
|
|
13
|
+
"flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
14
|
+
className
|
|
15
|
+
)}
|
|
16
|
+
ref={ref}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
Textarea.displayName = "Textarea";
|
|
23
|
+
|
|
24
|
+
export { Textarea };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useMemo, useState } from "react";
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { Debouncer } from "../../lib/debouncer";
|
|
3
3
|
import { nullableCompatibleEqualityCheck } from "../../lib/utils";
|
|
4
4
|
import { AutosuggestionsBareFunction } from "../../types/base";
|
|
@@ -51,8 +51,7 @@ export function useAutosuggestions(
|
|
|
51
51
|
|
|
52
52
|
// fetch the suggestion
|
|
53
53
|
const suggestion = await autosuggestionFunction(
|
|
54
|
-
editorAutocompleteState
|
|
55
|
-
editorAutocompleteState.textAfterCursor,
|
|
54
|
+
editorAutocompleteState,
|
|
56
55
|
abortSignal
|
|
57
56
|
);
|
|
58
57
|
|
|
@@ -82,6 +81,14 @@ export function useAutosuggestions(
|
|
|
82
81
|
[debounceTime]
|
|
83
82
|
);
|
|
84
83
|
|
|
84
|
+
// clean current state when unmounting or disabling
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
return () => {
|
|
87
|
+
debouncedFunction.cancel();
|
|
88
|
+
setCurrentAutocompleteSuggestion(null);
|
|
89
|
+
};
|
|
90
|
+
}, [debouncedFunction, disabled]);
|
|
91
|
+
|
|
85
92
|
const onChange = useCallback(
|
|
86
93
|
(newEditorState: EditorAutocompleteState | null) => {
|
|
87
94
|
const editorStateHasChanged = !nullableCompatibleEqualityCheck(
|
package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
CHANGED
|
@@ -2,10 +2,11 @@ import { CopilotContext } from "@copilotkit/react-core";
|
|
|
2
2
|
import { useCallback, useContext } from "react";
|
|
3
3
|
import {
|
|
4
4
|
AutosuggestionsBareFunction,
|
|
5
|
-
MakeSystemPrompt,
|
|
6
5
|
MinimalChatGPTMessage,
|
|
7
6
|
} from "../../types";
|
|
8
|
-
import {
|
|
7
|
+
import { retry } from "../../lib/retry";
|
|
8
|
+
import { InsertionEditorState } from "../../types/base/autosuggestions-bare-function";
|
|
9
|
+
import { SuggestionsApiConfig } from "../../types/autosuggestions-config/suggestions-api-config";
|
|
9
10
|
/**
|
|
10
11
|
* Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.
|
|
11
12
|
* The function takes in the text before and after the cursor, and an abort signal.
|
|
@@ -21,74 +22,58 @@ import { ChatlikeApiEndpoint } from "../../types/standard-autosuggestions/chatli
|
|
|
21
22
|
*/
|
|
22
23
|
export function useMakeStandardAutosuggestionFunction(
|
|
23
24
|
textareaPurpose: string,
|
|
24
|
-
apiEndpoint: ChatlikeApiEndpoint,
|
|
25
|
-
makeSystemPrompt: MakeSystemPrompt,
|
|
26
|
-
fewShotMessages: MinimalChatGPTMessage[],
|
|
27
25
|
contextCategories: string[] | undefined,
|
|
28
|
-
|
|
26
|
+
apiConfig: SuggestionsApiConfig
|
|
29
27
|
): AutosuggestionsBareFunction {
|
|
30
28
|
const { getContextString } = useContext(CopilotContext);
|
|
31
29
|
|
|
32
30
|
return useCallback(
|
|
33
|
-
async (
|
|
31
|
+
async (editorState: InsertionEditorState, abortSignal: AbortSignal) => {
|
|
34
32
|
const res = await retry(async () => {
|
|
35
33
|
const messages: MinimalChatGPTMessage[] = [
|
|
36
34
|
{
|
|
37
35
|
role: "system",
|
|
38
|
-
content: makeSystemPrompt(
|
|
36
|
+
content: apiConfig.makeSystemPrompt(
|
|
39
37
|
textareaPurpose,
|
|
40
38
|
getContextString(contextCategories)
|
|
41
39
|
),
|
|
42
40
|
},
|
|
43
|
-
...fewShotMessages,
|
|
41
|
+
...apiConfig.fewShotMessages,
|
|
44
42
|
{
|
|
45
43
|
role: "user",
|
|
46
44
|
name: "TextAfterCursor",
|
|
47
|
-
content:
|
|
45
|
+
content: editorState.textAfterCursor,
|
|
48
46
|
},
|
|
49
47
|
{
|
|
50
48
|
role: "user",
|
|
51
49
|
name: "TextBeforeCursor",
|
|
52
|
-
content:
|
|
50
|
+
content: editorState.textBeforeCursor,
|
|
53
51
|
},
|
|
54
52
|
];
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
const stream = await apiConfig.apiEndpoint.run(
|
|
55
|
+
abortSignal,
|
|
56
|
+
messages,
|
|
57
|
+
apiConfig.forwardedParams
|
|
58
|
+
);
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
apiEndpoint,
|
|
63
|
-
makeSystemPrompt,
|
|
64
|
-
fewShotMessages,
|
|
65
|
-
getContextString,
|
|
66
|
-
contextCategories,
|
|
67
|
-
textareaPurpose,
|
|
68
|
-
]
|
|
69
|
-
);
|
|
70
|
-
}
|
|
60
|
+
// read the stream:
|
|
61
|
+
const reader = stream.getReader();
|
|
62
|
+
let result = "";
|
|
71
63
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return new Promise((resolve, reject) => {
|
|
79
|
-
fn()
|
|
80
|
-
.then(resolve)
|
|
81
|
-
.catch((error) => {
|
|
82
|
-
if (retriesLeft === 1) {
|
|
83
|
-
reject(error);
|
|
84
|
-
return;
|
|
64
|
+
while (true) {
|
|
65
|
+
const { done, value } = await reader.read();
|
|
66
|
+
if (done) {
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
result += value;
|
|
85
70
|
}
|
|
86
71
|
|
|
87
|
-
|
|
88
|
-
retry(fn, retriesLeft - 1, interval * backoff, backoff)
|
|
89
|
-
.then(resolve)
|
|
90
|
-
.catch(reject);
|
|
91
|
-
}, interval);
|
|
72
|
+
return result;
|
|
92
73
|
});
|
|
93
|
-
|
|
74
|
+
|
|
75
|
+
return res;
|
|
76
|
+
},
|
|
77
|
+
[apiConfig, getContextString, contextCategories, textareaPurpose]
|
|
78
|
+
);
|
|
94
79
|
}
|