@anker-in/campaign-ui 0.0.33-alpha1 → 0.0.33-alpha3
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/cjs/components/chat/Markdown.d.ts +5 -0
- package/dist/cjs/components/chat/Messages.d.ts +3 -0
- package/dist/cjs/components/chat/Response.d.ts +2 -0
- package/dist/cjs/components/chat/action.d.ts +7 -3
- package/dist/cjs/components/chat/action.js +1 -1
- package/dist/cjs/components/chat/action.js.map +3 -3
- package/dist/cjs/components/chat/button.d.ts +3 -0
- package/dist/cjs/components/chat/button.js +2 -0
- package/dist/cjs/components/chat/button.js.map +7 -0
- package/dist/cjs/components/chat/index.d.ts +17 -3
- package/dist/cjs/components/chat/index.js +1 -5
- package/dist/cjs/components/chat/index.js.map +3 -3
- package/dist/cjs/components/chat/markdown.js +2 -0
- package/dist/cjs/components/chat/markdown.js.map +7 -0
- package/dist/cjs/components/chat/marksdown.d.ts +5 -0
- package/dist/cjs/components/chat/message.d.ts +2 -0
- package/dist/cjs/components/chat/messages.js +2 -0
- package/dist/cjs/components/chat/messages.js.map +7 -0
- package/dist/cjs/components/chat/props.d.ts +43 -0
- package/dist/cjs/components/chat/props.js +2 -0
- package/dist/cjs/components/chat/props.js.map +7 -0
- package/dist/cjs/components/chat/response copy.d.ts +2 -0
- package/dist/cjs/components/chat/response.js +2 -0
- package/dist/cjs/components/chat/response.js.map +7 -0
- package/dist/cjs/components/chat/rresponse.d.ts +2 -0
- package/dist/cjs/components/chat/suggestions.d.ts +3 -0
- package/dist/cjs/components/chat/suggestions.js +2 -0
- package/dist/cjs/components/chat/suggestions.js.map +7 -0
- package/dist/cjs/stories/chat.stories.d.ts +1 -0
- package/dist/cjs/stories/chat.stories.js +1 -1
- package/dist/cjs/stories/chat.stories.js.map +3 -3
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/components/chat/Markdown.d.ts +5 -0
- package/dist/esm/components/chat/Messages.d.ts +3 -0
- package/dist/esm/components/chat/Response.d.ts +2 -0
- package/dist/esm/components/chat/action.d.ts +7 -3
- package/dist/esm/components/chat/action.js +1 -1
- package/dist/esm/components/chat/action.js.map +3 -3
- package/dist/esm/components/chat/button.d.ts +3 -0
- package/dist/esm/components/chat/button.js +2 -0
- package/dist/esm/components/chat/button.js.map +7 -0
- package/dist/esm/components/chat/index.d.ts +17 -3
- package/dist/esm/components/chat/index.js +1 -5
- package/dist/esm/components/chat/index.js.map +3 -3
- package/dist/esm/components/chat/markdown.js +2 -0
- package/dist/esm/components/chat/markdown.js.map +7 -0
- package/dist/esm/components/chat/marksdown.d.ts +5 -0
- package/dist/esm/components/chat/message.d.ts +2 -0
- package/dist/esm/components/chat/messages.js +2 -0
- package/dist/esm/components/chat/messages.js.map +7 -0
- package/dist/esm/components/chat/props.d.ts +43 -0
- package/dist/esm/components/chat/props.js +2 -0
- package/dist/esm/components/chat/props.js.map +7 -0
- package/dist/esm/components/chat/response copy.d.ts +2 -0
- package/dist/esm/components/chat/response.js +2 -0
- package/dist/esm/components/chat/response.js.map +7 -0
- package/dist/esm/components/chat/rresponse.d.ts +2 -0
- package/dist/esm/components/chat/suggestions.d.ts +3 -0
- package/dist/esm/components/chat/suggestions.js +2 -0
- package/dist/esm/components/chat/suggestions.js.map +7 -0
- package/dist/esm/stories/chat.stories.d.ts +1 -0
- package/dist/esm/stories/chat.stories.js +1 -1
- package/dist/esm/stories/chat.stories.js.map +2 -2
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/src/components/chat/action.tsx +33 -12
- package/src/components/chat/button.tsx +23 -0
- package/src/components/chat/index.tsx +78 -68
- package/src/components/chat/markdown.tsx +36 -0
- package/src/components/chat/messages.tsx +167 -0
- package/src/components/chat/props.ts +51 -0
- package/src/components/chat/response.tsx +17 -0
- package/src/components/chat/suggestions.tsx +34 -0
- package/src/stories/chat.stories.tsx +4 -4
- package/src/styles/css/messages.css +4 -0
- package/src/styles/css/suggestions.css +1 -0
- package/style.css +14 -708
- package/dist/cjs/components/chat/chatContext.js +0 -2
- package/dist/cjs/components/chat/chatContext.js.map +0 -7
- package/dist/cjs/components/theme.js +0 -2
- package/dist/cjs/components/theme.js.map +0 -7
- package/dist/esm/components/chat/chatContext.js +0 -2
- package/dist/esm/components/chat/chatContext.js.map +0 -7
- package/dist/esm/components/theme.js +0 -2
- package/dist/esm/components/theme.js.map +0 -7
- package/src/components/chat/chatContext.tsx +0 -161
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var p=Object.create;var a=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var h=(e,t)=>{for(var o in t)a(e,o,{get:t[o],enumerable:!0})},i=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of d(t))!R.call(e,n)&&n!==o&&a(e,n,{get:()=>t[n],enumerable:!(r=C(t,n))||r.enumerable});return e};var x=(e,t,o)=>(o=e!=null?p(l(e)):{},i(t||!e||!e.__esModule?a(o,"default",{value:e,enumerable:!0}):o,e)),u=e=>i(a({},"__esModule",{value:!0}),e);var I={};h(I,{ChatContext:()=>s,useChatContext:()=>f});module.exports=u(I);var c=x(require("react"));const s=c.default.createContext(void 0);function f(){const e=c.default.useContext(s);if(e===void 0)throw new Error("Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?");return e}
|
|
2
|
-
//# sourceMappingURL=chatContext.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/chat/chatContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react'\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[]\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string\n\n /**\n * The message to display when an error occurs.\n * @default \"\u274C An error occurred. Please try again.\"\n */\n error?: string\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>\n icons: Required<CopilotChatIcons>\n open: boolean\n setOpen: (_open: boolean) => void\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined)\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext)\n if (context === undefined) {\n throw new Error('Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?')\n }\n return context\n}\n\nexport interface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels\n icons?: CopilotChatIcons\n children?: React.ReactNode\n open: boolean\n setOpen: (_open: boolean) => void\n}\n\n// export const ChatContextProvider = ({\n// // temperature,\n// // instructions,\n// // maxFeedback,\n// labels,\n// icons,\n// children,\n// open,\n// setOpen,\n// }: ChatContextProps) => {\n// const context = {\n// labels: {\n// ...{\n// initial: \"\",\n// title: \"CopilotKit\",\n// placeholder: \"Type a message...\",\n// error: \"\u274C An error occurred. Please try again.\",\n// stopGenerating: \"Stop generating\",\n// regenerateResponse: \"Regenerate response\",\n// },\n// ...labels,\n// },\n\n// icons: {\n// ...icons,\n// },\n// open,\n// setOpen,\n// };\n// return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n// };\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,mBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAkB,oBA6GX,MAAMH,EAAc,EAAAI,QAAM,cAAuC,MAAS,EAE1E,SAASH,GAA8B,CAC5C,MAAMI,EAAU,EAAAD,QAAM,WAAWJ,CAAW,EAC5C,GAAIK,IAAY,OACd,MAAM,IAAI,MAAM,0FAA0F,EAE5G,OAAOA,CACT",
|
|
6
|
-
"names": ["chatContext_exports", "__export", "ChatContext", "useChatContext", "__toCommonJS", "import_react", "React", "context"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var m=Object.create;var o=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var u=(e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})},d=(e,t,r,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of h(t))!f.call(e,a)&&a!==r&&o(e,a,{get:()=>t[a],enumerable:!(c=s(t,a))||c.enumerable});return e};var l=(e,t,r)=>(r=e!=null?m(p(e)):{},d(t||!e||!e.__esModule?o(r,"default",{value:e,enumerable:!0}):r,e)),i=e=>d(o({},"__esModule",{value:!0}),e);var T={};u(T,{default:()=>R});module.exports=i(T);var n=require("react/jsx-runtime"),b=l(require("react"));const y=({brand:e,children:t})=>(b.useLayoutEffect(()=>{document.querySelector("html")?.setAttribute("data-brand-theme",e)},[]),(0,n.jsx)(n.Fragment,{children:t}));var R=y;
|
|
2
|
-
//# sourceMappingURL=theme.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/theme.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react'\nimport type { Brand } from '../helpers/constants.js'\n\ninterface ThemeProps {\n brand: Brand\n children: React.ReactNode\n}\n/**\n *\n * @param param\n * @returns\n */\nconst Theme = ({ brand, children }: ThemeProps) => {\n React.useLayoutEffect(() => {\n document.querySelector('html')?.setAttribute('data-brand-theme', brand)\n }, [])\n return <>{children}</>\n}\n\nexport default Theme\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAgBS,IAAAI,EAAA,6BAhBTC,EAAuB,oBAYvB,MAAMC,EAAQ,CAAC,CAAE,MAAAC,EAAO,SAAAC,CAAS,KAC/BH,EAAM,gBAAgB,IAAM,CAC1B,SAAS,cAAc,MAAM,GAAG,aAAa,mBAAoBE,CAAK,CACxE,EAAG,CAAC,CAAC,KACE,mBAAG,SAAAC,EAAS,GAGrB,IAAON,EAAQI",
|
|
6
|
-
"names": ["theme_exports", "__export", "theme_default", "__toCommonJS", "import_jsx_runtime", "React", "Theme", "brand", "children"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import t from"react";const o=t.createContext(void 0);function a(){const e=t.useContext(o);if(e===void 0)throw new Error("Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?");return e}export{o as ChatContext,a as useChatContext};
|
|
2
|
-
//# sourceMappingURL=chatContext.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/chat/chatContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react'\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[]\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string\n\n /**\n * The message to display when an error occurs.\n * @default \"\u274C An error occurred. Please try again.\"\n */\n error?: string\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>\n icons: Required<CopilotChatIcons>\n open: boolean\n setOpen: (_open: boolean) => void\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined)\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext)\n if (context === undefined) {\n throw new Error('Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?')\n }\n return context\n}\n\nexport interface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels\n icons?: CopilotChatIcons\n children?: React.ReactNode\n open: boolean\n setOpen: (_open: boolean) => void\n}\n\n// export const ChatContextProvider = ({\n// // temperature,\n// // instructions,\n// // maxFeedback,\n// labels,\n// icons,\n// children,\n// open,\n// setOpen,\n// }: ChatContextProps) => {\n// const context = {\n// labels: {\n// ...{\n// initial: \"\",\n// title: \"CopilotKit\",\n// placeholder: \"Type a message...\",\n// error: \"\u274C An error occurred. Please try again.\",\n// stopGenerating: \"Stop generating\",\n// regenerateResponse: \"Regenerate response\",\n// },\n// ...labels,\n// },\n\n// icons: {\n// ...icons,\n// },\n// open,\n// setOpen,\n// };\n// return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n// };\n"],
|
|
5
|
-
"mappings": "AAAA,OAAOA,MAAW,QA6GX,MAAMC,EAAcD,EAAM,cAAuC,MAAS,EAE1E,SAASE,GAA8B,CAC5C,MAAMC,EAAUH,EAAM,WAAWC,CAAW,EAC5C,GAAIE,IAAY,OACd,MAAM,IAAI,MAAM,0FAA0F,EAE5G,OAAOA,CACT",
|
|
6
|
-
"names": ["React", "ChatContext", "useChatContext", "context"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Fragment as o,jsx as n}from"react/jsx-runtime";import*as r from"react";const a=({brand:e,children:t})=>(r.useLayoutEffect(()=>{document.querySelector("html")?.setAttribute("data-brand-theme",e)},[]),n(o,{children:t}));var c=a;export{c as default};
|
|
2
|
-
//# sourceMappingURL=theme.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/theme.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react'\nimport type { Brand } from '../helpers/constants.js'\n\ninterface ThemeProps {\n brand: Brand\n children: React.ReactNode\n}\n/**\n *\n * @param param\n * @returns\n */\nconst Theme = ({ brand, children }: ThemeProps) => {\n React.useLayoutEffect(() => {\n document.querySelector('html')?.setAttribute('data-brand-theme', brand)\n }, [])\n return <>{children}</>\n}\n\nexport default Theme\n"],
|
|
5
|
-
"mappings": "AAgBS,mBAAAA,EAAA,OAAAC,MAAA,oBAhBT,UAAYC,MAAW,QAYvB,MAAMC,EAAQ,CAAC,CAAE,MAAAC,EAAO,SAAAC,CAAS,KAC/BH,EAAM,gBAAgB,IAAM,CAC1B,SAAS,cAAc,MAAM,GAAG,aAAa,mBAAoBE,CAAK,CACxE,EAAG,CAAC,CAAC,EACEH,EAAAD,EAAA,CAAG,SAAAK,EAAS,GAGrB,IAAOC,EAAQH",
|
|
6
|
-
"names": ["Fragment", "jsx", "React", "Theme", "brand", "children", "theme_default"]
|
|
7
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Icons for CopilotChat component.
|
|
5
|
-
*/
|
|
6
|
-
export interface CopilotChatIcons {
|
|
7
|
-
/**
|
|
8
|
-
* The icon to use for the open chat button.
|
|
9
|
-
* @default <OpenIcon />
|
|
10
|
-
*/
|
|
11
|
-
openIcon?: React.ReactNode
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The icon to use for the close chat button.
|
|
15
|
-
* @default <CloseIcon />
|
|
16
|
-
*/
|
|
17
|
-
closeIcon?: React.ReactNode
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The icon to use for the close chat button in the header.
|
|
21
|
-
* @default <HeaderCloseIcon />
|
|
22
|
-
*/
|
|
23
|
-
headerCloseIcon?: React.ReactNode
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The icon to use for the send button.
|
|
27
|
-
* @default <SendIcon />
|
|
28
|
-
*/
|
|
29
|
-
sendIcon?: React.ReactNode
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The icon to use for the activity indicator.
|
|
33
|
-
* @default <ActivityIcon />
|
|
34
|
-
*/
|
|
35
|
-
activityIcon?: React.ReactNode
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The icon to use for the spinner.
|
|
39
|
-
* @default <SpinnerIcon />
|
|
40
|
-
*/
|
|
41
|
-
spinnerIcon?: React.ReactNode
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The icon to use for the stop button.
|
|
45
|
-
* @default <StopIcon />
|
|
46
|
-
*/
|
|
47
|
-
stopIcon?: React.ReactNode
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* The icon to use for the regenerate button.
|
|
51
|
-
* @default <RegenerateIcon />
|
|
52
|
-
*/
|
|
53
|
-
regenerateIcon?: React.ReactNode
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* The icons to use for push to talk.
|
|
57
|
-
* @default <PushToTalkIcon />
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
pushToTalkIcon?: React.ReactNode
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Labels for CopilotChat component.
|
|
65
|
-
*/
|
|
66
|
-
export interface CopilotChatLabels {
|
|
67
|
-
/**
|
|
68
|
-
* The initial message(s) to display in the chat window.
|
|
69
|
-
*/
|
|
70
|
-
initial?: string | string[]
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* The title to display in the header.
|
|
74
|
-
* @default "CopilotKit"
|
|
75
|
-
*/
|
|
76
|
-
title?: string
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The placeholder to display in the input.
|
|
80
|
-
* @default "Type a message..."
|
|
81
|
-
*/
|
|
82
|
-
placeholder?: string
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* The message to display when an error occurs.
|
|
86
|
-
* @default "❌ An error occurred. Please try again."
|
|
87
|
-
*/
|
|
88
|
-
error?: string
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* The label to display on the stop button.
|
|
92
|
-
* @default "Stop generating"
|
|
93
|
-
*/
|
|
94
|
-
stopGenerating?: string
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* The label to display on the regenerate button.
|
|
98
|
-
* @default "Regenerate response"
|
|
99
|
-
*/
|
|
100
|
-
regenerateResponse?: string
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
interface ChatContext {
|
|
104
|
-
labels: Required<CopilotChatLabels>
|
|
105
|
-
icons: Required<CopilotChatIcons>
|
|
106
|
-
open: boolean
|
|
107
|
-
setOpen: (_open: boolean) => void
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export const ChatContext = React.createContext<ChatContext | undefined>(undefined)
|
|
111
|
-
|
|
112
|
-
export function useChatContext(): ChatContext {
|
|
113
|
-
const context = React.useContext(ChatContext)
|
|
114
|
-
if (context === undefined) {
|
|
115
|
-
throw new Error('Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?')
|
|
116
|
-
}
|
|
117
|
-
return context
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export interface ChatContextProps {
|
|
121
|
-
// temperature?: number;
|
|
122
|
-
// instructions?: string;
|
|
123
|
-
// maxFeedback?: number;
|
|
124
|
-
labels?: CopilotChatLabels
|
|
125
|
-
icons?: CopilotChatIcons
|
|
126
|
-
children?: React.ReactNode
|
|
127
|
-
open: boolean
|
|
128
|
-
setOpen: (_open: boolean) => void
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// export const ChatContextProvider = ({
|
|
132
|
-
// // temperature,
|
|
133
|
-
// // instructions,
|
|
134
|
-
// // maxFeedback,
|
|
135
|
-
// labels,
|
|
136
|
-
// icons,
|
|
137
|
-
// children,
|
|
138
|
-
// open,
|
|
139
|
-
// setOpen,
|
|
140
|
-
// }: ChatContextProps) => {
|
|
141
|
-
// const context = {
|
|
142
|
-
// labels: {
|
|
143
|
-
// ...{
|
|
144
|
-
// initial: "",
|
|
145
|
-
// title: "CopilotKit",
|
|
146
|
-
// placeholder: "Type a message...",
|
|
147
|
-
// error: "❌ An error occurred. Please try again.",
|
|
148
|
-
// stopGenerating: "Stop generating",
|
|
149
|
-
// regenerateResponse: "Regenerate response",
|
|
150
|
-
// },
|
|
151
|
-
// ...labels,
|
|
152
|
-
// },
|
|
153
|
-
|
|
154
|
-
// icons: {
|
|
155
|
-
// ...icons,
|
|
156
|
-
// },
|
|
157
|
-
// open,
|
|
158
|
-
// setOpen,
|
|
159
|
-
// };
|
|
160
|
-
// return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;
|
|
161
|
-
// };
|