@copilotkit/runtime 0.37.0 → 0.38.0-beta.0
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 +69 -54
- package/CHANGELOG.md +11 -0
- package/__snapshots__/schema/schema.graphql +15 -4
- package/dist/{chunk-2CCVVJDU.mjs → chunk-2PJG3NAC.mjs} +13 -15
- package/dist/chunk-2PJG3NAC.mjs.map +1 -0
- package/dist/{chunk-NFCPM5AM.mjs → chunk-6NZ4UMOD.mjs} +4 -4
- package/dist/chunk-6NZ4UMOD.mjs.map +1 -0
- package/dist/{chunk-XPAUPJMW.mjs → chunk-6YGDE3YI.mjs} +432 -220
- package/dist/chunk-6YGDE3YI.mjs.map +1 -0
- package/dist/chunk-BYB2LNMK.mjs +152 -0
- package/dist/chunk-BYB2LNMK.mjs.map +1 -0
- package/dist/{chunk-7IFP53C6.mjs → chunk-FRK6BXXV.mjs} +49 -11
- package/dist/chunk-FRK6BXXV.mjs.map +1 -0
- package/dist/{chunk-5HGYI6EG.mjs → chunk-JBDOA7MK.mjs} +34 -15
- package/dist/chunk-JBDOA7MK.mjs.map +1 -0
- package/dist/{chunk-4UA4RB4C.mjs → chunk-JIKPSUGQ.mjs} +45 -76
- package/dist/chunk-JIKPSUGQ.mjs.map +1 -0
- package/dist/{chunk-BLTAUVRP.mjs → chunk-OZMCHYYR.mjs} +5 -3
- package/dist/{chunk-BLTAUVRP.mjs.map → chunk-OZMCHYYR.mjs.map} +1 -1
- package/dist/chunk-RHQLCJGG.mjs +7 -0
- package/dist/chunk-RHQLCJGG.mjs.map +1 -0
- package/dist/failed-response-status-reasons-0ab19e06.d.ts +49 -0
- package/dist/graphql/types/base/index.mjs +2 -1
- package/dist/graphql/types/converted/index.mjs +3 -2
- package/dist/{index-f0875df3.d.ts → index-0e75acd2.d.ts} +86 -59
- package/dist/index.d.ts +7 -4
- package/dist/index.js +536 -169
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -13
- package/dist/index.mjs.map +1 -1
- package/dist/{langchain-adapter-9ce103f3.d.ts → langchain-adapter-a02d1d38.d.ts} +4 -4
- package/dist/{langserve-fd5066ee.d.ts → langserve-75ebbc38.d.ts} +25 -9
- package/dist/lib/cloud/index.d.ts +6 -0
- package/dist/lib/cloud/index.js +18 -0
- package/dist/lib/cloud/index.js.map +1 -0
- package/dist/lib/cloud/index.mjs +1 -0
- package/dist/lib/cloud/index.mjs.map +1 -0
- package/dist/lib/index.d.ts +6 -4
- package/dist/lib/index.js +530 -169
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +9 -13
- package/dist/lib/integrations/index.d.ts +5 -3
- package/dist/lib/integrations/index.js +426 -64
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +7 -5
- package/dist/lib/integrations/node-http/index.d.ts +4 -2
- package/dist/lib/integrations/node-http/index.js +416 -52
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +6 -4
- package/dist/pages-router-e81920d5.d.ts +21 -0
- package/dist/service-adapters/index.d.ts +2 -2
- package/dist/service-adapters/index.js +82 -25
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +5 -4
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +174 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +12 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +6 -4
- package/src/graphql/inputs/cloud-guardrails.input.ts +2 -5
- package/src/graphql/inputs/cloud.input.ts +2 -2
- package/src/graphql/resolvers/copilot.resolver.ts +340 -30
- package/src/graphql/types/response-status.type.ts +16 -2
- package/src/index.ts +1 -0
- package/src/lib/cloud/index.ts +4 -0
- package/src/lib/copilot-runtime.ts +116 -70
- package/src/lib/index.ts +0 -1
- package/src/lib/integrations/nextjs/app-router.ts +9 -17
- package/src/lib/integrations/nextjs/pages-router.ts +9 -15
- package/src/lib/integrations/node-http/index.ts +6 -14
- package/src/lib/integrations/shared.ts +38 -18
- package/src/lib/logger.ts +28 -0
- package/src/service-adapters/events.ts +20 -2
- package/src/service-adapters/experimental/groq/groq-adapter.ts +3 -1
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +3 -1
- package/src/service-adapters/google/google-genai-adapter.ts +6 -1
- package/src/service-adapters/google/utils.ts +1 -1
- package/src/service-adapters/index.ts +1 -1
- package/src/service-adapters/langchain/langchain-adapter.ts +8 -9
- package/src/service-adapters/langchain/langserve.ts +10 -4
- package/src/service-adapters/langchain/utils.ts +58 -9
- package/src/service-adapters/openai/openai-adapter.ts +8 -7
- package/src/service-adapters/openai/openai-assistant-adapter.ts +6 -8
- package/src/service-adapters/service-adapter.ts +1 -2
- package/src/utils/failed-response-status-reasons.ts +48 -0
- package/src/utils/index.ts +1 -0
- package/dist/chunk-2CCVVJDU.mjs.map +0 -1
- package/dist/chunk-4UA4RB4C.mjs.map +0 -1
- package/dist/chunk-5HGYI6EG.mjs.map +0 -1
- package/dist/chunk-7IFP53C6.mjs.map +0 -1
- package/dist/chunk-NFCPM5AM.mjs.map +0 -1
- package/dist/chunk-XPAUPJMW.mjs.map +0 -1
- package/dist/pages-router-b6bc6c60.d.ts +0 -30
- package/src/lib/copilot-cloud.ts +0 -63
- package/src/lib/guardrails.ts +0 -3
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import * as graphql_yoga from 'graphql-yoga';
|
|
2
|
-
import { YogaServerInstance } from 'graphql-yoga';
|
|
3
|
-
import { a as CopilotRuntime, G as GraphQLContext } from './index-f0875df3.js';
|
|
4
|
-
import { C as CopilotServiceAdapter } from './langserve-fd5066ee.js';
|
|
5
|
-
|
|
6
|
-
declare function copilotRuntimeNextJSAppRouterEndpoint({ runtime, endpoint, serviceAdapter, }: {
|
|
7
|
-
runtime: CopilotRuntime;
|
|
8
|
-
serviceAdapter: CopilotServiceAdapter;
|
|
9
|
-
endpoint: string;
|
|
10
|
-
}): {
|
|
11
|
-
handleRequest: graphql_yoga.YogaServerInstance<{}, Partial<GraphQLContext>>;
|
|
12
|
-
GET: graphql_yoga.YogaServerInstance<{}, Partial<GraphQLContext>>;
|
|
13
|
-
POST: graphql_yoga.YogaServerInstance<{}, Partial<GraphQLContext>>;
|
|
14
|
-
OPTIONS: graphql_yoga.YogaServerInstance<{}, Partial<GraphQLContext>>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
declare const config: {
|
|
18
|
-
api: {
|
|
19
|
-
bodyParser: boolean;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
type CopilotRuntimeServerInstance<T> = YogaServerInstance<T, Partial<GraphQLContext>>;
|
|
23
|
-
|
|
24
|
-
declare function copilotRuntimeNextJSPagesRouterEndpoint({ runtime, endpoint, serviceAdapter, }: {
|
|
25
|
-
runtime: CopilotRuntime;
|
|
26
|
-
serviceAdapter: CopilotServiceAdapter;
|
|
27
|
-
endpoint: string;
|
|
28
|
-
}): CopilotRuntimeServerInstance<GraphQLContext>;
|
|
29
|
-
|
|
30
|
-
export { CopilotRuntimeServerInstance as C, config as a, copilotRuntimeNextJSPagesRouterEndpoint as b, copilotRuntimeNextJSAppRouterEndpoint as c };
|
package/src/lib/copilot-cloud.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
COPILOT_CLOUD_API_URL,
|
|
3
|
-
COPILOT_CLOUD_VERSION,
|
|
4
|
-
COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,
|
|
5
|
-
CopilotCloudConfig,
|
|
6
|
-
} from "@copilotkit/shared";
|
|
7
|
-
|
|
8
|
-
export interface CloudCheckGuardrailsInputParams {
|
|
9
|
-
cloud: CopilotCloudConfig;
|
|
10
|
-
publicApiKey: string;
|
|
11
|
-
// TODO-PROTOCOL: switch to graphql
|
|
12
|
-
messages: any[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface CloudCheckGuardrailsInputResponse {
|
|
16
|
-
status: "allowed" | "denied";
|
|
17
|
-
reason: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export abstract class CopilotCloud {
|
|
21
|
-
abstract checkGuardrailsInput(
|
|
22
|
-
params: CloudCheckGuardrailsInputParams,
|
|
23
|
-
): Promise<CloudCheckGuardrailsInputResponse>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class RemoteCopilotCloud extends CopilotCloud {
|
|
27
|
-
constructor(private readonly cloudApiUrl: string = COPILOT_CLOUD_API_URL) {
|
|
28
|
-
super();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async checkGuardrailsInput({
|
|
32
|
-
cloud,
|
|
33
|
-
publicApiKey,
|
|
34
|
-
messages,
|
|
35
|
-
}: CloudCheckGuardrailsInputParams): Promise<CloudCheckGuardrailsInputResponse> {
|
|
36
|
-
const url = `${this.cloudApiUrl}/${COPILOT_CLOUD_VERSION}/copilotkit/guardrails/input`;
|
|
37
|
-
|
|
38
|
-
const response = await fetch(url, {
|
|
39
|
-
method: "PUT",
|
|
40
|
-
headers: {
|
|
41
|
-
"Content-Type": "application/json",
|
|
42
|
-
[COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey,
|
|
43
|
-
},
|
|
44
|
-
body: JSON.stringify({ messages, cloud }),
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
if (!response.ok) {
|
|
48
|
-
let message = response.statusText;
|
|
49
|
-
|
|
50
|
-
// try to parse the response body for a more detailed error message
|
|
51
|
-
try {
|
|
52
|
-
const json = await response.json();
|
|
53
|
-
if (json.message) {
|
|
54
|
-
message = json.message;
|
|
55
|
-
}
|
|
56
|
-
} catch (error) {}
|
|
57
|
-
|
|
58
|
-
throw new Error("Failed to check input guardrails: " + message);
|
|
59
|
-
}
|
|
60
|
-
const json = await response.json();
|
|
61
|
-
return { status: json.status, reason: json.reason };
|
|
62
|
-
}
|
|
63
|
-
}
|
package/src/lib/guardrails.ts
DELETED