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,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File processing utility
|
|
3
|
+
*/
|
|
4
|
+
export declare const FileHandler: {
|
|
5
|
+
getAcceptedTypes(): {
|
|
6
|
+
mimeTypes: string[];
|
|
7
|
+
extensions: string[];
|
|
8
|
+
descriptions: string[];
|
|
9
|
+
};
|
|
10
|
+
isFileAccepted(file: File): boolean;
|
|
11
|
+
processFiles(files: File[]): {
|
|
12
|
+
acceptedFiles: File[];
|
|
13
|
+
rejectedFiles: File[];
|
|
14
|
+
};
|
|
15
|
+
getAcceptedTypesDescription(): string;
|
|
16
|
+
getInputAcceptAttribute(): string;
|
|
17
|
+
getFileIcon(file: File): React.ReactNode;
|
|
18
|
+
formatFileSize(bytes: number): string;
|
|
19
|
+
getFileTypeDescription(file: File): string;
|
|
20
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type MergeConfig<T> = {
|
|
2
|
+
/**
|
|
3
|
+
* Map incoming AI keys → draft keys when they differ.
|
|
4
|
+
* Example: { originCity: 'origin' }
|
|
5
|
+
*/
|
|
6
|
+
keyMap?: Partial<Record<keyof T | string, keyof T>>;
|
|
7
|
+
/**
|
|
8
|
+
* Fine-grained transforms for fields that need more than simple assignment.
|
|
9
|
+
*/
|
|
10
|
+
transforms?: Partial<Record<keyof T, (val: unknown, draft: T) => unknown>>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Generic helper that patches an existing object with an AI-generated payload.
|
|
14
|
+
*
|
|
15
|
+
* • Skips undefined / null values so they never blank user input
|
|
16
|
+
* • Coerces strings → numbers when the draft already stores a number
|
|
17
|
+
* • Allows per-field key mapping & transform overrides
|
|
18
|
+
*/
|
|
19
|
+
export declare function mergeWithAi<T extends Record<string, unknown>>(draft: T, ai: Partial<T> | Record<string, unknown> | undefined, config?: MergeConfig<T>): T;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { AnalysisContext, CommandSuggestion, Intent, RouteConfig, TrainingData } from '../types/types';
|
|
2
|
+
export declare function sanitizeFormData(formData: Record<string, any> | undefined): Record<string, any>;
|
|
3
|
+
export declare function handleError(error: unknown, prefix?: string, verboseLogging?: boolean): void;
|
|
4
|
+
export declare function extractFirstJsonArray(text: string): any;
|
|
5
|
+
export declare function getModelSupportsImages(modelId: string, provider: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Check if the current model supports image input
|
|
8
|
+
* @returns {boolean} True if current model supports images
|
|
9
|
+
*/
|
|
10
|
+
export declare function currentModelSupportsImages(): string;
|
|
11
|
+
export declare function getDefaultModelsForProvider(provider: string): {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
provider: string;
|
|
15
|
+
available: boolean;
|
|
16
|
+
supportsImages: boolean;
|
|
17
|
+
}[] | {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
provider: string;
|
|
21
|
+
available: boolean;
|
|
22
|
+
supportsImages: boolean;
|
|
23
|
+
}[] | {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
provider: string;
|
|
27
|
+
available: boolean;
|
|
28
|
+
supportsImages: boolean;
|
|
29
|
+
}[];
|
|
30
|
+
/**
|
|
31
|
+
* Enhanced context analysis for better AI suggestions
|
|
32
|
+
* Analyzes chat history to extract relevant context for form state management
|
|
33
|
+
*/
|
|
34
|
+
export declare function analyzeContext(chatHistory: any[], currentCommand: string): AnalysisContext;
|
|
35
|
+
/**
|
|
36
|
+
* Extract entities (quotes, customers, shipments) from message content
|
|
37
|
+
*/
|
|
38
|
+
export declare function extractEntitiesFromMessage(content: string, context: any): void;
|
|
39
|
+
/**
|
|
40
|
+
* Extract form state information from message content
|
|
41
|
+
*/
|
|
42
|
+
export declare function extractFormStateFromMessage(content: string, context: any): void;
|
|
43
|
+
/**
|
|
44
|
+
* Extract user preferences and patterns from message content
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractUserPreferencesFromMessage(content: string, context: any): void;
|
|
47
|
+
/**
|
|
48
|
+
* Track recent actions for continuity
|
|
49
|
+
*/
|
|
50
|
+
export declare function trackRecentActions(content: string, context: any): void;
|
|
51
|
+
/**
|
|
52
|
+
* Extract data from current command
|
|
53
|
+
*/
|
|
54
|
+
export declare function extractDataFromCommand(command: string, context: any): void;
|
|
55
|
+
/**
|
|
56
|
+
* Classify user intent based on command and context
|
|
57
|
+
*/
|
|
58
|
+
export declare function classifyIntent(command: string, context: any): Intent;
|
|
59
|
+
/**
|
|
60
|
+
* Determine action type based on context and intent
|
|
61
|
+
*/
|
|
62
|
+
export declare function determineActionType(context: any, intent: string | null): "create" | "edit" | "view";
|
|
63
|
+
/**
|
|
64
|
+
* Helper: Parse and fix JSON response from any provider
|
|
65
|
+
*/
|
|
66
|
+
export declare function parseAndFixJsonResponse(content: string, provider: string): any[];
|
|
67
|
+
/**
|
|
68
|
+
* Helper: Safely parse JSON that might contain JavaScript expressions
|
|
69
|
+
* Replaces common JS expressions (e.g., new Date(), Date.now()) with JSON-safe values
|
|
70
|
+
* Returns parsed object/array on success, or null on failure
|
|
71
|
+
*/
|
|
72
|
+
export declare function parseJsonWithExpressions(str: string): any;
|
|
73
|
+
/**
|
|
74
|
+
* Helper: Enhance suggestions with actionType and context
|
|
75
|
+
*/
|
|
76
|
+
export declare function enhanceSuggestions(suggestions: any, context: any): CommandSuggestion[];
|
|
77
|
+
/**
|
|
78
|
+
* Helper: Create fallback suggestions
|
|
79
|
+
*/
|
|
80
|
+
export declare function createFallbackSuggestions(message?: string): {
|
|
81
|
+
action: string;
|
|
82
|
+
actionType: string;
|
|
83
|
+
path: string;
|
|
84
|
+
formState: {};
|
|
85
|
+
message: string;
|
|
86
|
+
}[];
|
|
87
|
+
/**
|
|
88
|
+
* Dynamic route validation based on training data
|
|
89
|
+
*/
|
|
90
|
+
export declare function isValidRoute(path: string, routes: RouteConfig[]): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Unified JSON extraction function for all models
|
|
93
|
+
* Extracts ALL JSON objects from text and maintains their order
|
|
94
|
+
*/
|
|
95
|
+
export declare function extractAllJsonFromText(text: string, provider: string): Array<{
|
|
96
|
+
type: 'array' | 'object';
|
|
97
|
+
content: string;
|
|
98
|
+
startIndex: number;
|
|
99
|
+
endIndex: number;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* Check if JSON is actually complete (not just balanced brackets)
|
|
103
|
+
*/
|
|
104
|
+
export declare function isJsonActuallyComplete(str: string): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Enhanced JSON depth tracking that handles nested structures properly
|
|
107
|
+
*/
|
|
108
|
+
export declare function calculateJsonDepth(str: string): number;
|
|
109
|
+
/**
|
|
110
|
+
* Enhanced suggestion extraction with better error handling
|
|
111
|
+
*/
|
|
112
|
+
export declare function extractSuggestions(jsonStr: string): any;
|
|
113
|
+
/**
|
|
114
|
+
* Extract JSON from streamed text, handling both markdown code blocks and raw JSON
|
|
115
|
+
* Returns the cleaned text and extracted JSON with completion status
|
|
116
|
+
*/
|
|
117
|
+
export declare function extractJsonFromStream(input: string): {
|
|
118
|
+
text: string;
|
|
119
|
+
json: string;
|
|
120
|
+
isJsonComplete: boolean;
|
|
121
|
+
isMarkdownBlock: boolean;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Extract partial JSON from potentially incomplete string
|
|
125
|
+
*/
|
|
126
|
+
export declare function extractPartialJson(str: string): string | null;
|
|
127
|
+
/**
|
|
128
|
+
* Validate JSON structure and attempt to fix common issues
|
|
129
|
+
* Now includes bulletproof JavaScript expression evaluation
|
|
130
|
+
*/
|
|
131
|
+
export declare function validateAndFixJson(str: string): string | null;
|
|
132
|
+
/**
|
|
133
|
+
* Bulletproof JavaScript expression evaluator
|
|
134
|
+
* Safely evaluates common JavaScript expressions in JSON strings
|
|
135
|
+
*/
|
|
136
|
+
export declare function evaluateJavaScriptExpressions(str: string): string;
|
|
137
|
+
export declare function buildSystemPrompt(trainingData: TrainingData | undefined, chatLevel: 'full' | 'basic' | 'none' | undefined, provider?: string): string;
|
|
138
|
+
/**
|
|
139
|
+
* Get chat level specific instructions
|
|
140
|
+
* CRITICAL: These contain the JSON format requirements and must be preserved
|
|
141
|
+
*/
|
|
142
|
+
export declare function getChatLevelInstructions(chatLevel: 'full' | 'basic' | 'none' | undefined): string;
|
|
143
|
+
export declare function prepareMessageWithImages(command: string, images: any[], provider?: string | null): Promise<string | ({
|
|
144
|
+
type: string;
|
|
145
|
+
source: {
|
|
146
|
+
type: string;
|
|
147
|
+
media_type: any;
|
|
148
|
+
data: any;
|
|
149
|
+
};
|
|
150
|
+
image_url?: undefined;
|
|
151
|
+
inlineData?: undefined;
|
|
152
|
+
} | {
|
|
153
|
+
type: string;
|
|
154
|
+
image_url: {
|
|
155
|
+
url: string;
|
|
156
|
+
};
|
|
157
|
+
source?: undefined;
|
|
158
|
+
inlineData?: undefined;
|
|
159
|
+
} | {
|
|
160
|
+
inlineData: {
|
|
161
|
+
mimeType: any;
|
|
162
|
+
data: any;
|
|
163
|
+
};
|
|
164
|
+
type?: undefined;
|
|
165
|
+
source?: undefined;
|
|
166
|
+
image_url?: undefined;
|
|
167
|
+
} | {
|
|
168
|
+
text: string;
|
|
169
|
+
type?: undefined;
|
|
170
|
+
} | {
|
|
171
|
+
type: string;
|
|
172
|
+
text: string;
|
|
173
|
+
})[]>;
|
|
174
|
+
export declare function processImageForAI(image: any, provider?: string | null): Promise<{
|
|
175
|
+
type: string;
|
|
176
|
+
source: {
|
|
177
|
+
type: string;
|
|
178
|
+
media_type: any;
|
|
179
|
+
data: any;
|
|
180
|
+
};
|
|
181
|
+
image_url?: undefined;
|
|
182
|
+
inlineData?: undefined;
|
|
183
|
+
} | {
|
|
184
|
+
type: string;
|
|
185
|
+
image_url: {
|
|
186
|
+
url: string;
|
|
187
|
+
};
|
|
188
|
+
source?: undefined;
|
|
189
|
+
inlineData?: undefined;
|
|
190
|
+
} | {
|
|
191
|
+
inlineData: {
|
|
192
|
+
mimeType: any;
|
|
193
|
+
data: any;
|
|
194
|
+
};
|
|
195
|
+
type?: undefined;
|
|
196
|
+
source?: undefined;
|
|
197
|
+
image_url?: undefined;
|
|
198
|
+
}>;
|
|
199
|
+
export declare function detectImageTypeFromBase64(base64Data: string): "image/jpeg" | "image/png" | "image/gif" | "image/webp" | "image/heic" | "image/heif";
|
|
200
|
+
/**
|
|
201
|
+
* Comprehensive text cleaning utility that removes JSON blocks and related content
|
|
202
|
+
* This consolidates all the scattered cleaning logic into one place
|
|
203
|
+
*/
|
|
204
|
+
export declare function cleanStreamedText(text: string): string;
|
|
205
|
+
/**
|
|
206
|
+
* Detect if text contains the start of a JSON code block
|
|
207
|
+
* Used by frontend to show loading suggestions component
|
|
208
|
+
*/
|
|
209
|
+
export declare function detectJsonBlockStart(text: string): boolean;
|