@copilotkit/runtime 1.5.12-next.6 → 1.5.12
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/CHANGELOG.md +22 -0
- package/__snapshots__/schema/schema.graphql +33 -0
- package/dist/{chunk-XM2VJFL6.mjs → chunk-4LRVKGBI.mjs} +2 -2
- package/dist/{chunk-YGXAWYRB.mjs → chunk-IS3QAGOU.mjs} +2 -2
- package/dist/{chunk-ON4AESON.mjs → chunk-PFELVFS7.mjs} +540 -221
- package/dist/chunk-PFELVFS7.mjs.map +1 -0
- package/dist/{chunk-TPTCSIAR.mjs → chunk-S3KKBII4.mjs} +42 -30
- package/dist/chunk-S3KKBII4.mjs.map +1 -0
- package/dist/{chunk-BKIGYRXE.mjs → chunk-W6EE6OTN.mjs} +2 -2
- package/dist/{copilot-runtime-da917bd5.d.ts → copilot-runtime-8c442d65.d.ts} +16 -5
- package/dist/graphql/types/converted/index.d.ts +1 -1
- package/dist/{groq-adapter-c35c5374.d.ts → groq-adapter-7a82cd22.d.ts} +21 -1
- package/dist/{index-24315d90.d.ts → index-a7f37670.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +628 -297
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/{langserve-a16ef8f4.d.ts → langserve-e308c437.d.ts} +32 -3
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.js +626 -295
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -6
- package/dist/lib/integrations/index.d.ts +4 -4
- package/dist/lib/integrations/index.js +495 -237
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +5 -5
- package/dist/lib/integrations/nest/index.d.ts +3 -3
- package/dist/lib/integrations/nest/index.js +495 -237
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +3 -3
- package/dist/lib/integrations/node-express/index.d.ts +3 -3
- package/dist/lib/integrations/node-express/index.js +495 -237
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +3 -3
- package/dist/lib/integrations/node-http/index.d.ts +3 -3
- package/dist/lib/integrations/node-http/index.js +495 -237
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +2 -2
- package/dist/service-adapters/index.d.ts +4 -4
- package/dist/service-adapters/index.js +23 -11
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +1 -1
- package/package.json +2 -2
- package/src/graphql/inputs/extensions.input.ts +21 -0
- package/src/graphql/inputs/generate-copilot-response.input.ts +4 -0
- package/src/graphql/inputs/load-agent-state.input.ts +10 -0
- package/src/graphql/resolvers/copilot.resolver.ts +8 -3
- package/src/graphql/resolvers/state.resolver.ts +23 -0
- package/src/graphql/types/agents-response.type.ts +1 -4
- package/src/graphql/types/copilot-response.type.ts +5 -1
- package/src/graphql/types/extensions-response.type.ts +23 -0
- package/src/graphql/types/load-agent-state-response.type.ts +17 -0
- package/src/lib/integrations/shared.ts +2 -1
- package/src/lib/runtime/copilot-runtime.ts +102 -9
- package/src/lib/runtime/remote-lg-action.ts +24 -12
- package/src/service-adapters/anthropic/anthropic-adapter.ts +2 -3
- package/src/service-adapters/empty/empty-adapter.ts +2 -2
- package/src/service-adapters/events.ts +5 -0
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +2 -2
- package/src/service-adapters/groq/groq-adapter.ts +2 -2
- package/src/service-adapters/langchain/langchain-adapter.ts +10 -3
- package/src/service-adapters/openai/openai-adapter.ts +4 -3
- package/src/service-adapters/openai/openai-assistant-adapter.ts +15 -4
- package/src/service-adapters/service-adapter.ts +4 -0
- package/src/service-adapters/unify/unify-adapter.ts +2 -3
- package/dist/chunk-ON4AESON.mjs.map +0 -1
- package/dist/chunk-TPTCSIAR.mjs.map +0 -1
- /package/dist/{chunk-XM2VJFL6.mjs.map → chunk-4LRVKGBI.mjs.map} +0 -0
- /package/dist/{chunk-YGXAWYRB.mjs.map → chunk-IS3QAGOU.mjs.map} +0 -0
- /package/dist/{chunk-BKIGYRXE.mjs.map → chunk-W6EE6OTN.mjs.map} +0 -0
|
@@ -94,8 +94,13 @@ export class OpenAIAssistantAdapter implements CopilotServiceAdapter {
|
|
|
94
94
|
request: CopilotRuntimeChatCompletionRequest,
|
|
95
95
|
): Promise<CopilotRuntimeChatCompletionResponse> {
|
|
96
96
|
const { messages, actions, eventSource, runId, forwardedParameters } = request;
|
|
97
|
+
|
|
97
98
|
// if we don't have a threadId, create a new thread
|
|
98
|
-
let threadId = request.threadId
|
|
99
|
+
let threadId = request.extensions?.openaiAssistantAPI?.threadId;
|
|
100
|
+
|
|
101
|
+
if (!threadId) {
|
|
102
|
+
threadId = (await this.openai.beta.threads.create()).id;
|
|
103
|
+
}
|
|
99
104
|
|
|
100
105
|
const lastMessage = messages.at(-1);
|
|
101
106
|
|
|
@@ -121,8 +126,15 @@ export class OpenAIAssistantAdapter implements CopilotServiceAdapter {
|
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
return {
|
|
124
|
-
threadId,
|
|
125
129
|
runId: nextRunId,
|
|
130
|
+
threadId,
|
|
131
|
+
extensions: {
|
|
132
|
+
...request.extensions,
|
|
133
|
+
openaiAssistantAPI: {
|
|
134
|
+
threadId: threadId,
|
|
135
|
+
runId: nextRunId,
|
|
136
|
+
},
|
|
137
|
+
},
|
|
126
138
|
};
|
|
127
139
|
}
|
|
128
140
|
|
|
@@ -133,6 +145,7 @@ export class OpenAIAssistantAdapter implements CopilotServiceAdapter {
|
|
|
133
145
|
eventSource: RuntimeEventSource,
|
|
134
146
|
) {
|
|
135
147
|
let run = await this.openai.beta.threads.runs.retrieve(threadId, runId);
|
|
148
|
+
|
|
136
149
|
if (!run.required_action) {
|
|
137
150
|
throw new Error("No tool outputs required");
|
|
138
151
|
}
|
|
@@ -193,7 +206,6 @@ export class OpenAIAssistantAdapter implements CopilotServiceAdapter {
|
|
|
193
206
|
throw new Error("No user message found");
|
|
194
207
|
}
|
|
195
208
|
|
|
196
|
-
// create a new message on the thread
|
|
197
209
|
await this.openai.beta.threads.messages.create(threadId, {
|
|
198
210
|
role: "user",
|
|
199
211
|
content: userMessage.content,
|
|
@@ -207,7 +219,6 @@ export class OpenAIAssistantAdapter implements CopilotServiceAdapter {
|
|
|
207
219
|
...(this.fileSearchEnabled ? [{ type: "file_search" } as AssistantTool] : []),
|
|
208
220
|
];
|
|
209
221
|
|
|
210
|
-
// run the thread
|
|
211
222
|
let stream = this.openai.beta.threads.runs.stream(threadId, {
|
|
212
223
|
assistant_id: this.assistantId,
|
|
213
224
|
instructions,
|
|
@@ -2,6 +2,8 @@ import { Message } from "../graphql/types/converted";
|
|
|
2
2
|
import { RuntimeEventSource } from "./events";
|
|
3
3
|
import { ActionInput } from "../graphql/inputs/action.input";
|
|
4
4
|
import { ForwardedParametersInput } from "../graphql/inputs/forwarded-parameters.input";
|
|
5
|
+
import { ExtensionsInput } from "../graphql/inputs/extensions.input";
|
|
6
|
+
import { ExtensionsResponse } from "../graphql/types/extensions-response.type";
|
|
5
7
|
|
|
6
8
|
export interface CopilotKitResponse {
|
|
7
9
|
stream: ReadableStream;
|
|
@@ -16,11 +18,13 @@ export interface CopilotRuntimeChatCompletionRequest {
|
|
|
16
18
|
threadId?: string;
|
|
17
19
|
runId?: string;
|
|
18
20
|
forwardedParameters?: ForwardedParametersInput;
|
|
21
|
+
extensions?: ExtensionsInput;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
export interface CopilotRuntimeChatCompletionResponse {
|
|
22
25
|
threadId: string;
|
|
23
26
|
runId?: string;
|
|
27
|
+
extensions?: ExtensionsResponse;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
export interface CopilotServiceAdapter {
|
|
@@ -17,14 +17,13 @@
|
|
|
17
17
|
* );
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
import { TextMessage } from "../../graphql/types/converted";
|
|
21
20
|
import {
|
|
22
21
|
CopilotRuntimeChatCompletionRequest,
|
|
23
22
|
CopilotRuntimeChatCompletionResponse,
|
|
24
23
|
CopilotServiceAdapter,
|
|
25
24
|
} from "../service-adapter";
|
|
26
25
|
import OpenAI from "openai";
|
|
27
|
-
import { randomId } from "@copilotkit/shared";
|
|
26
|
+
import { randomId, randomUUID } from "@copilotkit/shared";
|
|
28
27
|
import { convertActionInputToOpenAITool, convertMessageToOpenAIMessage } from "../openai/utils";
|
|
29
28
|
|
|
30
29
|
export interface UnifyAdapterParams {
|
|
@@ -139,7 +138,7 @@ export class UnifyAdapter implements CopilotServiceAdapter {
|
|
|
139
138
|
});
|
|
140
139
|
|
|
141
140
|
return {
|
|
142
|
-
threadId: request.threadId ||
|
|
141
|
+
threadId: request.threadId || randomUUID(),
|
|
143
142
|
};
|
|
144
143
|
}
|
|
145
144
|
}
|