Sign In

@copilotkit/react-core

Package Overview
Dependencies
Maintainers
1
Versions
1115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@copilotkit/react-core - npm Package Compare versions

Comparing version
0.17.1-alpha.1
to
0.17.1
+113
dist/chunk-LMZN4NSM.mjs
import { ChatCompletionClient } from './chunk-TKXPMMND.mjs';
import { __async, __spreadValues } from './chunk-MRXNTQOX.mjs';
import { useState, useRef } from 'react';
import { nanoid } from 'nanoid';
function useChat(options) {
const [messages, setMessages] = useState([]);
const [input, setInput] = useState("");
const [isLoading, setIsLoading] = useState(false);
const abortControllerRef = useRef();
const runChatCompletion = (messages2) => __async(this, null, function* () {
return new Promise((resolve, reject) => {
setIsLoading(true);
const abortController = new AbortController();
abortControllerRef.current = abortController;
const assistantMessage = {
id: nanoid(),
createdAt: /* @__PURE__ */ new Date(),
content: "",
role: "assistant"
};
setMessages([...messages2, __spreadValues({}, assistantMessage)]);
const messagesWithContext = [...options.initialMessages || [], ...messages2];
const client = new ChatCompletionClient({});
const cleanup = () => {
client.off("content");
client.off("end");
client.off("error");
client.off("function");
abortControllerRef.current = void 0;
};
abortController.signal.addEventListener("abort", () => {
setIsLoading(false);
cleanup();
reject(new DOMException("Aborted", "AbortError"));
});
client.on("content", (content) => {
assistantMessage.content += content;
setMessages([...messages2, __spreadValues({}, assistantMessage)]);
});
client.on("end", () => {
setIsLoading(false);
cleanup();
resolve(__spreadValues({}, assistantMessage));
});
client.on("error", (error) => {
setIsLoading(false);
cleanup();
reject(error);
});
client.on("function", (functionCall) => __async(this, null, function* () {
assistantMessage.function_call = {
name: functionCall.name,
arguments: JSON.stringify(functionCall.arguments)
};
setMessages([...messages2, __spreadValues({}, assistantMessage)]);
setIsLoading(false);
cleanup();
resolve(__spreadValues({}, assistantMessage));
}));
client.fetch({
copilotConfig: options.copilotConfig,
messages: messagesWithContext,
functions: options.functions,
headers: options.headers,
signal: abortController.signal
});
});
});
const runChatCompletionAndHandleFunctionCall = (messages2) => __async(this, null, function* () {
const message = yield runChatCompletion(messages2);
if (message.function_call && options.onFunctionCall) {
yield options.onFunctionCall(messages2, message.function_call);
}
});
const append = (message) => __async(this, null, function* () {
if (isLoading) {
return;
}
const newMessages = [...messages, message];
setMessages(newMessages);
return runChatCompletionAndHandleFunctionCall(newMessages);
});
const reload = () => __async(this, null, function* () {
if (isLoading || messages.length === 0) {
return;
}
let newMessages = [...messages];
const lastMessage = messages[messages.length - 1];
if (lastMessage.role === "assistant") {
newMessages = newMessages.slice(0, -1);
}
setMessages(newMessages);
return runChatCompletionAndHandleFunctionCall(newMessages);
});
const stop = () => {
var _a;
(_a = abortControllerRef.current) == null ? void 0 : _a.abort();
};
return {
messages,
append,
reload,
stop,
isLoading,
input,
setInput
};
}
export { useChat };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-LMZN4NSM.mjs.map
{"version":3,"sources":["../src/hooks/use-chat.ts"],"names":["messages"],"mappings":";;;;;;;;;AAAA,SAAS,QAAQ,gBAAgB;AAEjC,SAAS,cAAc;AAgFhB,SAAS,QAAQ,SAA0D;AAChF,QAAM,CAAC,UAAU,WAAW,IAAI,SAAoB,CAAC,CAAC;AACtD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,EAAE;AACrC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,qBAAqB,OAAwB;AAEnD,QAAM,oBAAoB,CAAOA,cAA0C;AACzE,WAAO,IAAI,QAAiB,CAAC,SAAS,WAAW;AAC/C,mBAAa,IAAI;AAEjB,YAAM,kBAAkB,IAAI,gBAAgB;AAC5C,yBAAmB,UAAU;AAE7B,YAAM,mBAA4B;AAAA,QAChC,IAAI,OAAO;AAAA,QACX,WAAW,oBAAI,KAAK;AAAA,QACpB,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAGA,kBAAY,CAAC,GAAGA,WAAU,mBAAK,iBAAkB,CAAC;AAElD,YAAM,sBAAsB,CAAC,GAAI,QAA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kBAAkBA,SAAQ;AAChD,QAAI,QAAQ,iBAAiB,QAAQ,gBAAgB;AACnD,YAAM,QAAQ,eAAeA,WAAU,QAAQ,aAAa;AAAA,IAC9D;AAAA,EACF;AAEA,QAAM,SAAS,CAAO,YAAoC;AACxD,QAAI,WAAW;AACb;AAAA,IACF;AACA,UAAM,cAAc,CAAC,GAAG,UAAU,OAAO;AACzC,gBAAY,WAAW;AACvB,WAAO,uCAAuC,WAAW;AAAA,EAC3D;AAEA,QAAM,SAAS,MAA2B;AACxC,QAAI,aAAa,SAAS,WAAW,GAAG;AACtC;AAAA,IACF;AACA,QAAI,cAAc,CAAC,GAAG,QAAQ;AAC9B,UAAM,cAAc,SAAS,SAAS,SAAS,CAAC;AAEhD,QAAI,YAAY,SAAS,aAAa;AACpC,oBAAc,YAAY,MAAM,GAAG,EAAE;AAAA,IACvC;AACA,gBAAY,WAAW;AAEvB,WAAO,uCAAuC,WAAW;AAAA,EAC3D;AAEA,QAAM,OAAO,MAAY;AAlM3B;AAmMI,6BAAmB,YAAnB,mBAA4B;AAAA,EAC9B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF","sourcesContent":["import { useRef, useState } from \"react\";\nimport { Message, Function, FunctionCallHandler } from \"../types\";\nimport { nanoid } from \"nanoid\";\nimport { ChatCompletionClient } from \"../openai/chat-completion-client\";\nimport { CopilotApiConfig } from \"../context\";\n\nexport type UseChatOptions = {\n /**\n * The API endpoint that accepts a `{ messages: Message[] }` object and returns\n * a stream of tokens of the AI chat response. Defaults to `/api/chat`.\n */\n api?: string;\n /**\n * A unique identifier for the chat. If not provided, a random one will be\n * generated. When provided, the `useChat` hook with the same `id` will\n * have shared states across components.\n */\n id?: string;\n /**\n * System messages of the chat. Defaults to an empty array.\n */\n initialMessages?: Message[];\n /**\n * Callback function to be called when a function call is received.\n * If the function returns a `ChatRequest` object, the request will be sent\n * automatically to the API and will be used to update the chat.\n */\n onFunctionCall?: FunctionCallHandler;\n /**\n * HTTP headers to be sent with the API request.\n */\n headers?: Record<string, string> | Headers;\n /**\n * Extra body object to be sent with the API request.\n * @example\n * Send a `sessionId` to the API along with the messages.\n * ```js\n * useChat({\n * body: {\n * sessionId: '123',\n * }\n * })\n * ```\n */\n body?: object;\n /**\n * Function definitions to be sent to the API.\n */\n functions?: Function[];\n};\n\nexport type UseChatHelpers = {\n /** Current messages in the chat */\n messages: Message[];\n /**\n * Append a user message to the chat list. This triggers the API call to fetch\n * the assistant's response.\n * @param message The message to append\n */\n append: (message: Message) => Promise<void>;\n /**\n * Reload the last AI chat response for the given chat history. If the last\n * message isn't from the assistant, it will request the API to generate a\n * new response.\n */\n reload: () => Promise<void>;\n /**\n * Abort the current request immediately, keep the generated tokens if any.\n */\n stop: () => void;\n /** The current value of the input */\n input: string;\n /** setState-powered method to update the input value */\n setInput: React.Dispatch<React.SetStateAction<string>>;\n /** Whether the API request is in progress */\n isLoading: boolean;\n};\n\nexport type UseChatOptionsWithCopilotConfig = UseChatOptions & {\n copilotConfig: CopilotApiConfig;\n};\n\nexport function useChat(options: UseChatOptionsWithCopilotConfig): UseChatHelpers {\n const [messages, setMessages] = useState<Message[]>([]);\n const [input, setInput] = useState(\"\");\n const [isLoading, setIsLoading] = useState(false);\n const abortControllerRef = useRef<AbortController>();\n\n const runChatCompletion = async (messages: Message[]): Promise<Message> => {\n return new Promise<Message>((resolve, reject) => {\n setIsLoading(true);\n\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n const assistantMessage: Message = {\n id: nanoid(),\n createdAt: new Date(),\n content: \"\",\n role: \"assistant\",\n };\n\n // Assistant messages are always copied when using setState\n setMessages([...messages, { ...assistantMessage }]);\n\n const messagesWithContext = [...(options.initialMessages || []), ...messages];\n\n const client = new ChatCompletionClient({});\n\n const cleanup = () => {\n client.off(\"content\");\n client.off(\"end\");\n client.off(\"error\");\n client.off(\"function\");\n\n abortControllerRef.current = undefined;\n };\n\n abortController.signal.addEventListener(\"abort\", () => {\n setIsLoading(false);\n cleanup();\n reject(new DOMException(\"Aborted\", \"AbortError\"));\n });\n\n client.on(\"content\", (content) => {\n assistantMessage.content += content;\n setMessages([...messages, { ...assistantMessage }]);\n });\n\n client.on(\"end\", () => {\n setIsLoading(false);\n cleanup();\n resolve({ ...assistantMessage });\n });\n\n client.on(\"error\", (error) => {\n setIsLoading(false);\n cleanup();\n reject(error);\n });\n\n client.on(\"function\", async (functionCall) => {\n assistantMessage.function_call = {\n name: functionCall.name,\n arguments: JSON.stringify(functionCall.arguments),\n };\n setMessages([...messages, { ...assistantMessage }]);\n // quit early if we get a function call\n setIsLoading(false);\n cleanup();\n resolve({ ...assistantMessage });\n });\n\n client.fetch({\n copilotConfig: options.copilotConfig,\n messages: messagesWithContext,\n functions: options.functions,\n headers: options.headers,\n signal: abortController.signal,\n });\n });\n };\n\n const runChatCompletionAndHandleFunctionCall = async (messages: Message[]): Promise<void> => {\n const message = await runChatCompletion(messages);\n if (message.function_call && options.onFunctionCall) {\n await options.onFunctionCall(messages, message.function_call);\n }\n };\n\n const append = async (message: Message): Promise<void> => {\n if (isLoading) {\n return;\n }\n const newMessages = [...messages, message];\n setMessages(newMessages);\n return runChatCompletionAndHandleFunctionCall(newMessages);\n };\n\n const reload = async (): Promise<void> => {\n if (isLoading || messages.length === 0) {\n return;\n }\n let newMessages = [...messages];\n const lastMessage = messages[messages.length - 1];\n\n if (lastMessage.role === \"assistant\") {\n newMessages = newMessages.slice(0, -1);\n }\n setMessages(newMessages);\n\n return runChatCompletionAndHandleFunctionCall(newMessages);\n };\n\n const stop = (): void => {\n abortControllerRef.current?.abort();\n };\n\n return {\n messages,\n append,\n reload,\n stop,\n isLoading,\n input,\n setInput,\n };\n}\n"]}
import { defaultCopilotContextCategories } from './chunk-QTET3FBV.mjs';
import { CopilotContext } from './chunk-6A4PCNMZ.mjs';
import { useChat } from './chunk-LMZN4NSM.mjs';
import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
import { useContext, useMemo } from 'react';
function useCopilotChat(_a) {
var _b = _a, {
makeSystemMessage
} = _b, options = __objRest(_b, [
"makeSystemMessage"
]);
const {
getContextString,
getChatCompletionFunctionDescriptions,
getFunctionCallHandler,
copilotApiConfig
} = useContext(CopilotContext);
const systemMessage = useMemo(() => {
const systemMessageMaker = makeSystemMessage || defaultSystemMessage;
const contextString = getContextString([], defaultCopilotContextCategories);
return {
id: "system",
content: systemMessageMaker(contextString),
role: "system"
};
}, [getContextString, makeSystemMessage]);
const functionDescriptions = useMemo(() => {
return getChatCompletionFunctionDescriptions();
}, [getChatCompletionFunctionDescriptions]);
const { messages, append, reload, stop, isLoading, input, setInput } = useChat(__spreadProps(__spreadValues({}, options), {
copilotConfig: copilotApiConfig,
id: options.id,
initialMessages: [systemMessage].concat(options.initialMessages || []),
functions: functionDescriptions,
onFunctionCall: getFunctionCallHandler(),
headers: __spreadValues({}, options.headers),
body: __spreadValues({}, options.body)
}));
const visibleMessages = messages.filter(
(message) => message.role === "user" || message.role === "assistant"
);
return {
visibleMessages,
append,
reload,
stop,
isLoading,
input,
setInput
};
}
function defaultSystemMessage(contextString) {
return `
Please act as an efficient, competent, conscientious, and industrious professional assistant.
Help the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.
Always be polite and respectful, and prefer brevity over verbosity.
The user has provided you with the following context:
\`\`\`
${contextString}
\`\`\`
They have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.
Please assist them as best you can.
You can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.
If you would like to call a function, call it without saying anything else.
`;
}
export { defaultSystemMessage, useCopilotChat };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-SFQOMKM2.mjs.map
{"version":3,"sources":["../src/hooks/use-copilot-chat.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,SAAS,kBAAkB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AWF","sourcesContent":["import { useMemo, useContext } from \"react\";\nimport { CopilotContext, CopilotContextParams } from \"../context/copilot-context\";\nimport { Message } from \"../types\";\nimport { UseChatOptions, useChat } from \"./use-chat\";\nimport { defaultCopilotContextCategories } from \"../components\";\nimport { ChatCompletionCreateParams } from \"openai/resources/chat\";\n\nexport interface UseCopilotChatOptions extends UseChatOptions {\n makeSystemMessage?: (contextString: string) => string;\n}\n\nexport interface UseCopilotChatReturn {\n visibleMessages: Message[];\n append: (message: Message) => Promise<void>;\n reload: () => Promise<void>;\n stop: () => void;\n isLoading: boolean;\n input: string;\n setInput: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport function useCopilotChat({\n makeSystemMessage,\n ...options\n}: UseCopilotChatOptions): UseCopilotChatReturn {\n const {\n getContextString,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n copilotApiConfig,\n } = useContext(CopilotContext);\n\n const systemMessage: Message = useMemo(() => {\n const systemMessageMaker = makeSystemMessage || defaultSystemMessage;\n const contextString = getContextString([], defaultCopilotContextCategories); // TODO: make the context categories configurable\n\n return {\n id: \"system\",\n content: systemMessageMaker(contextString),\n role: \"system\",\n };\n }, [getContextString, makeSystemMessage]);\n\n const functionDescriptions: ChatCompletionCreateParams.Function[] = useMemo(() => {\n return getChatCompletionFunctionDescriptions();\n }, [getChatCompletionFunctionDescriptions]);\n\n const { messages, append, reload, stop, isLoading, input, setInput } = useChat({\n ...options,\n copilotConfig: copilotApiConfig,\n id: options.id,\n initialMessages: [systemMessage].concat(options.initialMessages || []),\n functions: functionDescriptions,\n onFunctionCall: getFunctionCallHandler(),\n headers: { ...options.headers },\n body: {\n ...options.body,\n },\n });\n\n const visibleMessages = messages.filter(\n (message) => message.role === \"user\" || message.role === \"assistant\",\n );\n\n return {\n visibleMessages,\n append,\n reload,\n stop,\n isLoading,\n input,\n setInput,\n };\n}\n\nexport function defaultSystemMessage(contextString: string): string {\n return `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.\n\nPlease assist them as best you can.\n\nYou can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.\n\nIf you would like to call a function, call it without saying anything else.\n`;\n}\n"]}
+160
-164

@@ -1,14 +0,12 @@

Debugger attached.
> @copilotkit/react-core@0.17.1-alpha.0 build /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core
> @copilotkit/react-core@0.17.1 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-core
> tsup --treeshake
Debugger attached.
CLI Building entry: src/index.tsx, src/components/index.ts, src/context/copilot-context.tsx, src/context/index.ts, src/hooks/index.ts, src/hooks/use-chat.ts, src/hooks/use-copilot-chat.ts, src/hooks/use-flat-category-store.ts, src/hooks/use-make-copilot-actionable.ts, src/hooks/use-make-copilot-document-readable.ts, src/hooks/use-make-copilot-readable.ts, src/hooks/use-tree.ts, src/openai/chat-completion-client.ts, src/openai/chat-completion-stream.ts, src/openai/chat-completion-transport.ts, src/openai/index.tsx, src/openai-assistants/index.ts, src/types/annotated-function.ts, src/types/base.ts, src/types/document-pointer.ts, src/types/index.ts, src/types/message.ts, src/utils/utils.test.ts, src/utils/utils.ts, src/components/copilot-provider/copilot-provider-props.tsx, src/components/copilot-provider/copilot-provider.tsx, src/components/copilot-provider/index.ts, src/components/copilot-provider/standard-copilot-api-config.tsx, src/openai-assistants/hooks/index.ts, src/openai-assistants/hooks/use-assistants.ts, src/openai-assistants/hooks/use-copilot-chat-v2.ts, src/openai-assistants/utils/index.ts, src/openai-assistants/utils/process-message-stream.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v6.7.0
CLI Using tsup config: /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core/tsup.config.ts
CLI Target: es6
CLI Cleaning output folder
ESM Build start
CLI Building entry: src/index.tsx, src/components/index.ts, src/context/copilot-context.tsx, src/context/index.ts, src/hooks/index.ts, src/hooks/use-chat.ts, src/hooks/use-copilot-chat.ts, src/hooks/use-flat-category-store.ts, src/hooks/use-make-copilot-actionable.ts, src/hooks/use-make-copilot-document-readable.ts, src/hooks/use-make-copilot-readable.ts, src/hooks/use-tree.ts, src/openai/chat-completion-client.ts, src/openai/chat-completion-stream.ts, src/openai/chat-completion-transport.ts, src/openai/index.tsx, src/openai-assistants/index.ts, src/types/annotated-function.ts, src/types/base.ts, src/types/document-pointer.ts, src/types/index.ts, src/types/message.ts, src/utils/utils.test.ts, src/utils/utils.ts, src/components/copilot-provider/copilot-provider-props.tsx, src/components/copilot-provider/copilot-provider.tsx, src/components/copilot-provider/index.ts, src/components/copilot-provider/standard-copilot-api-config.tsx, src/openai-assistants/hooks/index.ts, src/openai-assistants/hooks/use-assistants.ts, src/openai-assistants/hooks/use-copilot-chat-v2.ts, src/openai-assistants/utils/index.ts, src/openai-assistants/utils/process-message-stream.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v6.7.0
CLI Using tsup config: /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-core/tsup.config.ts
CLI Target: es6
CLI Cleaning output folder
ESM Build start
Module level directives cause errors when bundled, "use client" in "dist/components/copilot-provider/copilot-provider-props.mjs" was ignored.

@@ -36,155 +34,153 @@ Module level directives cause errors when bundled, "use client" in "dist/components/copilot-provider/copilot-provider.mjs" was ignored.

Generated an empty chunk: "chunk-SPCZTZCY".
ESM dist/components/copilot-provider/copilot-provider-props.mjs 84.00 B
ESM dist/types/annotated-function.mjs 80.00 B
ESM dist/types/base.mjs 66.00 B
ESM dist/types/message.mjs 69.00 B
ESM dist/utils/utils.test.mjs 202.00 B
ESM dist/types/document-pointer.mjs 78.00 B
ESM dist/utils/utils.mjs 67.00 B
ESM dist/chunk-BABVSMJR.mjs 76.00 B
ESM dist/chunk-FRAKUJWH.mjs 76.00 B
ESM dist/chunk-VNRDQJXW.mjs 76.00 B
ESM dist/chunk-5UGLWBZJ.mjs 76.00 B
ESM dist/chunk-PUFR5OAI.mjs 76.00 B
ESM dist/chunk-JD7BAH7U.mjs 76.00 B
ESM dist/chunk-SPCZTZCY.mjs 76.00 B
ESM dist/chunk-MRXNTQOX.mjs 1.92 KB
ESM dist/chunk-F2JIAPZQ.mjs 435.00 B
ESM dist/chunk-EFZPSZWO.mjs 76.00 B
ESM dist/openai-assistants/utils/process-message-stream.mjs 183.00 B
ESM dist/components/copilot-provider/index.mjs 369.00 B
ESM dist/components/copilot-provider/standard-copilot-api-config.mjs 192.00 B
ESM dist/components/copilot-provider/copilot-provider.mjs 345.00 B
ESM dist/openai-assistants/utils/index.mjs 201.00 B
ESM dist/openai-assistants/index.mjs 570.00 B
ESM dist/chunk-7GFKOIO7.mjs 76.00 B
ESM dist/types/index.mjs 98.00 B
ESM dist/hooks/use-make-copilot-actionable.mjs 218.00 B
ESM dist/hooks/use-make-copilot-readable.mjs 214.00 B
ESM dist/hooks/use-make-copilot-document-readable.mjs 231.00 B
ESM dist/openai-assistants/hooks/index.mjs 547.00 B
ESM dist/hooks/use-tree.mjs 170.00 B
ESM dist/openai-assistants/hooks/use-copilot-chat-v2.mjs 548.00 B
ESM dist/openai/chat-completion-stream.mjs 209.00 B
ESM dist/openai/chat-completion-transport.mjs 183.00 B
ESM dist/openai/chat-completion-client.mjs 209.00 B
ESM dist/openai/index.mjs 224.00 B
ESM dist/index.mjs 1.11 KB
ESM dist/chunk-TU4DNDO7.mjs 4.33 KB
ESM dist/chunk-MZ5UN3BY.mjs 830.00 B
ESM dist/chunk-6SOQYBNX.mjs 1.24 KB
ESM dist/components/index.mjs 380.00 B
ESM dist/context/copilot-context.mjs 164.00 B
ESM dist/context/index.mjs 186.00 B
ESM dist/hooks/index.mjs 708.00 B
ESM dist/chunk-FP4EXCGS.mjs 954.00 B
ESM dist/chunk-7P4OYNP3.mjs 677.00 B
ESM dist/chunk-HW5IH6PV.mjs 626.00 B
ESM dist/hooks/use-chat.mjs 214.00 B
ESM dist/chunk-R75NEA76.mjs 2.71 KB
ESM dist/chunk-QTET3FBV.mjs 5.18 KB
ESM dist/hooks/use-copilot-chat.mjs 507.00 B
ESM dist/chunk-VUY2K2DI.mjs 3.89 KB
ESM dist/chunk-R2WOR4SW.mjs 3.69 KB
ESM dist/chunk-TKXPMMND.mjs 5.33 KB
ESM dist/hooks/use-flat-category-store.mjs 200.00 B
ESM dist/chunk-YULKJPY3.mjs 1.87 KB
ESM dist/chunk-VK25FIML.mjs 4.48 KB
ESM dist/chunk-6A4PCNMZ.mjs 1.30 KB
ESM dist/openai-assistants/hooks/use-assistants.mjs 2.55 KB
ESM dist/components/copilot-provider/copilot-provider-props.mjs.map 51.00 B
ESM dist/utils/utils.test.mjs.map 351.00 B
ESM dist/types/annotated-function.mjs.map 51.00 B
ESM dist/utils/utils.mjs.map 51.00 B
ESM dist/types/base.mjs.map 51.00 B
ESM dist/chunk-BABVSMJR.mjs.map 51.00 B
ESM dist/chunk-FRAKUJWH.mjs.map 51.00 B
ESM dist/chunk-VNRDQJXW.mjs.map 51.00 B
ESM dist/chunk-PUFR5OAI.mjs.map 51.00 B
ESM dist/chunk-JD7BAH7U.mjs.map 51.00 B
ESM dist/chunk-F2JIAPZQ.mjs.map 1.12 KB
ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
ESM dist/chunk-EFZPSZWO.mjs.map 51.00 B
ESM dist/openai-assistants/utils/process-message-stream.mjs.map 51.00 B
ESM dist/components/copilot-provider/index.mjs.map 51.00 B
ESM dist/components/copilot-provider/standard-copilot-api-config.mjs.map 51.00 B
ESM dist/components/copilot-provider/copilot-provider.mjs.map 51.00 B
ESM dist/openai-assistants/index.mjs.map 51.00 B
ESM dist/chunk-7GFKOIO7.mjs.map 51.00 B
ESM dist/types/index.mjs.map 51.00 B
ESM dist/hooks/use-make-copilot-actionable.mjs.map 51.00 B
ESM dist/hooks/use-make-copilot-readable.mjs.map 51.00 B
ESM dist/hooks/use-make-copilot-document-readable.mjs.map 51.00 B
ESM dist/openai-assistants/hooks/index.mjs.map 51.00 B
ESM dist/hooks/use-tree.mjs.map 51.00 B
ESM dist/types/message.mjs.map 51.00 B
ESM dist/openai-assistants/hooks/use-copilot-chat-v2.mjs.map 51.00 B
ESM dist/openai/chat-completion-stream.mjs.map 51.00 B
ESM dist/types/document-pointer.mjs.map 51.00 B
ESM dist/openai/chat-completion-transport.mjs.map 51.00 B
ESM dist/openai/chat-completion-client.mjs.map 51.00 B
ESM dist/chunk-5UGLWBZJ.mjs.map 51.00 B
ESM dist/index.mjs.map 51.00 B
ESM dist/chunk-SPCZTZCY.mjs.map 51.00 B
ESM dist/openai/index.mjs.map 51.00 B
ESM dist/chunk-TU4DNDO7.mjs.map 7.90 KB
ESM dist/chunk-MZ5UN3BY.mjs.map 1.26 KB
ESM dist/chunk-6SOQYBNX.mjs.map 2.07 KB
ESM dist/components/index.mjs.map 51.00 B
ESM dist/context/copilot-context.mjs.map 51.00 B
ESM dist/context/index.mjs.map 51.00 B
ESM dist/chunk-FP4EXCGS.mjs.map 1.67 KB
ESM dist/hooks/index.mjs.map 51.00 B
ESM dist/chunk-HW5IH6PV.mjs.map 1.47 KB
ESM dist/hooks/use-chat.mjs.map 51.00 B
ESM dist/chunk-R75NEA76.mjs.map 4.37 KB
ESM dist/openai-assistants/utils/index.mjs.map 51.00 B
ESM dist/hooks/use-copilot-chat.mjs.map 51.00 B
ESM dist/chunk-R2WOR4SW.mjs.map 8.47 KB
ESM dist/chunk-TKXPMMND.mjs.map 9.93 KB
ESM dist/hooks/use-flat-category-store.mjs.map 51.00 B
ESM dist/chunk-YULKJPY3.mjs.map 4.21 KB
ESM dist/chunk-VK25FIML.mjs.map 7.84 KB
ESM dist/chunk-VUY2K2DI.mjs.map 8.27 KB
ESM dist/chunk-6A4PCNMZ.mjs.map 4.26 KB
ESM dist/openai-assistants/hooks/use-assistants.mjs.map 4.67 KB
ESM dist/chunk-7P4OYNP3.mjs.map 1.42 KB
ESM dist/chunk-QTET3FBV.mjs.map 11.03 KB
ESM ⚡️ Build success in 405ms
DTS Build start
DTS ⚡️ Build success in 3554ms
DTS dist/index.d.ts 1.61 KB
DTS dist/components/copilot-provider/copilot-provider.d.ts 1.55 KB
DTS dist/components/copilot-provider/copilot-provider-props.d.ts 1.52 KB
DTS dist/context/copilot-context.d.ts 1.98 KB
DTS dist/hooks/use-copilot-chat.d.ts 955.00 B
DTS dist/hooks/use-make-copilot-actionable.d.ts 255.00 B
DTS dist/hooks/use-make-copilot-readable.d.ts 598.00 B
DTS dist/hooks/use-make-copilot-document-readable.d.ts 516.00 B
DTS dist/hooks/use-chat.d.ts 2.75 KB
DTS dist/types/annotated-function.d.ts 767.00 B
DTS dist/types/document-pointer.d.ts 181.00 B
DTS dist/types/base.d.ts 1.96 KB
DTS dist/openai-assistants/hooks/use-copilot-chat-v2.d.ts 1.41 KB
DTS dist/openai-assistants/utils/process-message-stream.d.ts 196.00 B
DTS dist/openai/chat-completion-stream.d.ts 694.00 B
DTS dist/openai/chat-completion-transport.d.ts 1.26 KB
DTS dist/hooks/use-tree.d.ts 543.00 B
DTS dist/components/index.d.ts 482.00 B
DTS dist/context/index.d.ts 281.00 B
DTS dist/hooks/index.d.ts 608.00 B
DTS dist/hooks/use-flat-category-store.d.ts 424.00 B
DTS dist/openai/chat-completion-client.d.ts 1.44 KB
DTS dist/openai/index.d.ts 438.00 B
DTS dist/openai-assistants/index.d.ts 262.00 B
DTS dist/types/index.d.ts 233.00 B
DTS dist/types/message.d.ts 12.00 B
DTS dist/utils/utils.test.d.ts 12.00 B
DTS dist/utils/utils.d.ts 12.00 B
DTS dist/components/copilot-provider/index.d.ts 463.00 B
DTS dist/components/copilot-provider/standard-copilot-api-config.d.ts 911.00 B
DTS dist/openai-assistants/hooks/index.d.ts 182.00 B
DTS dist/openai-assistants/hooks/use-assistants.d.ts 551.00 B
DTS dist/openai-assistants/utils/index.d.ts 68.00 B
Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...
DTS Build start
ESM dist/chunk-7GFKOIO7.mjs 76.00 B
ESM dist/openai-assistants/index.mjs 570.00 B
ESM dist/types/index.mjs 98.00 B
ESM dist/hooks/use-make-copilot-actionable.mjs 218.00 B
ESM dist/openai/chat-completion-client.mjs 209.00 B
ESM dist/components/index.mjs 380.00 B
ESM dist/context/copilot-context.mjs 164.00 B
ESM dist/chunk-FRAKUJWH.mjs 76.00 B
ESM dist/chunk-BABVSMJR.mjs 76.00 B
ESM dist/chunk-EFZPSZWO.mjs 76.00 B
ESM dist/chunk-PUFR5OAI.mjs 76.00 B
ESM dist/chunk-VNRDQJXW.mjs 76.00 B
ESM dist/chunk-5UGLWBZJ.mjs 76.00 B
ESM dist/chunk-JD7BAH7U.mjs 76.00 B
ESM dist/chunk-SPCZTZCY.mjs 76.00 B
ESM dist/chunk-F2JIAPZQ.mjs 435.00 B
ESM dist/chunk-MRXNTQOX.mjs 1.92 KB
ESM dist/hooks/use-make-copilot-document-readable.mjs 231.00 B
ESM dist/hooks/use-make-copilot-readable.mjs 214.00 B
ESM dist/hooks/use-tree.mjs 170.00 B
ESM dist/openai/chat-completion-stream.mjs 209.00 B
ESM dist/openai/chat-completion-transport.mjs 183.00 B
ESM dist/openai/index.mjs 224.00 B
ESM dist/index.mjs 1.11 KB
ESM dist/chunk-TU4DNDO7.mjs 4.33 KB
ESM dist/chunk-MZ5UN3BY.mjs 830.00 B
ESM dist/chunk-6SOQYBNX.mjs 1.24 KB
ESM dist/context/index.mjs 186.00 B
ESM dist/hooks/index.mjs 708.00 B
ESM dist/chunk-FP4EXCGS.mjs 954.00 B
ESM dist/chunk-7P4OYNP3.mjs 677.00 B
ESM dist/chunk-HW5IH6PV.mjs 626.00 B
ESM dist/hooks/use-chat.mjs 214.00 B
ESM dist/hooks/use-copilot-chat.mjs 507.00 B
ESM dist/chunk-SFQOMKM2.mjs 2.71 KB
ESM dist/chunk-QTET3FBV.mjs 5.18 KB
ESM dist/chunk-VUY2K2DI.mjs 3.89 KB
ESM dist/chunk-6A4PCNMZ.mjs 1.30 KB
ESM dist/chunk-LMZN4NSM.mjs 3.69 KB
ESM dist/chunk-TKXPMMND.mjs 5.33 KB
ESM dist/chunk-VK25FIML.mjs 4.48 KB
ESM dist/hooks/use-flat-category-store.mjs 200.00 B
ESM dist/chunk-YULKJPY3.mjs 1.87 KB
ESM dist/components/copilot-provider/copilot-provider-props.mjs 84.00 B
ESM dist/utils/utils.test.mjs 202.00 B
ESM dist/openai-assistants/utils/process-message-stream.mjs 183.00 B
ESM dist/openai-assistants/hooks/index.mjs 547.00 B
ESM dist/types/annotated-function.mjs 80.00 B
ESM dist/types/base.mjs 66.00 B
ESM dist/types/document-pointer.mjs 78.00 B
ESM dist/types/message.mjs 69.00 B
ESM dist/utils/utils.mjs 67.00 B
ESM dist/components/copilot-provider/copilot-provider.mjs 345.00 B
ESM dist/components/copilot-provider/index.mjs 369.00 B
ESM dist/components/copilot-provider/standard-copilot-api-config.mjs 192.00 B
ESM dist/openai-assistants/hooks/use-assistants.mjs 2.55 KB
ESM dist/openai-assistants/hooks/use-copilot-chat-v2.mjs 548.00 B
ESM dist/openai-assistants/utils/index.mjs 201.00 B
ESM dist/chunk-7GFKOIO7.mjs.map 51.00 B
ESM dist/openai-assistants/index.mjs.map 51.00 B
ESM dist/types/index.mjs.map 51.00 B
ESM dist/hooks/use-make-copilot-actionable.mjs.map 51.00 B
ESM dist/openai/chat-completion-client.mjs.map 51.00 B
ESM dist/components/index.mjs.map 51.00 B
ESM dist/context/copilot-context.mjs.map 51.00 B
ESM dist/chunk-FRAKUJWH.mjs.map 51.00 B
ESM dist/chunk-BABVSMJR.mjs.map 51.00 B
ESM dist/chunk-EFZPSZWO.mjs.map 51.00 B
ESM dist/chunk-PUFR5OAI.mjs.map 51.00 B
ESM dist/chunk-VNRDQJXW.mjs.map 51.00 B
ESM dist/chunk-5UGLWBZJ.mjs.map 51.00 B
ESM dist/chunk-JD7BAH7U.mjs.map 51.00 B
ESM dist/chunk-SPCZTZCY.mjs.map 51.00 B
ESM dist/chunk-F2JIAPZQ.mjs.map 1.12 KB
ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
ESM dist/hooks/use-make-copilot-document-readable.mjs.map 51.00 B
ESM dist/hooks/use-make-copilot-readable.mjs.map 51.00 B
ESM dist/hooks/use-tree.mjs.map 51.00 B
ESM dist/openai/chat-completion-stream.mjs.map 51.00 B
ESM dist/openai/chat-completion-transport.mjs.map 51.00 B
ESM dist/openai/index.mjs.map 51.00 B
ESM dist/index.mjs.map 51.00 B
ESM dist/chunk-TU4DNDO7.mjs.map 7.90 KB
ESM dist/chunk-MZ5UN3BY.mjs.map 1.26 KB
ESM dist/chunk-6SOQYBNX.mjs.map 2.07 KB
ESM dist/context/index.mjs.map 51.00 B
ESM dist/hooks/index.mjs.map 51.00 B
ESM dist/chunk-FP4EXCGS.mjs.map 1.67 KB
ESM dist/chunk-7P4OYNP3.mjs.map 1.42 KB
ESM dist/chunk-HW5IH6PV.mjs.map 1.47 KB
ESM dist/hooks/use-chat.mjs.map 51.00 B
ESM dist/hooks/use-copilot-chat.mjs.map 51.00 B
ESM dist/chunk-SFQOMKM2.mjs.map 4.37 KB
ESM dist/chunk-QTET3FBV.mjs.map 11.03 KB
ESM dist/chunk-VUY2K2DI.mjs.map 8.27 KB
ESM dist/chunk-6A4PCNMZ.mjs.map 4.26 KB
ESM dist/chunk-LMZN4NSM.mjs.map 8.47 KB
ESM dist/chunk-TKXPMMND.mjs.map 9.93 KB
ESM dist/chunk-VK25FIML.mjs.map 7.84 KB
ESM dist/hooks/use-flat-category-store.mjs.map 51.00 B
ESM dist/chunk-YULKJPY3.mjs.map 4.21 KB
ESM dist/components/copilot-provider/copilot-provider-props.mjs.map 51.00 B
ESM dist/utils/utils.test.mjs.map 351.00 B
ESM dist/openai-assistants/utils/process-message-stream.mjs.map 51.00 B
ESM dist/openai-assistants/hooks/index.mjs.map 51.00 B
ESM dist/types/annotated-function.mjs.map 51.00 B
ESM dist/types/base.mjs.map 51.00 B
ESM dist/types/document-pointer.mjs.map 51.00 B
ESM dist/types/message.mjs.map 51.00 B
ESM dist/utils/utils.mjs.map 51.00 B
ESM dist/components/copilot-provider/copilot-provider.mjs.map 51.00 B
ESM dist/components/copilot-provider/index.mjs.map 51.00 B
ESM dist/components/copilot-provider/standard-copilot-api-config.mjs.map 51.00 B
ESM dist/openai-assistants/hooks/use-assistants.mjs.map 4.67 KB
ESM dist/openai-assistants/hooks/use-copilot-chat-v2.mjs.map 51.00 B
ESM dist/openai-assistants/utils/index.mjs.map 51.00 B
ESM ⚡️ Build success in 495ms
DTS ⚡️ Build success in 4916ms
DTS dist/index.d.ts 1.61 KB
DTS dist/components/copilot-provider/copilot-provider.d.ts 1.55 KB
DTS dist/components/copilot-provider/copilot-provider-props.d.ts 1.52 KB
DTS dist/context/copilot-context.d.ts 1.98 KB
DTS dist/hooks/use-copilot-chat.d.ts 955.00 B
DTS dist/hooks/use-make-copilot-actionable.d.ts 255.00 B
DTS dist/hooks/use-make-copilot-readable.d.ts 598.00 B
DTS dist/hooks/use-make-copilot-document-readable.d.ts 516.00 B
DTS dist/hooks/use-chat.d.ts 2.75 KB
DTS dist/types/annotated-function.d.ts 767.00 B
DTS dist/types/document-pointer.d.ts 181.00 B
DTS dist/types/base.d.ts 1.96 KB
DTS dist/openai-assistants/hooks/use-copilot-chat-v2.d.ts 1.41 KB
DTS dist/openai-assistants/utils/process-message-stream.d.ts 196.00 B
DTS dist/openai/chat-completion-stream.d.ts 694.00 B
DTS dist/openai/chat-completion-transport.d.ts 1.26 KB
DTS dist/hooks/use-tree.d.ts 543.00 B
DTS dist/components/index.d.ts 482.00 B
DTS dist/context/index.d.ts 281.00 B
DTS dist/hooks/index.d.ts 608.00 B
DTS dist/hooks/use-flat-category-store.d.ts 424.00 B
DTS dist/openai/chat-completion-client.d.ts 1.44 KB
DTS dist/openai/index.d.ts 438.00 B
DTS dist/openai-assistants/index.d.ts 262.00 B
DTS dist/types/index.d.ts 233.00 B
DTS dist/types/message.d.ts 12.00 B
DTS dist/utils/utils.test.d.ts 12.00 B
DTS dist/utils/utils.d.ts 12.00 B
DTS dist/components/copilot-provider/index.d.ts 463.00 B
DTS dist/components/copilot-provider/standard-copilot-api-config.d.ts 911.00 B
DTS dist/openai-assistants/hooks/index.d.ts 182.00 B
DTS dist/openai-assistants/hooks/use-assistants.d.ts 551.00 B
DTS dist/openai-assistants/utils/index.d.ts 68.00 B
# ui
## 0.17.1
### Patch Changes
- stop generating button working
- aa6bc5a: fix stop generate
- cf0bde6: change order of operations on stop cleanup
- Updated dependencies
- Updated dependencies [aa6bc5a]
- Updated dependencies [cf0bde6]
- @copilotkit/shared@0.1.1
## 0.17.1-alpha.1

@@ -4,0 +16,0 @@

@@ -5,3 +5,3 @@ import '../chunk-5UGLWBZJ.mjs';

export { useMakeCopilotReadable } from '../chunk-HW5IH6PV.mjs';
export { useCopilotChat } from '../chunk-R75NEA76.mjs';
export { useCopilotChat } from '../chunk-SFQOMKM2.mjs';
import '../chunk-JD7BAH7U.mjs';

@@ -13,3 +13,3 @@ import '../chunk-SPCZTZCY.mjs';

import '../chunk-6A4PCNMZ.mjs';
import '../chunk-R2WOR4SW.mjs';
import '../chunk-LMZN4NSM.mjs';
import '../chunk-TKXPMMND.mjs';

@@ -16,0 +16,0 @@ import '../chunk-VK25FIML.mjs';

@@ -1,2 +0,2 @@

export { useChat } from '../chunk-R2WOR4SW.mjs';
export { useChat } from '../chunk-LMZN4NSM.mjs';
import '../chunk-TKXPMMND.mjs';

@@ -3,0 +3,0 @@ import '../chunk-VK25FIML.mjs';

@@ -1,2 +0,2 @@

export { defaultSystemMessage, useCopilotChat } from '../chunk-R75NEA76.mjs';
export { defaultSystemMessage, useCopilotChat } from '../chunk-SFQOMKM2.mjs';
import '../chunk-JD7BAH7U.mjs';

@@ -8,3 +8,3 @@ import '../chunk-SPCZTZCY.mjs';

import '../chunk-6A4PCNMZ.mjs';
import '../chunk-R2WOR4SW.mjs';
import '../chunk-LMZN4NSM.mjs';
import '../chunk-TKXPMMND.mjs';

@@ -11,0 +11,0 @@ import '../chunk-VK25FIML.mjs';

@@ -14,3 +14,3 @@ import './chunk-7GFKOIO7.mjs';

export { useMakeCopilotReadable } from './chunk-HW5IH6PV.mjs';
export { useCopilotChat } from './chunk-R75NEA76.mjs';
export { useCopilotChat } from './chunk-SFQOMKM2.mjs';
import './chunk-JD7BAH7U.mjs';

@@ -22,3 +22,3 @@ import './chunk-SPCZTZCY.mjs';

export { CopilotContext } from './chunk-6A4PCNMZ.mjs';
import './chunk-R2WOR4SW.mjs';
import './chunk-LMZN4NSM.mjs';
import './chunk-TKXPMMND.mjs';

@@ -25,0 +25,0 @@ import './chunk-VK25FIML.mjs';

@@ -7,3 +7,3 @@ {

},
"version": "0.17.1-alpha.1",
"version": "0.17.1",
"sideEffects": false,

@@ -34,3 +34,3 @@ "main": "./dist/index.js",

"openai": "^4.6.0",
"@copilotkit/shared": "0.1.1-alpha.1"
"@copilotkit/shared": "0.1.1"
},

@@ -37,0 +37,0 @@ "scripts": {

import { ChatCompletionClient } from './chunk-TKXPMMND.mjs';
import { __async, __spreadValues } from './chunk-MRXNTQOX.mjs';
import { useState, useRef } from 'react';
import { nanoid } from 'nanoid';
function useChat(options) {
const [messages, setMessages] = useState([]);
const [input, setInput] = useState("");
const [isLoading, setIsLoading] = useState(false);
const abortControllerRef = useRef();
const runChatCompletion = (messages2) => __async(this, null, function* () {
return new Promise((resolve, reject) => {
setIsLoading(true);
const abortController = new AbortController();
abortControllerRef.current = abortController;
const assistantMessage = {
id: nanoid(),
createdAt: /* @__PURE__ */ new Date(),
content: "",
role: "assistant"
};
setMessages([...messages2, __spreadValues({}, assistantMessage)]);
const messagesWithContext = [...options.initialMessages || [], ...messages2];
const client = new ChatCompletionClient({});
const cleanup = () => {
client.off("content");
client.off("end");
client.off("error");
client.off("function");
abortControllerRef.current = void 0;
};
abortController.signal.addEventListener("abort", () => {
cleanup();
setIsLoading(false);
reject(new DOMException("Aborted", "AbortError"));
});
client.on("content", (content) => {
assistantMessage.content += content;
setMessages([...messages2, __spreadValues({}, assistantMessage)]);
});
client.on("end", () => {
setIsLoading(false);
cleanup();
resolve(__spreadValues({}, assistantMessage));
});
client.on("error", (error) => {
setIsLoading(false);
cleanup();
reject(error);
});
client.on("function", (functionCall) => __async(this, null, function* () {
assistantMessage.function_call = {
name: functionCall.name,
arguments: JSON.stringify(functionCall.arguments)
};
setMessages([...messages2, __spreadValues({}, assistantMessage)]);
setIsLoading(false);
cleanup();
resolve(__spreadValues({}, assistantMessage));
}));
client.fetch({
copilotConfig: options.copilotConfig,
messages: messagesWithContext,
functions: options.functions,
headers: options.headers,
signal: abortController.signal
});
});
});
const runChatCompletionAndHandleFunctionCall = (messages2) => __async(this, null, function* () {
const message = yield runChatCompletion(messages2);
if (message.function_call && options.onFunctionCall) {
yield options.onFunctionCall(messages2, message.function_call);
}
});
const append = (message) => __async(this, null, function* () {
if (isLoading) {
return;
}
const newMessages = [...messages, message];
setMessages(newMessages);
return runChatCompletionAndHandleFunctionCall(newMessages);
});
const reload = () => __async(this, null, function* () {
if (isLoading || messages.length === 0) {
return;
}
let newMessages = [...messages];
const lastMessage = messages[messages.length - 1];
if (lastMessage.role === "assistant") {
newMessages = newMessages.slice(0, -1);
}
setMessages(newMessages);
return runChatCompletionAndHandleFunctionCall(newMessages);
});
const stop = () => {
var _a;
(_a = abortControllerRef.current) == null ? void 0 : _a.abort();
};
return {
messages,
append,
reload,
stop,
isLoading,
input,
setInput
};
}
export { useChat };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-R2WOR4SW.mjs.map
{"version":3,"sources":["../src/hooks/use-chat.ts"],"names":["messages"],"mappings":";;;;;;;;;AAAA,SAAS,QAAQ,gBAAgB;AAEjC,SAAS,cAAc;AAg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AAA,EAC9B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF","sourcesContent":["import { useRef, useState } from \"react\";\nimport { Message, Function, FunctionCallHandler } from \"../types\";\nimport { nanoid } from \"nanoid\";\nimport { ChatCompletionClient } from \"../openai/chat-completion-client\";\nimport { CopilotApiConfig } from \"../context\";\n\nexport type UseChatOptions = {\n /**\n * The API endpoint that accepts a `{ messages: Message[] }` object and returns\n * a stream of tokens of the AI chat response. Defaults to `/api/chat`.\n */\n api?: string;\n /**\n * A unique identifier for the chat. If not provided, a random one will be\n * generated. When provided, the `useChat` hook with the same `id` will\n * have shared states across components.\n */\n id?: string;\n /**\n * System messages of the chat. Defaults to an empty array.\n */\n initialMessages?: Message[];\n /**\n * Callback function to be called when a function call is received.\n * If the function returns a `ChatRequest` object, the request will be sent\n * automatically to the API and will be used to update the chat.\n */\n onFunctionCall?: FunctionCallHandler;\n /**\n * HTTP headers to be sent with the API request.\n */\n headers?: Record<string, string> | Headers;\n /**\n * Extra body object to be sent with the API request.\n * @example\n * Send a `sessionId` to the API along with the messages.\n * ```js\n * useChat({\n * body: {\n * sessionId: '123',\n * }\n * })\n * ```\n */\n body?: object;\n /**\n * Function definitions to be sent to the API.\n */\n functions?: Function[];\n};\n\nexport type UseChatHelpers = {\n /** Current messages in the chat */\n messages: Message[];\n /**\n * Append a user message to the chat list. This triggers the API call to fetch\n * the assistant's response.\n * @param message The message to append\n */\n append: (message: Message) => Promise<void>;\n /**\n * Reload the last AI chat response for the given chat history. If the last\n * message isn't from the assistant, it will request the API to generate a\n * new response.\n */\n reload: () => Promise<void>;\n /**\n * Abort the current request immediately, keep the generated tokens if any.\n */\n stop: () => void;\n /** The current value of the input */\n input: string;\n /** setState-powered method to update the input value */\n setInput: React.Dispatch<React.SetStateAction<string>>;\n /** Whether the API request is in progress */\n isLoading: boolean;\n};\n\nexport type UseChatOptionsWithCopilotConfig = UseChatOptions & {\n copilotConfig: CopilotApiConfig;\n};\n\nexport function useChat(options: UseChatOptionsWithCopilotConfig): UseChatHelpers {\n const [messages, setMessages] = useState<Message[]>([]);\n const [input, setInput] = useState(\"\");\n const [isLoading, setIsLoading] = useState(false);\n const abortControllerRef = useRef<AbortController>();\n\n const runChatCompletion = async (messages: Message[]): Promise<Message> => {\n return new Promise<Message>((resolve, reject) => {\n setIsLoading(true);\n\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n const assistantMessage: Message = {\n id: nanoid(),\n createdAt: new Date(),\n content: \"\",\n role: \"assistant\",\n };\n\n // Assistant messages are always copied when using setState\n setMessages([...messages, { ...assistantMessage }]);\n\n const messagesWithContext = [...(options.initialMessages || []), ...messages];\n\n const client = new ChatCompletionClient({});\n\n const cleanup = () => {\n client.off(\"content\");\n client.off(\"end\");\n client.off(\"error\");\n client.off(\"function\");\n\n abortControllerRef.current = undefined;\n };\n\n abortController.signal.addEventListener(\"abort\", () => {\n cleanup();\n setIsLoading(false);\n reject(new DOMException(\"Aborted\", \"AbortError\"));\n });\n\n client.on(\"content\", (content) => {\n assistantMessage.content += content;\n setMessages([...messages, { ...assistantMessage }]);\n });\n\n client.on(\"end\", () => {\n setIsLoading(false);\n cleanup();\n resolve({ ...assistantMessage });\n });\n\n client.on(\"error\", (error) => {\n setIsLoading(false);\n cleanup();\n reject(error);\n });\n\n client.on(\"function\", async (functionCall) => {\n assistantMessage.function_call = {\n name: functionCall.name,\n arguments: JSON.stringify(functionCall.arguments),\n };\n setMessages([...messages, { ...assistantMessage }]);\n // quit early if we get a function call\n setIsLoading(false);\n cleanup();\n resolve({ ...assistantMessage });\n });\n\n client.fetch({\n copilotConfig: options.copilotConfig,\n messages: messagesWithContext,\n functions: options.functions,\n headers: options.headers,\n signal: abortController.signal,\n });\n });\n };\n\n const runChatCompletionAndHandleFunctionCall = async (messages: Message[]): Promise<void> => {\n const message = await runChatCompletion(messages);\n if (message.function_call && options.onFunctionCall) {\n await options.onFunctionCall(messages, message.function_call);\n }\n };\n\n const append = async (message: Message): Promise<void> => {\n if (isLoading) {\n return;\n }\n const newMessages = [...messages, message];\n setMessages(newMessages);\n return runChatCompletionAndHandleFunctionCall(newMessages);\n };\n\n const reload = async (): Promise<void> => {\n if (isLoading || messages.length === 0) {\n return;\n }\n let newMessages = [...messages];\n const lastMessage = messages[messages.length - 1];\n\n if (lastMessage.role === \"assistant\") {\n newMessages = newMessages.slice(0, -1);\n }\n setMessages(newMessages);\n\n return runChatCompletionAndHandleFunctionCall(newMessages);\n };\n\n const stop = (): void => {\n abortControllerRef.current?.abort();\n };\n\n return {\n messages,\n append,\n reload,\n stop,\n isLoading,\n input,\n setInput,\n };\n}\n"]}
import { defaultCopilotContextCategories } from './chunk-QTET3FBV.mjs';
import { CopilotContext } from './chunk-6A4PCNMZ.mjs';
import { useChat } from './chunk-R2WOR4SW.mjs';
import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
import { useContext, useMemo } from 'react';
function useCopilotChat(_a) {
var _b = _a, {
makeSystemMessage
} = _b, options = __objRest(_b, [
"makeSystemMessage"
]);
const {
getContextString,
getChatCompletionFunctionDescriptions,
getFunctionCallHandler,
copilotApiConfig
} = useContext(CopilotContext);
const systemMessage = useMemo(() => {
const systemMessageMaker = makeSystemMessage || defaultSystemMessage;
const contextString = getContextString([], defaultCopilotContextCategories);
return {
id: "system",
content: systemMessageMaker(contextString),
role: "system"
};
}, [getContextString, makeSystemMessage]);
const functionDescriptions = useMemo(() => {
return getChatCompletionFunctionDescriptions();
}, [getChatCompletionFunctionDescriptions]);
const { messages, append, reload, stop, isLoading, input, setInput } = useChat(__spreadProps(__spreadValues({}, options), {
copilotConfig: copilotApiConfig,
id: options.id,
initialMessages: [systemMessage].concat(options.initialMessages || []),
functions: functionDescriptions,
onFunctionCall: getFunctionCallHandler(),
headers: __spreadValues({}, options.headers),
body: __spreadValues({}, options.body)
}));
const visibleMessages = messages.filter(
(message) => message.role === "user" || message.role === "assistant"
);
return {
visibleMessages,
append,
reload,
stop,
isLoading,
input,
setInput
};
}
function defaultSystemMessage(contextString) {
return `
Please act as an efficient, competent, conscientious, and industrious professional assistant.
Help the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.
Always be polite and respectful, and prefer brevity over verbosity.
The user has provided you with the following context:
\`\`\`
${contextString}
\`\`\`
They have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.
Please assist them as best you can.
You can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.
If you would like to call a function, call it without saying anything else.
`;
}
export { defaultSystemMessage, useCopilotChat };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-R75NEA76.mjs.map
{"version":3,"sources":["../src/hooks/use-copilot-chat.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,SAAS,kBAAkB;AAqB7B,SAAS,eAAe,IAGiB;AAHjB,eAC7B;AAAA;AAAA,EAtBF,IAqB+B,IAE1B,oBAF0B,IAE1B;AAAA,IADH;AAAA;AAGA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,cAAc;AAE7B,QAAM,gBAAyB,QAAQ,MAAM;AAC3C,UAAM,qBAAqB,qBAAqB;AAChD,UAAM,gBAAgB,iBAAiB,CAAC,GAAG,+BAA+B;AAE1E,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,mBAAmB,aAAa;AAAA,MACzC,MAAM;AAAA,IACR;AAAA,EACF,GAAG,CAAC,kBAAkB,iBAAiB,CAAC;AAExC,QAAM,uBAA8D,QAAQ,MAAM;AAChF,WAAO,sCAAsC;AAAA,EAC/C,GAAG,CAAC,qCAAqC,CAAC;AAE1C,QAAM,EAAE,UAAU,QAAQ,QAAQ,MAAM,WAAW,OAAO,SAAS,IAAI,QAAQ,iCAC1E,UAD0E;AAAA,IAE7E,eAAe;AAAA,IACf,IAAI,QAAQ;AAAA,IACZ,iBAAiB,CAAC,aAAa,EAAE,OAAO,QAAQ,mBAAmB,CAAC,CAAC;AAAA,IACrE,WAAW;AAAA,IACX,gBAAgB,uBAAuB;AAAA,IACvC,SAAS,mBAAK,QAAQ;AAAA,IACtB,MAAM,mBACD,QAAQ;AAAA,EAEf,EAAC;AAED,QAAM,kBAAkB,SAAS;AAAA,IAC/B,CAAC,YAAY,QAAQ,SAAS,UAAU,QAAQ,SAAS;AAAA,EAC3D;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,qBAAqB,eAA+B;AAClE,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWF","sourcesContent":["import { useMemo, useContext } from \"react\";\nimport { CopilotContext, CopilotContextParams } from \"../context/copilot-context\";\nimport { Message } from \"../types\";\nimport { UseChatOptions, useChat } from \"./use-chat\";\nimport { defaultCopilotContextCategories } from \"../components\";\nimport { ChatCompletionCreateParams } from \"openai/resources/chat\";\n\nexport interface UseCopilotChatOptions extends UseChatOptions {\n makeSystemMessage?: (contextString: string) => string;\n}\n\nexport interface UseCopilotChatReturn {\n visibleMessages: Message[];\n append: (message: Message) => Promise<void>;\n reload: () => Promise<void>;\n stop: () => void;\n isLoading: boolean;\n input: string;\n setInput: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport function useCopilotChat({\n makeSystemMessage,\n ...options\n}: UseCopilotChatOptions): UseCopilotChatReturn {\n const {\n getContextString,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n copilotApiConfig,\n } = useContext(CopilotContext);\n\n const systemMessage: Message = useMemo(() => {\n const systemMessageMaker = makeSystemMessage || defaultSystemMessage;\n const contextString = getContextString([], defaultCopilotContextCategories); // TODO: make the context categories configurable\n\n return {\n id: \"system\",\n content: systemMessageMaker(contextString),\n role: \"system\",\n };\n }, [getContextString, makeSystemMessage]);\n\n const functionDescriptions: ChatCompletionCreateParams.Function[] = useMemo(() => {\n return getChatCompletionFunctionDescriptions();\n }, [getChatCompletionFunctionDescriptions]);\n\n const { messages, append, reload, stop, isLoading, input, setInput } = useChat({\n ...options,\n copilotConfig: copilotApiConfig,\n id: options.id,\n initialMessages: [systemMessage].concat(options.initialMessages || []),\n functions: functionDescriptions,\n onFunctionCall: getFunctionCallHandler(),\n headers: { ...options.headers },\n body: {\n ...options.body,\n },\n });\n\n const visibleMessages = messages.filter(\n (message) => message.role === \"user\" || message.role === \"assistant\",\n );\n\n return {\n visibleMessages,\n append,\n reload,\n stop,\n isLoading,\n input,\n setInput,\n };\n}\n\nexport function defaultSystemMessage(contextString: string): string {\n return `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.\n\nPlease assist them as best you can.\n\nYou can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.\n\nIf you would like to call a function, call it without saying anything else.\n`;\n}\n"]}