orchid-ai 1.0.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/README.md +225 -0
- package/dist/components/ChatPanel.d.ts +123 -0
- package/dist/components/Conversation.d.ts +75 -0
- package/dist/components/ErrorBoundary.d.ts +16 -0
- package/dist/components/Icon.d.ts +84 -0
- package/dist/components/ModelSwitcher.d.ts +24 -0
- package/dist/components/SuggestionsPanel.d.ts +27 -0
- package/dist/constants.d.ts +353 -0
- package/dist/hooks/useAiMerge.d.ts +20 -0
- package/dist/hooks/useModelSwitcher.d.ts +65 -0
- package/dist/hooks/useStreamingAI.d.ts +29 -0
- package/dist/hooks/useSuggestions.d.ts +48 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.esm.js +3385 -0
- package/dist/index.js +3400 -0
- package/dist/server/components/ChatPanel.d.ts +123 -0
- package/dist/server/components/Conversation.d.ts +75 -0
- package/dist/server/components/ErrorBoundary.d.ts +16 -0
- package/dist/server/components/Icon.d.ts +84 -0
- package/dist/server/components/ModelSwitcher.d.ts +24 -0
- package/dist/server/components/SuggestionsPanel.d.ts +27 -0
- package/dist/server/constants.d.ts +353 -0
- package/dist/server/contextual-service.d.ts +59 -0
- package/dist/server/document-processor.d.ts +60 -0
- package/dist/server/hooks/useAiMerge.d.ts +20 -0
- package/dist/server/hooks/useModelSwitcher.d.ts +65 -0
- package/dist/server/hooks/useStreamingAI.d.ts +29 -0
- package/dist/server/hooks/useSuggestions.d.ts +48 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.esm.js +14008 -0
- package/dist/server/index.js +14019 -0
- package/dist/server/server/contextual-service.d.ts +59 -0
- package/dist/server/server/document-processor.d.ts +60 -0
- package/dist/server/server/index.d.ts +7 -0
- package/dist/server/server/server.d.ts +32 -0
- package/dist/server/server/service.d.ts +267 -0
- package/dist/server/server/training-schema.d.ts +17 -0
- package/dist/server/server/training.d.ts +231 -0
- package/dist/server/server/utils.d.ts +209 -0
- package/dist/server/server.d.ts +32 -0
- package/dist/server/service.d.ts +267 -0
- package/dist/server/training-schema.d.ts +17 -0
- package/dist/server/training.d.ts +231 -0
- package/dist/server/types/types.d.ts +481 -0
- package/dist/server/utils/fileHandler.d.ts +20 -0
- package/dist/server/utils/mergeWithAi.d.ts +19 -0
- package/dist/server/utils.d.ts +209 -0
- package/dist/types/types.d.ts +481 -0
- package/dist/utils/fileHandler.d.ts +20 -0
- package/dist/utils/mergeWithAi.d.ts +19 -0
- package/dist/utils.d.ts +19 -0
- package/package.json +137 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { ChatTheme, CommandTheme, ModelInfo } from './types/types';
|
|
2
|
+
export declare const DEFAULT_CONFIG: {
|
|
3
|
+
service: "claude";
|
|
4
|
+
model: string;
|
|
5
|
+
temperature: number;
|
|
6
|
+
maxTokens: number;
|
|
7
|
+
chatLevel: "none";
|
|
8
|
+
supportsImages: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const DEFAULT_MODELS: Record<string, ModelInfo[]>;
|
|
11
|
+
export declare const defaultTheme: CommandTheme;
|
|
12
|
+
export declare const defaultDarkTheme: ChatTheme;
|
|
13
|
+
export declare const defaultLightTheme: ChatTheme;
|
|
14
|
+
export declare const commandTrainingRules: {
|
|
15
|
+
components: {
|
|
16
|
+
patterns: {
|
|
17
|
+
componentName: RegExp;
|
|
18
|
+
props: RegExp;
|
|
19
|
+
state: RegExp;
|
|
20
|
+
functions: RegExp;
|
|
21
|
+
routes: RegExp;
|
|
22
|
+
formFields: RegExp;
|
|
23
|
+
imports: RegExp;
|
|
24
|
+
exports: RegExp;
|
|
25
|
+
hooks: RegExp;
|
|
26
|
+
eventHandlers: RegExp;
|
|
27
|
+
};
|
|
28
|
+
importance: string[];
|
|
29
|
+
};
|
|
30
|
+
schemas: {
|
|
31
|
+
patterns: {
|
|
32
|
+
modelName: RegExp;
|
|
33
|
+
fields: RegExp;
|
|
34
|
+
fieldDefinitions: RegExp;
|
|
35
|
+
indexes: RegExp;
|
|
36
|
+
indexDefinitions: RegExp;
|
|
37
|
+
validations: RegExp;
|
|
38
|
+
validationRules: RegExp;
|
|
39
|
+
};
|
|
40
|
+
importance: string[];
|
|
41
|
+
};
|
|
42
|
+
constants: {
|
|
43
|
+
patterns: {
|
|
44
|
+
definitions: RegExp;
|
|
45
|
+
constValues: RegExp;
|
|
46
|
+
enums: RegExp;
|
|
47
|
+
enumValues: RegExp;
|
|
48
|
+
arrayConstants: RegExp;
|
|
49
|
+
objectConstants: RegExp;
|
|
50
|
+
};
|
|
51
|
+
importance: string[];
|
|
52
|
+
};
|
|
53
|
+
types: {
|
|
54
|
+
patterns: {
|
|
55
|
+
types: RegExp;
|
|
56
|
+
typeDefinitions: RegExp;
|
|
57
|
+
interfaces: RegExp;
|
|
58
|
+
interfaceDefinitions: RegExp;
|
|
59
|
+
enums: RegExp;
|
|
60
|
+
enumMembers: RegExp;
|
|
61
|
+
generics: RegExp;
|
|
62
|
+
unionTypes: RegExp;
|
|
63
|
+
optionalFields: RegExp;
|
|
64
|
+
};
|
|
65
|
+
importance: string[];
|
|
66
|
+
};
|
|
67
|
+
dataTypes: {
|
|
68
|
+
date: {
|
|
69
|
+
pattern: RegExp;
|
|
70
|
+
transform: (value: any) => any;
|
|
71
|
+
validation: (value: any) => boolean;
|
|
72
|
+
};
|
|
73
|
+
number: {
|
|
74
|
+
pattern: RegExp;
|
|
75
|
+
transform: (value: any) => number;
|
|
76
|
+
validation: (value: any) => boolean;
|
|
77
|
+
};
|
|
78
|
+
boolean: {
|
|
79
|
+
pattern: RegExp;
|
|
80
|
+
transform: (value: any) => boolean;
|
|
81
|
+
validation: (value: any) => value is boolean;
|
|
82
|
+
};
|
|
83
|
+
string: {
|
|
84
|
+
pattern: RegExp;
|
|
85
|
+
transform: (value: any) => string;
|
|
86
|
+
validation: (value: any) => value is string;
|
|
87
|
+
};
|
|
88
|
+
array: {
|
|
89
|
+
pattern: RegExp;
|
|
90
|
+
transform: (value: any) => any[];
|
|
91
|
+
validation: (value: any) => value is any[];
|
|
92
|
+
};
|
|
93
|
+
object: {
|
|
94
|
+
pattern: RegExp;
|
|
95
|
+
transform: (value: any) => any;
|
|
96
|
+
validation: (value: any) => boolean;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
dataTypeImportance: string[];
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Base training data for the command service.
|
|
103
|
+
*
|
|
104
|
+
* NOTE: You should customize the following for your project:
|
|
105
|
+
* - components: List all relevant React component files.
|
|
106
|
+
* - schemas: List all Monastery schema files.
|
|
107
|
+
* - constants: List all constants files.
|
|
108
|
+
* - types: List all TypeScript type files.
|
|
109
|
+
* - options: Define all field options and refinement logic for your domain.
|
|
110
|
+
* - _paths: Metadata specifying which fields contain file paths (used by collector).
|
|
111
|
+
*
|
|
112
|
+
* The collector will extract structured data including:
|
|
113
|
+
* - Component names, props, state, functions, form fields
|
|
114
|
+
* - Schema field definitions with types and validations
|
|
115
|
+
* - Constant values and enum members
|
|
116
|
+
* - TypeScript interfaces and type definitions
|
|
117
|
+
*/
|
|
118
|
+
export declare const baseTrainingData: {
|
|
119
|
+
/**
|
|
120
|
+
* List of React component file paths used for context.
|
|
121
|
+
* The collector will extract: component names, props, state, functions, form fields, imports, hooks
|
|
122
|
+
* @type {string[]}
|
|
123
|
+
*/
|
|
124
|
+
components: never[];
|
|
125
|
+
/**
|
|
126
|
+
* List of Monastery schema file paths.
|
|
127
|
+
* The collector will extract: model names, field definitions, indexes, validations
|
|
128
|
+
* @type {string[]}
|
|
129
|
+
*/
|
|
130
|
+
schemas: never[];
|
|
131
|
+
/**
|
|
132
|
+
* List of constants file paths.
|
|
133
|
+
* The collector will extract: constant definitions, values, enums
|
|
134
|
+
* @type {string[]}
|
|
135
|
+
*/
|
|
136
|
+
constants: never[];
|
|
137
|
+
/**
|
|
138
|
+
* List of TypeScript type file paths.
|
|
139
|
+
* The collector will extract: type definitions, interfaces, enums
|
|
140
|
+
* @type {string[]}
|
|
141
|
+
*/
|
|
142
|
+
types: never[];
|
|
143
|
+
/**
|
|
144
|
+
* Manual route definitions with descriptions.
|
|
145
|
+
* Define all available routes with clear descriptions for the AI to understand.
|
|
146
|
+
* Format: { path: string, title: string, description?: string }
|
|
147
|
+
* @type {Array<{path: string, title: string, description?: string}>}
|
|
148
|
+
*/
|
|
149
|
+
routes: never[];
|
|
150
|
+
/**
|
|
151
|
+
* Field options and refinement logic. Customize for your domain fields.
|
|
152
|
+
* The AI will use these to understand field values and validation rules.
|
|
153
|
+
* @type {Object}
|
|
154
|
+
*/
|
|
155
|
+
options: {};
|
|
156
|
+
/**
|
|
157
|
+
* Metadata specifying which fields contain file paths for the collector.
|
|
158
|
+
* The collector will automatically read and process these fields.
|
|
159
|
+
* Note: 'routes' is now handled manually - no automatic extraction.
|
|
160
|
+
* @type {string[]}
|
|
161
|
+
*/
|
|
162
|
+
_paths: never[];
|
|
163
|
+
/**
|
|
164
|
+
* Action types.
|
|
165
|
+
* The AI will use these to understand the user's input
|
|
166
|
+
* and return the correct suggestions for icon display
|
|
167
|
+
* @type {Object}
|
|
168
|
+
*/
|
|
169
|
+
actionTypes: {
|
|
170
|
+
type: string;
|
|
171
|
+
description: string;
|
|
172
|
+
}[];
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Instructions for a fully conversational AI assistant.
|
|
176
|
+
* Always provides chatty, helpful responses regardless of context.
|
|
177
|
+
*/
|
|
178
|
+
export declare const fullChatInstructions: string;
|
|
179
|
+
/**
|
|
180
|
+
* Instructions for a basic conversational AI assistant.
|
|
181
|
+
* Balances being helpful with being concise, focusing on essential help and actions.
|
|
182
|
+
*/
|
|
183
|
+
export declare const basicChatInstructions: string;
|
|
184
|
+
/**
|
|
185
|
+
* Instructions for a functional, JSON-only AI assistant.
|
|
186
|
+
* Provides only JSON responses with no explanations or commentary.
|
|
187
|
+
*/
|
|
188
|
+
export declare const noneChatInstructions: string;
|
|
189
|
+
/**
|
|
190
|
+
* Structured training data format optimized for AI models
|
|
191
|
+
* Organizes information hierarchically with clear relationships
|
|
192
|
+
*/
|
|
193
|
+
export declare const structuredTrainingFormat: {
|
|
194
|
+
/**
|
|
195
|
+
* Application Overview - High-level context for the AI
|
|
196
|
+
*/
|
|
197
|
+
overview: {
|
|
198
|
+
domain: string;
|
|
199
|
+
purpose: string;
|
|
200
|
+
architecture: string;
|
|
201
|
+
primaryEntities: string[];
|
|
202
|
+
commonActions: string[];
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Component Hierarchy - Organized by functionality
|
|
206
|
+
*/
|
|
207
|
+
components: {
|
|
208
|
+
pages: Array<{
|
|
209
|
+
name: string;
|
|
210
|
+
path: string;
|
|
211
|
+
purpose: string;
|
|
212
|
+
mainActions: string[];
|
|
213
|
+
relatedEntities: string[];
|
|
214
|
+
}>;
|
|
215
|
+
forms: Array<{
|
|
216
|
+
name: string;
|
|
217
|
+
purpose: string;
|
|
218
|
+
fields: Array<{
|
|
219
|
+
name: string;
|
|
220
|
+
type: string;
|
|
221
|
+
required: boolean;
|
|
222
|
+
validation?: string;
|
|
223
|
+
}>;
|
|
224
|
+
actions: string[];
|
|
225
|
+
relatedEntity: string;
|
|
226
|
+
}>;
|
|
227
|
+
ui: Array<{
|
|
228
|
+
name: string;
|
|
229
|
+
purpose: string;
|
|
230
|
+
props: Array<{
|
|
231
|
+
name: string;
|
|
232
|
+
type: string;
|
|
233
|
+
required: boolean;
|
|
234
|
+
}>;
|
|
235
|
+
}>;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Data Models - Structured with relationships
|
|
239
|
+
*/
|
|
240
|
+
dataModels: {
|
|
241
|
+
entities: Array<{
|
|
242
|
+
name: string;
|
|
243
|
+
purpose: string;
|
|
244
|
+
fields: Array<{
|
|
245
|
+
name: string;
|
|
246
|
+
type: string;
|
|
247
|
+
required: boolean;
|
|
248
|
+
description?: string;
|
|
249
|
+
validation?: string;
|
|
250
|
+
options?: string[];
|
|
251
|
+
}>;
|
|
252
|
+
relationships: Array<{
|
|
253
|
+
type: "hasMany" | "belongsTo" | "hasOne";
|
|
254
|
+
entity: string;
|
|
255
|
+
description: string;
|
|
256
|
+
}>;
|
|
257
|
+
commonActions: string[];
|
|
258
|
+
}>;
|
|
259
|
+
enums: Array<{
|
|
260
|
+
name: string;
|
|
261
|
+
purpose: string;
|
|
262
|
+
values: Array<{
|
|
263
|
+
key: string;
|
|
264
|
+
value: string;
|
|
265
|
+
description?: string;
|
|
266
|
+
}>;
|
|
267
|
+
}>;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Navigation & Routes - Organized by user flow
|
|
271
|
+
*/
|
|
272
|
+
navigation: {
|
|
273
|
+
routes: Array<{
|
|
274
|
+
path: string;
|
|
275
|
+
name: string;
|
|
276
|
+
purpose: string;
|
|
277
|
+
requiredParams?: string[];
|
|
278
|
+
relatedEntity?: string;
|
|
279
|
+
commonActions: string[];
|
|
280
|
+
}>;
|
|
281
|
+
workflows: Array<{
|
|
282
|
+
name: string;
|
|
283
|
+
description: string;
|
|
284
|
+
steps: Array<{
|
|
285
|
+
action: string;
|
|
286
|
+
route: string;
|
|
287
|
+
description: string;
|
|
288
|
+
}>;
|
|
289
|
+
}>;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Business Rules - Context for decision making
|
|
293
|
+
*/
|
|
294
|
+
businessRules: {
|
|
295
|
+
validation: Array<{
|
|
296
|
+
field: string;
|
|
297
|
+
rule: string;
|
|
298
|
+
message: string;
|
|
299
|
+
context: string;
|
|
300
|
+
}>;
|
|
301
|
+
workflows: Array<{
|
|
302
|
+
trigger: string;
|
|
303
|
+
conditions: string[];
|
|
304
|
+
actions: string[];
|
|
305
|
+
description: string;
|
|
306
|
+
}>;
|
|
307
|
+
permissions: Array<{
|
|
308
|
+
action: string;
|
|
309
|
+
entity: string;
|
|
310
|
+
conditions: string[];
|
|
311
|
+
description: string;
|
|
312
|
+
}>;
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* Examples - Concrete usage patterns
|
|
316
|
+
*/
|
|
317
|
+
examples: {
|
|
318
|
+
commonTasks: Array<{
|
|
319
|
+
userIntent: string;
|
|
320
|
+
expectedAction: string;
|
|
321
|
+
formData?: Record<string, any>;
|
|
322
|
+
route?: string;
|
|
323
|
+
description: string;
|
|
324
|
+
}>;
|
|
325
|
+
fieldMappings: Array<{
|
|
326
|
+
userInput: string;
|
|
327
|
+
fieldName: string;
|
|
328
|
+
processedValue: any;
|
|
329
|
+
validation?: string;
|
|
330
|
+
}>;
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Provider-specific training data formatters
|
|
335
|
+
* These functions format the structured training data in optimal ways for each AI provider
|
|
336
|
+
*/
|
|
337
|
+
export declare const trainingDataFormatters: {
|
|
338
|
+
/**
|
|
339
|
+
* Claude-optimized format: Structured markdown with clear sections
|
|
340
|
+
* Claude performs best with clear hierarchical markdown and explicit structure
|
|
341
|
+
*/
|
|
342
|
+
claude: (data: typeof structuredTrainingFormat) => string;
|
|
343
|
+
/**
|
|
344
|
+
* GPT-4-optimized format: Structured with clear hierarchy and consistent formatting
|
|
345
|
+
* OpenAI models prefer clear structure with consistent patterns
|
|
346
|
+
*/
|
|
347
|
+
openai: (data: typeof structuredTrainingFormat) => string;
|
|
348
|
+
/**
|
|
349
|
+
* Gemini-optimized format: JSON structure with nested relationships
|
|
350
|
+
* Gemini models excel at processing structured JSON data with clear relationships
|
|
351
|
+
*/
|
|
352
|
+
gemini: (data: typeof structuredTrainingFormat) => string;
|
|
353
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MergeConfig } from '../utils';
|
|
2
|
+
interface Options<T> {
|
|
3
|
+
ai?: Partial<T>;
|
|
4
|
+
draft: T;
|
|
5
|
+
onMerged: (next: T) => void;
|
|
6
|
+
config?: MergeConfig<T>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* React hook that merges an AI-generated payload into local form state.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* const { pending, applyPending } = useAiMerge({ ai, draft, onMerged })
|
|
13
|
+
* <WarningModal isOpen={!!pending} onConfirm={applyPending} />
|
|
14
|
+
*/
|
|
15
|
+
export declare function useAiMerge<T>({ ai, draft, onMerged, config }: Options<T>): {
|
|
16
|
+
pending: Partial<T> | null;
|
|
17
|
+
applyPending: () => void;
|
|
18
|
+
clearPending: () => void;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ModelInfo } from '../types/types';
|
|
2
|
+
interface CurrentModel {
|
|
3
|
+
provider: string;
|
|
4
|
+
model: string;
|
|
5
|
+
}
|
|
6
|
+
interface ModelCapabilities {
|
|
7
|
+
supportsImages: boolean;
|
|
8
|
+
computeWeight?: number;
|
|
9
|
+
}
|
|
10
|
+
interface UsageStats {
|
|
11
|
+
requests: number;
|
|
12
|
+
totalTokens: number;
|
|
13
|
+
totalComputeUnits: number;
|
|
14
|
+
modelSwitches: number;
|
|
15
|
+
uptime: number;
|
|
16
|
+
providers: Array<{
|
|
17
|
+
name: string;
|
|
18
|
+
requests: number;
|
|
19
|
+
computeUnits: number;
|
|
20
|
+
models: string[];
|
|
21
|
+
}>;
|
|
22
|
+
currentProvider: string;
|
|
23
|
+
currentModel: string;
|
|
24
|
+
}
|
|
25
|
+
interface UseModelSwitcherOptions {
|
|
26
|
+
initialProvider?: string;
|
|
27
|
+
initialModel?: string;
|
|
28
|
+
customModels?: Record<string, ModelInfo[]>;
|
|
29
|
+
}
|
|
30
|
+
export declare function useModelSwitcher({ initialProvider, initialModel, customModels, }?: UseModelSwitcherOptions): {
|
|
31
|
+
models: ModelInfo[];
|
|
32
|
+
modelsByProvider: Record<string, ModelInfo[]>;
|
|
33
|
+
currentModel: CurrentModel;
|
|
34
|
+
currentCapabilities: ModelCapabilities;
|
|
35
|
+
usageStats: UsageStats;
|
|
36
|
+
isLoading: boolean;
|
|
37
|
+
error: null;
|
|
38
|
+
switchModel: (model: string, provider?: string) => {
|
|
39
|
+
success: boolean;
|
|
40
|
+
current: {
|
|
41
|
+
provider: string;
|
|
42
|
+
model: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
trackUsage: (tokens: number, computeUnits: number) => void;
|
|
46
|
+
resetUsageStats: () => void;
|
|
47
|
+
getCurrentModelInfo: () => {
|
|
48
|
+
provider: string;
|
|
49
|
+
model: string;
|
|
50
|
+
capabilities: ModelCapabilities;
|
|
51
|
+
};
|
|
52
|
+
modelState: {
|
|
53
|
+
models: ModelInfo[];
|
|
54
|
+
current: CurrentModel;
|
|
55
|
+
capabilities: ModelCapabilities;
|
|
56
|
+
usage: UsageStats;
|
|
57
|
+
timestamp: number;
|
|
58
|
+
};
|
|
59
|
+
fetchModelState: () => Promise<void>;
|
|
60
|
+
fetchModels: () => Promise<void>;
|
|
61
|
+
fetchUsageStats: () => Promise<void>;
|
|
62
|
+
fetchCurrentCapabilities: () => Promise<void>;
|
|
63
|
+
integrationMode: "local";
|
|
64
|
+
};
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ChatMessage, ModelCapabilities, ServerConfig } from '../types/types';
|
|
2
|
+
interface ModelSelection {
|
|
3
|
+
provider: string;
|
|
4
|
+
model: string;
|
|
5
|
+
capabilities: ModelCapabilities;
|
|
6
|
+
}
|
|
7
|
+
export declare function useStreamingAI({ userId, serverConfig, formData, chats: externalChats, setChats: externalSetChats, currentChatId: externalCurrentChatId, setCurrentChatId: externalSetCurrentChatId, modelSelection, onUsageTracked, chatLevel, additionalContext, verbose, }: {
|
|
8
|
+
userId: string;
|
|
9
|
+
serverConfig?: ServerConfig;
|
|
10
|
+
formData?: Record<string, unknown>;
|
|
11
|
+
chats?: Record<string, ChatMessage[]>;
|
|
12
|
+
setChats?: React.Dispatch<React.SetStateAction<Record<string, ChatMessage[]>>>;
|
|
13
|
+
currentChatId?: string;
|
|
14
|
+
setCurrentChatId?: React.Dispatch<React.SetStateAction<string>>;
|
|
15
|
+
modelSelection?: ModelSelection;
|
|
16
|
+
onUsageTracked?: (tokens: number, computeUnits: number) => void;
|
|
17
|
+
chatLevel?: 'full' | 'basic' | 'none';
|
|
18
|
+
additionalContext?: string | Record<string, unknown>;
|
|
19
|
+
verbose?: boolean;
|
|
20
|
+
}): {
|
|
21
|
+
chat: ChatMessage[];
|
|
22
|
+
chats: Record<string, ChatMessage[]>;
|
|
23
|
+
currentChatId: string;
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
sendQuery: (query: string, files?: File[], context?: string) => void;
|
|
26
|
+
newChat: () => void;
|
|
27
|
+
switchChat: (chatId: string) => void;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CommandSuggestion, ServerConfig } from '../types/types';
|
|
2
|
+
interface UseSuggestionsProps {
|
|
3
|
+
userId: string;
|
|
4
|
+
formData?: Record<string, unknown>;
|
|
5
|
+
serverConfig?: ServerConfig;
|
|
6
|
+
debounceMs?: number;
|
|
7
|
+
maxSuggestions?: number;
|
|
8
|
+
chatLevel?: 'none' | 'basic' | 'full';
|
|
9
|
+
modelSelection?: {
|
|
10
|
+
provider: string;
|
|
11
|
+
model: string;
|
|
12
|
+
capabilities: {
|
|
13
|
+
supportsImages: boolean;
|
|
14
|
+
computeWeight: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
onUsageTracked?: (tokens: number, computeUnits: number) => void;
|
|
18
|
+
context?: string;
|
|
19
|
+
}
|
|
20
|
+
interface UseSuggestionsReturn {
|
|
21
|
+
suggestions: CommandSuggestion[];
|
|
22
|
+
isLoading: boolean;
|
|
23
|
+
error: string | null;
|
|
24
|
+
getSuggestions: (query: string, additionalContext?: string) => Promise<CommandSuggestion[] | Error>;
|
|
25
|
+
clearSuggestions: () => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Hook for getting AI suggestions based on a query
|
|
29
|
+
*
|
|
30
|
+
* @param userId - User ID for the suggestion request
|
|
31
|
+
* @param formData - Current form data context
|
|
32
|
+
* @param serverConfig - Server configuration
|
|
33
|
+
* @param debounceMs - Debounce delay in milliseconds (default: 300)
|
|
34
|
+
* @param maxSuggestions - Maximum number of suggestions to return (default: 10)
|
|
35
|
+
* @param chatLevel - Chat level to send to the server (default: 'none')
|
|
36
|
+
* @returns Object containing suggestions, loading state, error state, and control functions
|
|
37
|
+
*/
|
|
38
|
+
export declare function useSuggestions({ userId, formData, serverConfig, debounceMs, maxSuggestions, chatLevel, // <-- default to 'none'
|
|
39
|
+
modelSelection, onUsageTracked, context, }: UseSuggestionsProps): UseSuggestionsReturn;
|
|
40
|
+
/**
|
|
41
|
+
* Hook for getting suggestions with automatic debouncing
|
|
42
|
+
*
|
|
43
|
+
* @param query - The search query
|
|
44
|
+
* @param options - Configuration options
|
|
45
|
+
* @returns Object containing suggestions, loading state, and error state
|
|
46
|
+
*/
|
|
47
|
+
export declare function useDebouncedSuggestions(query: string, options: UseSuggestionsProps): Omit<UseSuggestionsReturn, 'getSuggestions' | 'clearSuggestions'>;
|
|
48
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { useStreamingAI } from './hooks/useStreamingAI';
|
|
2
|
+
export { useSuggestions, useDebouncedSuggestions, } from './hooks/useSuggestions';
|
|
3
|
+
export { ChatPanel } from './components/ChatPanel';
|
|
4
|
+
export { Conversation } from './components/Conversation';
|
|
5
|
+
export { SuggestionsPanel, SuggestionCard, } from './components/SuggestionsPanel';
|
|
6
|
+
export { ModelSwitcher } from './components/ModelSwitcher';
|
|
7
|
+
export { useModelSwitcher } from './hooks/useModelSwitcher';
|
|
8
|
+
export { mergeWithAi } from './utils';
|
|
9
|
+
export { useAiMerge } from './hooks/useAiMerge';
|
|
10
|
+
export { ErrorBoundary } from './components/ErrorBoundary';
|
|
11
|
+
export { Icon as CommandIcon } from './components/Icon';
|
|
12
|
+
export type { CommandConfig, TrainingData, AIProvider, CommandTheme, CommandSuggestion, CommandPopupProps, ChatMessage, ChatTheme, AIStatus, Action, ModelInfo, ServerConfig, SchemaDefinition, SchemaProperty, ContextualServiceConfig, ContextualRequest, } from './types/types';
|
|
13
|
+
export { defaultTheme as defaultCommandTheme } from './constants';
|