@worktango/ai-assistant 0.0.28 → 0.0.30
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/express.d.ts +38 -0
- package/package.json +3 -3
- package/react.d.ts +47 -0
- package/types.d.ts +0 -94
package/express.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { RequestHandler, Request, Application } from "express";
|
|
2
|
+
|
|
3
|
+
export function setupAiAssistantRoutes(args: {
|
|
4
|
+
app: Application;
|
|
5
|
+
/**
|
|
6
|
+
* A function that returns the bearer token for the AI assistant to use for
|
|
7
|
+
* back-channel request proxying. This should be a JWT token that can be
|
|
8
|
+
* decoded on the `kazoo-web` application to authenticate the request.
|
|
9
|
+
*/
|
|
10
|
+
getBearerToken: () => Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* The host of the application to proxy requests to.
|
|
13
|
+
*/
|
|
14
|
+
targetHost: string;
|
|
15
|
+
/**
|
|
16
|
+
* The port of the application to proxy requests to. Defaults to 80.
|
|
17
|
+
*/
|
|
18
|
+
targetPort?: number;
|
|
19
|
+
/**
|
|
20
|
+
* The route path to the local service's AI assistant. Defaults to
|
|
21
|
+
* "/ai-assistant".
|
|
22
|
+
*/
|
|
23
|
+
route?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The logger to use for logging.
|
|
26
|
+
*/
|
|
27
|
+
logger?: Pick<typeof console, "log" | "error" | "debug">;
|
|
28
|
+
/**
|
|
29
|
+
* Middleware functions to run before the proxy request.
|
|
30
|
+
*/
|
|
31
|
+
preflightMiddlewares?: RequestHandler[];
|
|
32
|
+
/**
|
|
33
|
+
* A function that should return the target path for the proxy request, based
|
|
34
|
+
* on the incoming request object. The path returned will be appended to the
|
|
35
|
+
* target host and port to form the final URL.
|
|
36
|
+
*/
|
|
37
|
+
getTargetPath: (req: Request) => string;
|
|
38
|
+
}): void;
|
package/package.json
CHANGED
package/react.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
type ToolDeclaration = {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
parameters?: any;
|
|
5
|
+
chatItemMatches?: (chatItem: {
|
|
6
|
+
role: "user" | "model" | "tool";
|
|
7
|
+
parts: ChatData[];
|
|
8
|
+
}) => boolean;
|
|
9
|
+
fulfill: (result: any) => Promise<string>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type ChatData = ChatDataText | ChatDataToolCall | ChatDataToolResult;
|
|
13
|
+
|
|
14
|
+
type ChatDataText = { type: "text"; text: string };
|
|
15
|
+
|
|
16
|
+
type ChatDataToolCall = {
|
|
17
|
+
type: "toolCall";
|
|
18
|
+
toolName: string;
|
|
19
|
+
args: Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type ChatDataToolResult = {
|
|
23
|
+
type: "toolResult";
|
|
24
|
+
toolName: string;
|
|
25
|
+
result: any;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function AiAssistant({
|
|
29
|
+
tools,
|
|
30
|
+
}: {
|
|
31
|
+
tools?: ToolDeclaration[];
|
|
32
|
+
}): JSX.Element;
|
|
33
|
+
|
|
34
|
+
export const tools: {
|
|
35
|
+
kazooTools: {
|
|
36
|
+
getRewardsAndRecognitionCurrentUserTool: ToolDeclaration;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const config: {
|
|
41
|
+
getLlmCallUrl: () => string;
|
|
42
|
+
getKazooUrl: (urlPath: string) => string;
|
|
43
|
+
getPulseUrl: (urlPath: string) => string;
|
|
44
|
+
setKazooUrlStrategy: (strategy: (urlPath: string) => string) => void;
|
|
45
|
+
setLlmCallUrlStrategy: (strategy: () => string) => void;
|
|
46
|
+
setPulseUrlStrategy: (strategy: (urlPath: string) => string) => void;
|
|
47
|
+
};
|
package/types.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
type ToolDeclaration = {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
parameters?: JsonSchema;
|
|
5
|
-
chatItemMatches?: (chatItem: {
|
|
6
|
-
role: "user" | "model" | "tool";
|
|
7
|
-
parts: ChatData[];
|
|
8
|
-
}) => boolean;
|
|
9
|
-
fulfill: (result: any) => Promise<string>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type ChatData = ChatDataText | ChatDataToolCall | ChatDataToolResult;
|
|
13
|
-
|
|
14
|
-
type ChatDataText = { type: "text"; text: string };
|
|
15
|
-
|
|
16
|
-
type ChatDataToolCall = {
|
|
17
|
-
type: "toolCall";
|
|
18
|
-
toolName: string;
|
|
19
|
-
args: Record<string, unknown>;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
type ChatDataToolResult = {
|
|
23
|
-
type: "toolResult";
|
|
24
|
-
toolName: string;
|
|
25
|
-
result: any;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
declare module "@worktango/ai-assistant/react" {
|
|
29
|
-
export function AiAssistant({
|
|
30
|
-
tools,
|
|
31
|
-
}: {
|
|
32
|
-
tools?: ToolDeclaration[];
|
|
33
|
-
}): JSX.Element;
|
|
34
|
-
|
|
35
|
-
export namespace tools {
|
|
36
|
-
export const kazooTools: {
|
|
37
|
-
getRewardsAndRecognitionCurrentUserTool: ToolDeclaration;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export namespace config {
|
|
42
|
-
export function getLlmCallUrl(): string;
|
|
43
|
-
export function getKazooUrl(urlPath: string): string;
|
|
44
|
-
export function getPulseUrl(urlPath: string): string;
|
|
45
|
-
export function setKazooUrlStrategy(
|
|
46
|
-
strategy: (urlPath: string) => string
|
|
47
|
-
): void;
|
|
48
|
-
export function setLlmCallUrlStrategy(strategy: () => string): void;
|
|
49
|
-
export function setPulseUrlStrategy(
|
|
50
|
-
strategy: (urlPath: string) => string
|
|
51
|
-
): void;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
declare module "@worktango/ai-assistant/express" {
|
|
56
|
-
export function setupAiAssistantRoutes(args: {
|
|
57
|
-
app: {
|
|
58
|
-
all: (path: string, ...args: any[]) => void;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* A function that returns the bearer token for the AI assistant to use for
|
|
62
|
-
* back-channel request proxying. This should be a JWT token that can be
|
|
63
|
-
* decoded on the `kazoo-web` application to authenticate the request.
|
|
64
|
-
*/
|
|
65
|
-
getBearerToken: () => Promise<string>;
|
|
66
|
-
/**
|
|
67
|
-
* The host of the application to proxy requests to.
|
|
68
|
-
*/
|
|
69
|
-
targetHost: string;
|
|
70
|
-
/**
|
|
71
|
-
* The port of the application to proxy requests to. Defaults to 80.
|
|
72
|
-
*/
|
|
73
|
-
targetPort?: number;
|
|
74
|
-
/**
|
|
75
|
-
* The route path to the local service's AI assistant. Defaults to
|
|
76
|
-
* "/ai-assistant".
|
|
77
|
-
*/
|
|
78
|
-
route?: string;
|
|
79
|
-
/**
|
|
80
|
-
* The logger to use for logging.
|
|
81
|
-
*/
|
|
82
|
-
logger?: Pick<typeof console, "log" | "error" | "debug">;
|
|
83
|
-
/**
|
|
84
|
-
* Middleware functions to run before the proxy request.
|
|
85
|
-
*/
|
|
86
|
-
preflightMiddlewares?: RequestHandler[];
|
|
87
|
-
/**
|
|
88
|
-
* A function that should return the target path for the proxy request, based
|
|
89
|
-
* on the incoming request object. The path returned will be appended to the
|
|
90
|
-
* target host and port to form the final URL.
|
|
91
|
-
*/
|
|
92
|
-
getTargetPath: (req: Request) => string;
|
|
93
|
-
}): void;
|
|
94
|
-
}
|