@copilotkit/react-core 0.17.0-alpha.0 → 0.17.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +86 -86
- package/CHANGELOG.md +12 -0
- package/dist/chunk-5UGLWBZJ.mjs +3 -0
- package/dist/chunk-5UGLWBZJ.mjs.map +1 -0
- package/dist/chunk-6A4PCNMZ.mjs +48 -0
- package/dist/chunk-6A4PCNMZ.mjs.map +1 -0
- package/dist/chunk-6SOQYBNX.mjs +44 -0
- package/dist/chunk-6SOQYBNX.mjs.map +1 -0
- package/dist/chunk-7GFKOIO7.mjs +3 -0
- package/dist/chunk-7GFKOIO7.mjs.map +1 -0
- package/dist/chunk-7P4OYNP3.mjs +19 -0
- package/dist/chunk-7P4OYNP3.mjs.map +1 -0
- package/dist/chunk-BABVSMJR.mjs +3 -0
- package/dist/chunk-BABVSMJR.mjs.map +1 -0
- package/dist/chunk-EFZPSZWO.mjs +3 -0
- package/dist/chunk-EFZPSZWO.mjs.map +1 -0
- package/dist/chunk-F2JIAPZQ.mjs +13 -0
- package/dist/chunk-F2JIAPZQ.mjs.map +1 -0
- package/dist/chunk-FP4EXCGS.mjs +27 -0
- package/dist/chunk-FP4EXCGS.mjs.map +1 -0
- package/dist/chunk-FRAKUJWH.mjs +3 -0
- package/dist/chunk-FRAKUJWH.mjs.map +1 -0
- package/dist/chunk-HW5IH6PV.mjs +19 -0
- package/dist/chunk-HW5IH6PV.mjs.map +1 -0
- package/dist/chunk-JD7BAH7U.mjs +3 -0
- package/dist/chunk-JD7BAH7U.mjs.map +1 -0
- package/dist/chunk-MRXNTQOX.mjs +55 -0
- package/dist/chunk-MRXNTQOX.mjs.map +1 -0
- package/dist/chunk-MZ5UN3BY.mjs +28 -0
- package/dist/chunk-MZ5UN3BY.mjs.map +1 -0
- package/dist/chunk-PUFR5OAI.mjs +3 -0
- package/dist/chunk-PUFR5OAI.mjs.map +1 -0
- package/dist/chunk-QTET3FBV.mjs +165 -0
- package/dist/chunk-QTET3FBV.mjs.map +1 -0
- package/dist/chunk-SPCZTZCY.mjs +3 -0
- package/dist/chunk-SPCZTZCY.mjs.map +1 -0
- package/dist/chunk-TKXPMMND.mjs +177 -0
- package/dist/chunk-TKXPMMND.mjs.map +1 -0
- package/dist/chunk-TU4DNDO7.mjs +125 -0
- package/dist/chunk-TU4DNDO7.mjs.map +1 -0
- package/dist/chunk-VK25FIML.mjs +144 -0
- package/dist/chunk-VK25FIML.mjs.map +1 -0
- package/dist/chunk-VNRDQJXW.mjs +3 -0
- package/dist/chunk-VNRDQJXW.mjs.map +1 -0
- package/dist/chunk-VUY2K2DI.mjs +135 -0
- package/dist/chunk-VUY2K2DI.mjs.map +1 -0
- package/dist/chunk-WMXA2TIX.mjs +102 -0
- package/dist/chunk-WMXA2TIX.mjs.map +1 -0
- package/dist/chunk-XSS45JC5.mjs +77 -0
- package/dist/chunk-XSS45JC5.mjs.map +1 -0
- package/dist/chunk-YULKJPY3.mjs +70 -0
- package/dist/chunk-YULKJPY3.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-provider-props.mjs +2 -1
- package/dist/components/copilot-provider/copilot-provider-props.mjs.map +1 -1
- package/dist/components/copilot-provider/copilot-provider.mjs +7 -468
- package/dist/components/copilot-provider/copilot-provider.mjs.map +1 -1
- package/dist/components/copilot-provider/index.mjs +8 -467
- package/dist/components/copilot-provider/index.mjs.map +1 -1
- package/dist/components/copilot-provider/standard-copilot-api-config.mjs +3 -12
- package/dist/components/copilot-provider/standard-copilot-api-config.mjs.map +1 -1
- package/dist/components/index.mjs +9 -467
- package/dist/components/index.mjs.map +1 -1
- package/dist/context/copilot-context.mjs +3 -70
- package/dist/context/copilot-context.mjs.map +1 -1
- package/dist/context/index.mjs +4 -69
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/index.mjs +17 -654
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/use-chat.mjs +5 -460
- package/dist/hooks/use-chat.mjs.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +13 -599
- package/dist/hooks/use-copilot-chat.mjs.map +1 -1
- package/dist/hooks/use-flat-category-store.mjs +3 -68
- package/dist/hooks/use-flat-category-store.mjs.map +1 -1
- package/dist/hooks/use-make-copilot-actionable.mjs +4 -95
- package/dist/hooks/use-make-copilot-actionable.mjs.map +1 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +4 -87
- package/dist/hooks/use-make-copilot-document-readable.mjs.map +1 -1
- package/dist/hooks/use-make-copilot-readable.mjs +4 -87
- package/dist/hooks/use-make-copilot-readable.mjs.map +1 -1
- package/dist/hooks/use-tree.mjs +3 -153
- package/dist/hooks/use-tree.mjs.map +1 -1
- package/dist/index.mjs +26 -1204
- package/dist/index.mjs.map +1 -1
- package/dist/openai/chat-completion-client.d.ts +0 -4
- package/dist/openai/chat-completion-client.mjs +4 -359
- package/dist/openai/chat-completion-client.mjs.map +1 -1
- package/dist/openai/chat-completion-stream.mjs +4 -220
- package/dist/openai/chat-completion-stream.mjs.map +1 -1
- package/dist/openai/chat-completion-transport.d.ts +3 -5
- package/dist/openai/chat-completion-transport.mjs +3 -180
- package/dist/openai/chat-completion-transport.mjs.map +1 -1
- package/dist/openai/index.mjs +5 -220
- package/dist/openai/index.mjs.map +1 -1
- package/dist/openai-assistants/hooks/index.mjs +14 -235
- package/dist/openai-assistants/hooks/index.mjs.map +1 -1
- package/dist/openai-assistants/hooks/use-assistants.mjs +8 -52
- package/dist/openai-assistants/hooks/use-assistants.mjs.map +1 -1
- package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs +13 -236
- package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs.map +1 -1
- package/dist/openai-assistants/index.mjs +15 -236
- package/dist/openai-assistants/index.mjs.map +1 -1
- package/dist/openai-assistants/utils/index.mjs +4 -46
- package/dist/openai-assistants/utils/index.mjs.map +1 -1
- package/dist/openai-assistants/utils/process-message-stream.mjs +3 -46
- package/dist/openai-assistants/utils/process-message-stream.mjs.map +1 -1
- package/dist/types/annotated-function.mjs +2 -0
- package/dist/types/annotated-function.mjs.map +1 -1
- package/dist/types/base.mjs +2 -0
- package/dist/types/base.mjs.map +1 -1
- package/dist/types/document-pointer.mjs +2 -0
- package/dist/types/document-pointer.mjs.map +1 -1
- package/dist/types/index.mjs +2 -0
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/message.mjs +2 -0
- package/dist/types/message.mjs.map +1 -1
- package/dist/utils/utils.mjs +2 -0
- package/dist/utils/utils.mjs.map +1 -1
- package/dist/utils/utils.test.mjs +1 -0
- package/dist/utils/utils.test.mjs.map +1 -1
- package/package.json +3 -3
- package/src/hooks/use-chat.ts +2 -4
- package/src/openai/chat-completion-client.ts +4 -15
- package/src/openai/chat-completion-stream.ts +1 -3
- package/src/openai/chat-completion-transport.ts +5 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1,47 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// src/openai-assistants/utils/process-message-stream.ts
|
|
23
|
-
function processMessageStream(reader, processMessage) {
|
|
24
|
-
return __async(this, null, function* () {
|
|
25
|
-
const decoder = new TextDecoder();
|
|
26
|
-
let buffer = "";
|
|
27
|
-
while (true) {
|
|
28
|
-
const { done, value } = yield reader.read();
|
|
29
|
-
if (done) {
|
|
30
|
-
if (buffer.length > 0) {
|
|
31
|
-
processMessage(buffer);
|
|
32
|
-
}
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
buffer += decoder.decode(value, { stream: true });
|
|
36
|
-
let endIndex;
|
|
37
|
-
while ((endIndex = buffer.indexOf("\n")) !== -1) {
|
|
38
|
-
processMessage(buffer.substring(0, endIndex).trim());
|
|
39
|
-
buffer = buffer.substring(endIndex + 1);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
export {
|
|
45
|
-
processMessageStream
|
|
46
|
-
};
|
|
1
|
+
export { processMessageStream } from '../../chunk-MZ5UN3BY.mjs';
|
|
2
|
+
import '../../chunk-MRXNTQOX.mjs';
|
|
3
|
+
//# sourceMappingURL=out.js.map
|
|
47
4
|
//# sourceMappingURL=process-message-stream.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/types/base.mjs
CHANGED
package/dist/types/base.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/types/index.mjs
CHANGED
package/dist/types/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/types/message.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/utils/utils.mjs
CHANGED
package/dist/utils/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/utils.test.ts"],"sourcesContent":["import * as utils from \"./utils\";\n\ndescribe(\"emptyTest\", () => {\n it(\"should be truthy\", () => {\n expect(true).toBeTruthy();\n });\n});\n"]
|
|
1
|
+
{"version":3,"sources":["../../src/utils/utils.test.ts"],"names":[],"mappings":";AAEA,SAAS,aAAa,MAAM;AAC1B,KAAG,oBAAoB,MAAM;AAC3B,WAAO,IAAI,EAAE,WAAW;AAAA,EAC1B,CAAC;AACH,CAAC","sourcesContent":["import * as utils from \"./utils\";\n\ndescribe(\"emptyTest\", () => {\n it(\"should be truthy\", () => {\n expect(true).toBeTruthy();\n });\n});\n"]}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.17.0-alpha.
|
|
7
|
+
"version": "0.17.0-alpha.2",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"module": "./dist/index.mjs",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"ts-jest": "^29.1.1",
|
|
24
24
|
"tsup": "^6.7.0",
|
|
25
25
|
"typescript": "^5.1.3",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"eslint-config-custom": "0.2.0",
|
|
27
|
+
"tsconfig": "0.6.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"eventemitter3": "^5.0.1",
|
package/src/hooks/use-chat.ts
CHANGED
|
@@ -101,9 +101,7 @@ export function useChat(options: UseChatOptionsWithCopilotConfig): UseChatHelper
|
|
|
101
101
|
|
|
102
102
|
const messagesWithContext = [...(options.initialMessages || []), ...messages];
|
|
103
103
|
|
|
104
|
-
const client = new ChatCompletionClient({
|
|
105
|
-
url: options.api || "/api/copilotkit/openai",
|
|
106
|
-
});
|
|
104
|
+
const client = new ChatCompletionClient({});
|
|
107
105
|
|
|
108
106
|
const cleanup = () => {
|
|
109
107
|
client.off("content");
|
|
@@ -142,10 +140,10 @@ export function useChat(options: UseChatOptionsWithCopilotConfig): UseChatHelper
|
|
|
142
140
|
});
|
|
143
141
|
|
|
144
142
|
client.fetch({
|
|
143
|
+
copilotConfig: options.copilotConfig,
|
|
145
144
|
messages: messagesWithContext,
|
|
146
145
|
functions: options.functions,
|
|
147
146
|
headers: options.headers,
|
|
148
|
-
copilotConfig: options.copilotConfig,
|
|
149
147
|
});
|
|
150
148
|
});
|
|
151
149
|
};
|
|
@@ -5,10 +5,7 @@ import {
|
|
|
5
5
|
ChatCompletionTransportFetchParams,
|
|
6
6
|
} from "./chat-completion-transport";
|
|
7
7
|
|
|
8
|
-
interface ChatCompletionClientConfiguration {
|
|
9
|
-
url: string;
|
|
10
|
-
model?: string;
|
|
11
|
-
}
|
|
8
|
+
interface ChatCompletionClientConfiguration {}
|
|
12
9
|
|
|
13
10
|
interface ChatCompletionClientEvents {
|
|
14
11
|
content: string;
|
|
@@ -37,9 +34,6 @@ export interface ChatCompletionChunk {
|
|
|
37
34
|
const DEFAULT_MAX_TOKENS = 8192;
|
|
38
35
|
|
|
39
36
|
export class ChatCompletionClient extends EventEmitter<ChatCompletionClientEvents> {
|
|
40
|
-
private url: string;
|
|
41
|
-
private model?: string;
|
|
42
|
-
|
|
43
37
|
private chatCompletionTransport: ChatCompletionTransport | null = null;
|
|
44
38
|
private mode: "function" | "message" | null = null;
|
|
45
39
|
private functionCallName: string = "";
|
|
@@ -47,20 +41,17 @@ export class ChatCompletionClient extends EventEmitter<ChatCompletionClientEvent
|
|
|
47
41
|
|
|
48
42
|
constructor(params: ChatCompletionClientConfiguration) {
|
|
49
43
|
super();
|
|
50
|
-
this.model = params.model;
|
|
51
|
-
this.url = params.url;
|
|
52
44
|
}
|
|
53
45
|
|
|
54
46
|
public async fetch(params: ChatCompletionTransportFetchParams) {
|
|
55
47
|
params = { ...params };
|
|
56
|
-
if (
|
|
57
|
-
params.maxTokens ||= maxTokensByModel[
|
|
48
|
+
if (params.model && params.model in maxTokensByModel) {
|
|
49
|
+
params.maxTokens ||= maxTokensByModel[params.model];
|
|
58
50
|
} else {
|
|
59
51
|
params.maxTokens ||= DEFAULT_MAX_TOKENS;
|
|
60
52
|
}
|
|
61
53
|
|
|
62
54
|
params.functions ||= [];
|
|
63
|
-
params.model = this.model;
|
|
64
55
|
params.messages = this.buildPrompt(params);
|
|
65
56
|
return await this.runPrompt(params);
|
|
66
57
|
}
|
|
@@ -110,9 +101,7 @@ export class ChatCompletionClient extends EventEmitter<ChatCompletionClientEvent
|
|
|
110
101
|
}
|
|
111
102
|
|
|
112
103
|
private async runPrompt(params: ChatCompletionTransportFetchParams): Promise<void> {
|
|
113
|
-
this.chatCompletionTransport = new ChatCompletionTransport({
|
|
114
|
-
url: this.url,
|
|
115
|
-
});
|
|
104
|
+
this.chatCompletionTransport = new ChatCompletionTransport({});
|
|
116
105
|
|
|
117
106
|
this.chatCompletionTransport.on("data", this.onData);
|
|
118
107
|
this.chatCompletionTransport.on("error", this.onError);
|
|
@@ -19,9 +19,7 @@ export class ChatCompletionStream {
|
|
|
19
19
|
params = { ...params };
|
|
20
20
|
params.functions = undefined;
|
|
21
21
|
|
|
22
|
-
const transport = new ChatCompletionTransport({
|
|
23
|
-
url: this.url,
|
|
24
|
-
});
|
|
22
|
+
const transport = new ChatCompletionTransport({});
|
|
25
23
|
|
|
26
24
|
const cleanup = () => {
|
|
27
25
|
transport.off("data");
|
|
@@ -2,9 +2,7 @@ import EventEmitter from "eventemitter3";
|
|
|
2
2
|
import { Message, Function } from "../types";
|
|
3
3
|
import { CopilotApiConfig } from "../context";
|
|
4
4
|
|
|
5
|
-
export interface ChatCompletionTransportConfiguration {
|
|
6
|
-
url: string;
|
|
7
|
-
}
|
|
5
|
+
export interface ChatCompletionTransportConfiguration {}
|
|
8
6
|
|
|
9
7
|
interface ChatCompletionTransportEvents {
|
|
10
8
|
end: void;
|
|
@@ -13,6 +11,7 @@ interface ChatCompletionTransportEvents {
|
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
export interface ChatCompletionTransportFetchParams {
|
|
14
|
+
copilotConfig: CopilotApiConfig;
|
|
16
15
|
model?: string;
|
|
17
16
|
messages: Message[];
|
|
18
17
|
functions?: Function[];
|
|
@@ -20,7 +19,6 @@ export interface ChatCompletionTransportFetchParams {
|
|
|
20
19
|
maxTokens?: number;
|
|
21
20
|
headers?: Record<string, string> | Headers;
|
|
22
21
|
body?: object;
|
|
23
|
-
copilotConfig: CopilotApiConfig;
|
|
24
22
|
signal?: AbortSignal;
|
|
25
23
|
}
|
|
26
24
|
|
|
@@ -29,11 +27,9 @@ const DEFAULT_MODEL = "gpt-4-1106-preview";
|
|
|
29
27
|
export class ChatCompletionTransport extends EventEmitter<ChatCompletionTransportEvents> {
|
|
30
28
|
private buffer = new Uint8Array();
|
|
31
29
|
private bodyReader: ReadableStreamDefaultReader<Uint8Array> | null = null;
|
|
32
|
-
private url: string;
|
|
33
30
|
|
|
34
|
-
constructor(
|
|
31
|
+
constructor(params: ChatCompletionTransportConfiguration) {
|
|
35
32
|
super();
|
|
36
|
-
this.url = url;
|
|
37
33
|
}
|
|
38
34
|
|
|
39
35
|
private async cleanup() {
|
|
@@ -49,9 +45,9 @@ export class ChatCompletionTransport extends EventEmitter<ChatCompletionTranspor
|
|
|
49
45
|
}
|
|
50
46
|
|
|
51
47
|
public async fetch({
|
|
48
|
+
copilotConfig,
|
|
52
49
|
model,
|
|
53
50
|
messages,
|
|
54
|
-
copilotConfig,
|
|
55
51
|
functions,
|
|
56
52
|
temperature,
|
|
57
53
|
headers,
|
|
@@ -71,7 +67,7 @@ export class ChatCompletionTransport extends EventEmitter<ChatCompletionTranspor
|
|
|
71
67
|
});
|
|
72
68
|
|
|
73
69
|
try {
|
|
74
|
-
const response = await fetch(
|
|
70
|
+
const response = await fetch(copilotConfig.chatApiEndpoint, {
|
|
75
71
|
method: "POST",
|
|
76
72
|
headers: {
|
|
77
73
|
"Content-Type": "application/json",
|