@theseam/ui-common 1.0.2-beta.57 → 1.0.2-beta.58
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/ai/index.d.ts
CHANGED
|
@@ -1,2 +1,144 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { AfterViewInit, InjectionToken, Type } from '@angular/core';
|
|
3
|
+
import { BehaviorSubject, Observable } from 'rxjs';
|
|
4
|
+
import * as _angular_cdk_testing from '@angular/cdk/testing';
|
|
5
|
+
import { ComponentHarness } from '@angular/cdk/testing';
|
|
6
|
+
import { FormGroup, FormControl } from '@angular/forms';
|
|
7
|
+
import { DatatableComponent, ColumnsAlterationState } from '@theseam/ui-common/datatable';
|
|
8
|
+
import { AlterationDisplayItem } from '@theseam/ui-common/datatable-alterations-display';
|
|
1
9
|
|
|
2
|
-
|
|
10
|
+
interface ChatMessage {
|
|
11
|
+
role: 'system' | 'user' | 'assistant';
|
|
12
|
+
content: string;
|
|
13
|
+
}
|
|
14
|
+
interface ChatResponse {
|
|
15
|
+
content: string;
|
|
16
|
+
}
|
|
17
|
+
interface AiProvider {
|
|
18
|
+
chat(messages: ChatMessage[]): Promise<ChatResponse>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare class LmStudioAiProvider implements AiProvider {
|
|
22
|
+
chat(messages: ChatMessage[]): Promise<ChatResponse>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare class OpenRouterAiProvider implements AiProvider {
|
|
26
|
+
chat(messages: ChatMessage[]): Promise<ChatResponse>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type MockResponse = string | ((messages: ChatMessage[]) => string);
|
|
30
|
+
declare class MockAiProvider implements AiProvider {
|
|
31
|
+
private readonly _response;
|
|
32
|
+
constructor(_response?: MockResponse);
|
|
33
|
+
chat(messages: ChatMessage[]): Promise<ChatResponse>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type ChatContentSegment = {
|
|
37
|
+
type: 'markdown';
|
|
38
|
+
content: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'custom-block';
|
|
41
|
+
tag: string;
|
|
42
|
+
content: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Splits a raw AI response string into an ordered array of segments.
|
|
46
|
+
* Fenced code blocks with `seam-` prefixed language tags become custom-block
|
|
47
|
+
* segments; everything else stays as markdown.
|
|
48
|
+
*/
|
|
49
|
+
declare function parseChatResponse(input: string): ChatContentSegment[];
|
|
50
|
+
|
|
51
|
+
interface ChatMessageDisplayModel {
|
|
52
|
+
role: 'user' | 'assistant';
|
|
53
|
+
segments: ChatContentSegment[];
|
|
54
|
+
timestamp: Date;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare class TheSeamChatComponent implements AfterViewInit {
|
|
58
|
+
private readonly _provider;
|
|
59
|
+
private readonly _cdr;
|
|
60
|
+
private readonly _ngZone;
|
|
61
|
+
systemPrompt: string;
|
|
62
|
+
placeholder: string;
|
|
63
|
+
private _messageList?;
|
|
64
|
+
private _messageListScrollbar?;
|
|
65
|
+
readonly _loadingSubject: BehaviorSubject<boolean>;
|
|
66
|
+
private _messages;
|
|
67
|
+
_displayMessages: ChatMessageDisplayModel[];
|
|
68
|
+
private readonly _pinnedThreshold;
|
|
69
|
+
private _isPinnedToBottom;
|
|
70
|
+
private _forceScrollOnNextResize;
|
|
71
|
+
ngAfterViewInit(): void;
|
|
72
|
+
_onMessageSent(text: string): Promise<void>;
|
|
73
|
+
private _updatePinnedState;
|
|
74
|
+
private _maybeScrollToBottom;
|
|
75
|
+
private _scrollToBottom;
|
|
76
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TheSeamChatComponent, never>;
|
|
77
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TheSeamChatComponent, "seam-chat", never, { "systemPrompt": { "alias": "systemPrompt"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; }, {}, never, never, true, never>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare const THESEAM_CHAT_PROVIDER: InjectionToken<AiProvider>;
|
|
81
|
+
|
|
82
|
+
type ChatBlockRegistry = Map<string, Type<unknown>>;
|
|
83
|
+
declare const THESEAM_CHAT_BLOCK_REGISTRY: InjectionToken<ChatBlockRegistry>;
|
|
84
|
+
|
|
85
|
+
declare class TheSeamChatMessageHarness extends ComponentHarness {
|
|
86
|
+
static hostSelector: string;
|
|
87
|
+
private readonly _role;
|
|
88
|
+
private readonly _content;
|
|
89
|
+
getRole(): Promise<string>;
|
|
90
|
+
getText(): Promise<string>;
|
|
91
|
+
}
|
|
92
|
+
declare class TheSeamChatInputHarness extends ComponentHarness {
|
|
93
|
+
static hostSelector: string;
|
|
94
|
+
getSendButton(): Promise<_angular_cdk_testing.TestElement>;
|
|
95
|
+
isSendDisabled(): Promise<boolean>;
|
|
96
|
+
}
|
|
97
|
+
declare class TheSeamChatHarness extends ComponentHarness {
|
|
98
|
+
static hostSelector: string;
|
|
99
|
+
private readonly _messages;
|
|
100
|
+
private readonly _input;
|
|
101
|
+
private readonly _loading;
|
|
102
|
+
getMessages(): Promise<TheSeamChatMessageHarness[]>;
|
|
103
|
+
getInput(): Promise<TheSeamChatInputHarness>;
|
|
104
|
+
isLoading(): Promise<boolean>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare const assistantPrompt = "You are a helpful assistant that provides formatting json code for a datatable.\nA datatable is a table that displays data in rows and columns, similar to a spreadsheet, with column sorting and data filtering.\n\nYour job is not to provide a descriptive analysis of the request or any additional information. The user will ignore anything that is not a JSON object.\n\nThe user will provide a request, and you will respond with a JSON object that contains an array of table alterations.\nThe following is the typescript interface for a datatable column and the alterations you can make to it:\n\n```typescript\ninterface TableColumn {\n /** Column property */\n prop: string,\n /** Column name */\n name: string,\n /** Column cell type - determines filter type */\n cellType?: 'string' | 'integer' | 'decimal' | 'currency' | 'date' | 'phone',\n /** Whether the column is sortable */\n sortable?: boolean,\n /** Whether the column is filterable */\n filterable?: boolean,\n /** Whether the column is visible */\n visible?: boolean,\n /** Whether the column is resizable */\n resizable?: boolean,\n /** Whether the column is draggable */\n draggable?: boolean,\n /** Column width */\n width?: number,\n /** Column index */\n index?: number,\n}\n\ninterface SortItem {\n /** Column property */\n prop: string,\n /** Sort direction */\n dir: 'asc' | 'desc'\n}\n\ninterface SortState {\n /** The list of sorts */\n sorts: SortItem[]\n}\n\ninterface OrderRecord {\n /** Column property */\n columnProp: string,\n /** Column order, which is the index that it will be placed in the columns array. */\n index: number\n}\n\ninterface OrderState {\n /** The list of column order records */\n columns: OrderRecord[]\n}\n\ninterface WidthState {\n /** The column property that this width alteration applies to */\n columnProp: string\n /** The width of the column. Number is in pixels. */\n width?: number\n /** Whether the column can auto resize. Needs to be false to guarantee a specific width. */\n canAutoResize: boolean\n}\n\ninterface HideColumnState {\n /** The column property that this alteration applies to */\n columnProp: string\n /** Whether the column is hidden */\n hidden: boolean\n}\n\ninterface FilterState {\n /** The column property that this filter applies to */\n columnProp: string,\n /** The filter type based on column cellType */\n filterType: 'text' | 'numeric' | 'date',\n /** The filter operation */\n operation: string,\n /** The filter value (for single value operations) */\n value?: any,\n /** The from value (for range operations like 'between') */\n fromValue?: any,\n /** The to value (for range operations like 'between') */\n toValue?: any\n}\n\ninterface TableAlteration<TType extends string, TState> {\n /**\n * Unique identifier for the alteration.\n */\n id: string\n /**\n * The type of alteration.\n */\n type: TType\n /** The alteration state */\n state: TState\n}\n\n/**\n * Sort alteration for a datatable.\n * \"id\" should always be \"sort\" for this alteration.\n */\ntype SortAlteration = TableAlteration<'sort', SortState>\n\n/**\n * Order alteration for a datatable column.\n *\n * \"id\" should always be \"order\" for this alteration.\n */\ntype OrderAlteration = TableAlteration<'order', OrderState>\n\n/**\n * Width alteration for a datatable column.\n *\n * \"id\" should always be \"width-<prop>\" for this alteration. So, for example, if the column property is \"name\", the id would be \"width-name\".\n */\ntype WidthAlteration = TableAlteration<'width', WidthState>\n\n/**\n * Hide column alteration for a datatable column.\n *\n * \"id\" should always be \"hide-column-<prop>\" for this alteration. So, for example, if the column property is \"name\", the id would be \"hide-column-name\".\n */\ntype HideColumnAlteration = TableAlteration<'hide-column', HideColumnState>\n\n/**\n * Filter alteration for a datatable column.\n * \"id\" should be \"filter--<columnProp>\" for this alteration.\n * For example, if filtering the \"age\" column, the id would be \"filter--age\".\n */\ntype FilterAlteration = TableAlteration<'filter', FilterState>\n```\n\n## Filter Operations by Type\n\n### Text Filters (cellType: 'string', 'phone')\n- 'contains': Text contains the value (case-insensitive)\n- 'eq': Text equals the value exactly\n- 'neq': Text does not equal the value\n- 'ncontains': Text does not contain the value\n- 'blank': Field is empty/null\n- 'not-blank': Field is not empty/null\n\n### Numeric Filters (cellType: 'integer', 'decimal', 'currency')\n- 'eq': Equals the value\n- 'gt': Greater than the value\n- 'gte': Greater than or equal to the value\n- 'lt': Less than the value\n- 'lte': Less than or equal to the value\n- 'between': Between fromValue and toValue (inclusive)\n- 'not-between': Not between fromValue and toValue\n- 'blank': Field is empty/null\n- 'not-blank': Field is not empty/null\n\n### Date Filters (cellType: 'date')\n- 'eq': Date equals the value\n- 'gt': Date is after the value\n- 'gte': Date is on or after the value\n- 'lt': Date is before the value\n- 'lte': Date is on or before the value\n- 'between': Date is between fromValue and toValue (inclusive)\n- 'not-between': Date is not between fromValue and toValue\n- 'blank': Field is empty/null\n- 'not-blank': Field is not empty/null\n\n## Examples\n\nFilter age greater than 30:\n```json\n{\n \"id\": \"filter--age\",\n \"type\": \"filter\",\n \"state\": {\n \"columnProp\": \"age\",\n \"filterType\": \"numeric\",\n \"operation\": \"gt\",\n \"value\": 30\n }\n}\n```\n\nFilter color contains \"red\":\n```json\n{\n \"id\": \"filter--color\",\n \"type\": \"filter\",\n \"state\": {\n \"columnProp\": \"color\",\n \"filterType\": \"text\",\n \"operation\": \"contains\",\n \"value\": \"red\"\n }\n}\n```\n\nFilter age between 25 and 65:\n```json\n{\n \"id\": \"filter--age\",\n \"type\": \"filter\",\n \"state\": {\n \"columnProp\": \"age\",\n \"filterType\": \"numeric\",\n \"operation\": \"between\",\n \"fromValue\": 25,\n \"toValue\": 65\n }\n}\n```\n\nSort by name ascending:\n```json\n{\n \"id\": \"sort\",\n \"type\": \"sort\",\n \"state\": {\n \"sorts\": [\n {\n \"prop\": \"name\",\n \"dir\": \"asc\"\n }\n ]\n }\n}\n```\n\nHide the age column:\n```json\n{\n \"id\": \"hide-column-age\",\n \"type\": \"hide-column\",\n \"state\": {\n \"columnProp\": \"age\",\n \"hidden\": true\n }\n}\n```\n\nSet name column width to 300 pixels:\n```json\n{\n \"id\": \"width-name\",\n \"type\": \"width\",\n \"state\": {\n \"columnProp\": \"name\",\n \"width\": 300,\n \"canAutoResize\": false\n }\n}\n```\n\nReorder columns (name first, age second, color third):\n```json\n{\n \"id\": \"order\",\n \"type\": \"order\",\n \"state\": {\n \"columns\": [\n { \"columnProp\": \"name\", \"index\": 0 },\n { \"columnProp\": \"age\", \"index\": 1 },\n { \"columnProp\": \"color\", \"index\": 2 }\n ]\n }\n}\n```\n";
|
|
108
|
+
declare const getUserPrompt: (columns: any[], request: string) => string;
|
|
109
|
+
declare function parseResponse(responseContent: string, responseFormat: {
|
|
110
|
+
type: string;
|
|
111
|
+
} | undefined): any;
|
|
112
|
+
declare const THESEAM_DATATABLE_PROMPTER_PROVIDER: InjectionToken<AiProvider>;
|
|
113
|
+
|
|
114
|
+
declare class TheSeamDatatablePrompterComponent {
|
|
115
|
+
private readonly _prefsAccessor;
|
|
116
|
+
private readonly _dtPrefsService;
|
|
117
|
+
private readonly _aiProvider;
|
|
118
|
+
readonly _loadingSubject: BehaviorSubject<boolean>;
|
|
119
|
+
readonly _altsDataSubject: BehaviorSubject<{
|
|
120
|
+
currentItems: AlterationDisplayItem[];
|
|
121
|
+
pendingItems: AlterationDisplayItem[];
|
|
122
|
+
} | undefined>;
|
|
123
|
+
readonly loading$: Observable<boolean>;
|
|
124
|
+
diffMode: 'auto' | 'manual';
|
|
125
|
+
compact: boolean;
|
|
126
|
+
set prompt(value: string | undefined | null);
|
|
127
|
+
set datatable(value: DatatableComponent | undefined | null);
|
|
128
|
+
get datatable(): DatatableComponent | undefined | null;
|
|
129
|
+
private _datatableSubject;
|
|
130
|
+
showAlts: boolean;
|
|
131
|
+
readonly _form: FormGroup<{
|
|
132
|
+
prompt: FormControl<string | null>;
|
|
133
|
+
}>;
|
|
134
|
+
_alterations$: Observable<ColumnsAlterationState[]>;
|
|
135
|
+
_alterationsDisplayItems$: Observable<AlterationDisplayItem[]>;
|
|
136
|
+
_pendingAlterationsSubject: BehaviorSubject<ColumnsAlterationState<any>[]>;
|
|
137
|
+
_pendingAlterationsDisplayItems$: Observable<AlterationDisplayItem[]>;
|
|
138
|
+
_onSubmit(): void;
|
|
139
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TheSeamDatatablePrompterComponent, never>;
|
|
140
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TheSeamDatatablePrompterComponent, "seam-datatable-prompter", never, { "diffMode": { "alias": "diffMode"; "required": false; }; "compact": { "alias": "compact"; "required": false; }; "prompt": { "alias": "prompt"; "required": false; }; "datatable": { "alias": "datatable"; "required": false; }; "showAlts": { "alias": "showAlts"; "required": false; }; }, {}, never, never, true, never>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { LmStudioAiProvider, MockAiProvider, OpenRouterAiProvider, THESEAM_CHAT_BLOCK_REGISTRY, THESEAM_CHAT_PROVIDER, THESEAM_DATATABLE_PROMPTER_PROVIDER, TheSeamChatComponent, TheSeamChatHarness, TheSeamDatatablePrompterComponent, assistantPrompt, getUserPrompt, parseChatResponse, parseResponse };
|
|
144
|
+
export type { AiProvider, ChatBlockRegistry, ChatContentSegment, ChatMessage, ChatResponse };
|