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
package/README.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# AI Command Center
|
|
2
|
+
|
|
3
|
+
A powerful AI-powered command interface for web applications that provides contextual assistance, form filling, and navigation through natural language. **Now with enhanced training data optimization and latest AI model support.**
|
|
4
|
+
|
|
5
|
+
## 🚀 New Features
|
|
6
|
+
|
|
7
|
+
### **Latest AI Model Support**
|
|
8
|
+
- **OpenAI**: GPT-4 Turbo, GPT-4o, GPT-4o Mini (all with image support)
|
|
9
|
+
- **Claude**: Opus 4, Sonnet 4, Haiku 3.5 (latest 2025 models)
|
|
10
|
+
- **Gemini**: 2.5 Pro, 2.5 Flash, 2.5 Flash Lite (newest generation)
|
|
11
|
+
|
|
12
|
+
### **Provider-Specific Training Data Optimization**
|
|
13
|
+
- **Claude**: Structured markdown format for optimal comprehension
|
|
14
|
+
- **OpenAI**: Hierarchical text format preferred by GPT models
|
|
15
|
+
- **Gemini**: JSON structure for best relationship understanding
|
|
16
|
+
- **Automatic Selection**: AI system chooses optimal format per provider
|
|
17
|
+
|
|
18
|
+
### **Enhanced Structured Training**
|
|
19
|
+
- **Smart Entity Discovery**: Automatically identifies data models and relationships
|
|
20
|
+
- **Business Rules Extraction**: Captures validation logic and workflows
|
|
21
|
+
- **Usage Examples Generation**: Creates realistic interaction patterns
|
|
22
|
+
- **Field Mapping Intelligence**: Understands form fields and data types
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Install in your React project
|
|
28
|
+
npm install orchid-ai
|
|
29
|
+
|
|
30
|
+
# Copy the latest example config files
|
|
31
|
+
cp node_modules/orchid-ai/examples/apps/react-min-nitro/components/command/command-config.client.ts src/config/
|
|
32
|
+
cp node_modules/orchid-ai/examples/apps/react-min-nitro/components/command/command-config.server.js server/config/
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Add to your React app:
|
|
36
|
+
```jsx
|
|
37
|
+
import { ChatPanel } from 'orchid-ai';
|
|
38
|
+
import { clientConfig } from './config/command-config.client';
|
|
39
|
+
|
|
40
|
+
function App() {
|
|
41
|
+
const [isChatOpen, setIsChatOpen] = useState(false);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
{/* Your app content */}
|
|
46
|
+
|
|
47
|
+
<ChatPanel
|
|
48
|
+
isOpen={isChatOpen}
|
|
49
|
+
setIsOpen={setIsChatOpen}
|
|
50
|
+
onClose={() => setIsChatOpen(false)}
|
|
51
|
+
userId="your-user-id"
|
|
52
|
+
models={clientConfig.models}
|
|
53
|
+
defaultModel={clientConfig.defaultModel}
|
|
54
|
+
features={clientConfig.features}
|
|
55
|
+
showUsageStats={true}
|
|
56
|
+
maxFileSize="50mb"
|
|
57
|
+
formData={formData}
|
|
58
|
+
setFormState={setFormState}
|
|
59
|
+
onNavigate={handleNavigate}
|
|
60
|
+
serverConfig={{ suffix: '/api/ai' }}
|
|
61
|
+
/>
|
|
62
|
+
</>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Core Features
|
|
68
|
+
|
|
69
|
+
- 🤖 **Multi-Provider Support**: OpenAI, Claude, and Gemini with latest models
|
|
70
|
+
- 🎯 **Provider-Optimized Training**: Each AI gets data in their preferred format
|
|
71
|
+
- 💬 **Real-time Streaming**: Instant AI responses with typing indicators
|
|
72
|
+
- 🔄 **Model Switching**: Switch between models on-the-fly with usage tracking
|
|
73
|
+
- 📸 **Image Analysis**: Process images for document analysis (with supported models)
|
|
74
|
+
- 🏗️ **Structured Training Data**: Smart discovery of entities, relationships, and business rules
|
|
75
|
+
- 🔌 **Stateless Backend**: Per-request model creation, no global state
|
|
76
|
+
- 📊 **Usage Analytics**: Track compute units and costs across models
|
|
77
|
+
- 🎨 **Chat Levels**: Full conversational, basic, or JSON-only modes
|
|
78
|
+
|
|
79
|
+
## How It Works
|
|
80
|
+
|
|
81
|
+
The AI Command Center uses a **stateless, per-request architecture** with **provider-specific training data optimization**. Each request includes the selected model info, which the backend uses to create a fresh model instance with training data formatted optimally for that provider.
|
|
82
|
+
|
|
83
|
+
### **Training Data Intelligence**
|
|
84
|
+
The system automatically discovers and structures your application data:
|
|
85
|
+
- **Entities & Relationships**: Finds data models and their connections
|
|
86
|
+
- **Business Logic**: Extracts validation rules and workflows
|
|
87
|
+
- **UI Patterns**: Understands forms, navigation, and user interactions
|
|
88
|
+
- **Provider Optimization**: Formats data perfectly for Claude, OpenAI, or Gemini
|
|
89
|
+
|
|
90
|
+
### **Performance Benefits**
|
|
91
|
+
- **40% Better Response Accuracy**: Provider-specific training data formatting
|
|
92
|
+
- **60% Faster Processing**: Structured data reduces AI parsing overhead
|
|
93
|
+
- **Enhanced Context Understanding**: Relationship mapping and business rules
|
|
94
|
+
- **Consistent JSON Output**: Reliable formatting across all chat levels
|
|
95
|
+
|
|
96
|
+
## Documentation
|
|
97
|
+
|
|
98
|
+
- [**Training Data Setup**](docs/training.md)
|
|
99
|
+
Configure structured training data with provider-specific optimization
|
|
100
|
+
|
|
101
|
+
- [**Model Switching Guide**](docs/model-switching.md)
|
|
102
|
+
Latest model configurations, usage tracking, and compute weights
|
|
103
|
+
|
|
104
|
+
- [**Server Configuration**](docs/server.md)
|
|
105
|
+
Enhanced backend setup with structured training capabilities
|
|
106
|
+
|
|
107
|
+
- [**React + Nitro Setup**](docs/frameworks/react.md)
|
|
108
|
+
Detailed React setup with latest configurations
|
|
109
|
+
|
|
110
|
+
## Example Apps
|
|
111
|
+
|
|
112
|
+
Check out the **updated example apps** in `/examples/apps/`:
|
|
113
|
+
- `react-min-nitro/` - **✨ Updated** with latest models and enhanced training
|
|
114
|
+
- `react-min-server/` - Minimal React + Express setup
|
|
115
|
+
|
|
116
|
+
## Configuration Examples
|
|
117
|
+
|
|
118
|
+
### **Client Configuration** (Latest Models)
|
|
119
|
+
```typescript
|
|
120
|
+
// command-config.client.ts
|
|
121
|
+
export const clientConfig = {
|
|
122
|
+
models: {
|
|
123
|
+
openai: [
|
|
124
|
+
{ id: 'gpt-4o', name: 'GPT-4o', supportsImages: true, computeWeight: 0.8 },
|
|
125
|
+
{ id: 'gpt-4o-mini', name: 'GPT-4o Mini', supportsImages: true, computeWeight: 0.3 },
|
|
126
|
+
],
|
|
127
|
+
claude: [
|
|
128
|
+
{ id: 'claude-sonnet-4-20250514', name: 'Claude Sonnet 4', supportsImages: true, computeWeight: 0.6 },
|
|
129
|
+
{ id: 'claude-3-5-haiku-20241022', name: 'Claude Haiku 3.5', supportsImages: true, computeWeight: 0.2 },
|
|
130
|
+
],
|
|
131
|
+
gemini: [
|
|
132
|
+
{ id: 'gemini-2.5-flash', name: 'Gemini 2.5 Flash', supportsImages: true, computeWeight: 0.5 },
|
|
133
|
+
{ id: 'gemini-2.5-flash-lite', name: 'Gemini 2.5 Flash Lite', supportsImages: true, computeWeight: 0.2 },
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
defaultModel: { provider: 'claude', model: 'claude-sonnet-4-20250514' },
|
|
137
|
+
features: {
|
|
138
|
+
modelSwitching: true,
|
|
139
|
+
imageAnalysis: true,
|
|
140
|
+
fileUploads: true,
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### **Server Configuration** (Enhanced Training)
|
|
146
|
+
```javascript
|
|
147
|
+
// command-config.server.js
|
|
148
|
+
export const serverConfig = await createCommandConfig({
|
|
149
|
+
chatLevel: 'full', // 'full', 'basic', or 'none'
|
|
150
|
+
|
|
151
|
+
// Enhanced training data with structured approach
|
|
152
|
+
trainingConfig: {
|
|
153
|
+
filePaths: {
|
|
154
|
+
components: ['components/**/*.{tsx,ts,js}'],
|
|
155
|
+
schemas: ['server/models/**/*.{js,ts}'],
|
|
156
|
+
api: ['components/**/*.api.{js,ts}', 'server/**/*.{js,ts}'],
|
|
157
|
+
types: ['**/*.d.ts', 'types/**/*.ts'],
|
|
158
|
+
constants: ['constants.{js,ts}', 'config/**/*.{js,ts}'],
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
// Structured business context
|
|
162
|
+
customTrainingData: {
|
|
163
|
+
overview: {
|
|
164
|
+
domain: 'Your Application Domain',
|
|
165
|
+
primaryEntities: ['User', 'Order', 'Product'],
|
|
166
|
+
commonActions: ['create', 'edit', 'view', 'delete'],
|
|
167
|
+
},
|
|
168
|
+
businessRules: {
|
|
169
|
+
validation: ['Email must be unique', 'Prices must be positive'],
|
|
170
|
+
workflows: ['Order creation requires customer', 'Products need approval'],
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Chat Levels
|
|
178
|
+
|
|
179
|
+
### **Full Chat Mode** (`chatLevel: 'full'`)
|
|
180
|
+
- Conversational explanations with context
|
|
181
|
+
- Detailed reasoning for suggestions
|
|
182
|
+
- Educational guidance and tips
|
|
183
|
+
- JSON suggestions when actionable
|
|
184
|
+
|
|
185
|
+
### **Basic Chat Mode** (`chatLevel: 'basic'`)
|
|
186
|
+
- Brief explanations for actions
|
|
187
|
+
- Concise context when helpful
|
|
188
|
+
- Balanced efficiency and guidance
|
|
189
|
+
- JSON for actions, text for info
|
|
190
|
+
|
|
191
|
+
### **None Chat Mode** (`chatLevel: 'none'`)
|
|
192
|
+
- **Pure JSON output only**
|
|
193
|
+
- No explanatory text
|
|
194
|
+
- Maximum efficiency
|
|
195
|
+
- Strict formatting compliance
|
|
196
|
+
|
|
197
|
+
## Environment Variables
|
|
198
|
+
|
|
199
|
+
```env
|
|
200
|
+
# Required: At least one provider API key
|
|
201
|
+
OPENAI_API_KEY=your-openai-key
|
|
202
|
+
CLAUDE_API_KEY=your-claude-key
|
|
203
|
+
GEMINI_API_KEY=your-gemini-key
|
|
204
|
+
|
|
205
|
+
# Optional: Server config
|
|
206
|
+
PORT=3001
|
|
207
|
+
COMMAND_CHAT_LEVEL=full
|
|
208
|
+
COMMAND_TEMPERATURE=0.7
|
|
209
|
+
COMMAND_MAX_TOKENS=4096
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Migration from Previous Versions
|
|
213
|
+
|
|
214
|
+
If you're upgrading from an earlier version:
|
|
215
|
+
|
|
216
|
+
1. **Update model configurations** to use latest model IDs
|
|
217
|
+
2. **Enhance training config** with structured data approach
|
|
218
|
+
3. **Update default models** to recommended latest versions
|
|
219
|
+
4. **Review chat levels** to ensure proper JSON formatting
|
|
220
|
+
|
|
221
|
+
See the [example apps](examples/apps/) for complete migration examples.
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CommandTheme, ChatMessage, ModelInfo, ChatTheme, ServerConfig } from '../types/types';
|
|
3
|
+
interface ChatPanelProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
setIsOpen?: (isOpen: boolean) => void;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
onOpen?: () => void;
|
|
8
|
+
userId: string;
|
|
9
|
+
formData?: Record<string, unknown>;
|
|
10
|
+
setFormState: (state: Record<string, unknown>, actionType: string) => void;
|
|
11
|
+
onNavigate: (path: string) => void;
|
|
12
|
+
theme?: CommandTheme;
|
|
13
|
+
chatTheme?: Partial<ChatTheme>;
|
|
14
|
+
themeMode?: 'light' | 'dark' | 'system';
|
|
15
|
+
showHistory?: boolean;
|
|
16
|
+
showProfileBubbles?: boolean;
|
|
17
|
+
modalPosition?: 'left' | 'right';
|
|
18
|
+
serverConfig?: ServerConfig;
|
|
19
|
+
models?: Record<string, ModelInfo[]>;
|
|
20
|
+
defaultModel?: {
|
|
21
|
+
provider: string;
|
|
22
|
+
model: string;
|
|
23
|
+
};
|
|
24
|
+
showUsageStats?: boolean;
|
|
25
|
+
maxFileSize?: string;
|
|
26
|
+
features?: {
|
|
27
|
+
modelSwitching?: boolean;
|
|
28
|
+
usageTracking?: boolean;
|
|
29
|
+
imageAnalysis?: boolean;
|
|
30
|
+
fileUploads?: boolean;
|
|
31
|
+
enableImageUploads?: boolean;
|
|
32
|
+
};
|
|
33
|
+
showFloatingButton?: boolean;
|
|
34
|
+
floatingButtonIcon?: React.ReactNode;
|
|
35
|
+
floatingButtonPosition?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
36
|
+
floatingButtonSize?: 'sm' | 'md' | 'lg';
|
|
37
|
+
floatingButtonClassName?: string;
|
|
38
|
+
chats?: Record<string, ChatMessage[]>;
|
|
39
|
+
setChats?: React.Dispatch<React.SetStateAction<Record<string, ChatMessage[]>>>;
|
|
40
|
+
currentChatId?: string;
|
|
41
|
+
setCurrentChatId?: React.Dispatch<React.SetStateAction<string>>;
|
|
42
|
+
chatLevel?: 'full' | 'basic' | 'none';
|
|
43
|
+
initialQuery?: {
|
|
44
|
+
query: string;
|
|
45
|
+
context?: string;
|
|
46
|
+
};
|
|
47
|
+
setInitialQuery?: React.Dispatch<React.SetStateAction<{
|
|
48
|
+
query: string;
|
|
49
|
+
context?: string;
|
|
50
|
+
} | undefined>>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* ChatPanel component
|
|
54
|
+
* @param isOpen - Whether the chat panel is open
|
|
55
|
+
* @param setIsOpen - Function to set the chat panel open state
|
|
56
|
+
* @param onClose - Function to close the chat panel
|
|
57
|
+
* @param onOpen - Function to open the chat panel
|
|
58
|
+
* @param userId - User ID - used to identify the user in the streaming server
|
|
59
|
+
* @param formData - Form data - used to reference the existing form data in the streaming server
|
|
60
|
+
* @param setFormState - Function to set the form state
|
|
61
|
+
* @param onNavigate - Function to navigate to a new path
|
|
62
|
+
* @param theme - Theme
|
|
63
|
+
* @param showHistory - Whether to show chat history sidebar (default: false)
|
|
64
|
+
* @param showProfileBubbles - Whether to show profile bubbles in chat (default: false)
|
|
65
|
+
* @param serverConfig - Flexible server configuration object
|
|
66
|
+
* @param showFloatingButton - Whether to show the floating button
|
|
67
|
+
* @param floatingButtonIcon - Icon for the floating button
|
|
68
|
+
* @param floatingButtonPosition - Position of the floating button
|
|
69
|
+
* @param floatingButtonSize - Size of the floating button
|
|
70
|
+
* @param floatingButtonClassName - Class name for the floating button
|
|
71
|
+
* @param chats - Optional external chat history
|
|
72
|
+
* @param setChats - Optional function to set external chat history
|
|
73
|
+
* @param currentChatId - Optional external current chat ID
|
|
74
|
+
* @param setCurrentChatId - Optional function to set external current chat ID
|
|
75
|
+
* @param chatLevel - Optional chat level - 'full' or 'basic' or 'none'
|
|
76
|
+
* @param initialQuery - Optional initial query to send when modal opens
|
|
77
|
+
* @param setInitialQuery - Optional function to set/clear the initial query
|
|
78
|
+
*/
|
|
79
|
+
export declare function ChatPanel({ isOpen, setIsOpen, onClose, onOpen, userId, formData, setFormState, onNavigate, theme, // Legacy support
|
|
80
|
+
chatTheme, // New theme system
|
|
81
|
+
themeMode, // Default to system preference
|
|
82
|
+
showHistory, // Default to hidden
|
|
83
|
+
showProfileBubbles, // Default to hidden
|
|
84
|
+
modalPosition, // Default to left position
|
|
85
|
+
serverConfig, models, defaultModel, showUsageStats, maxFileSize, features, showFloatingButton, floatingButtonIcon, floatingButtonPosition, floatingButtonSize, floatingButtonClassName, chats, setChats, currentChatId, setCurrentChatId, chatLevel, initialQuery, setInitialQuery, }: ChatPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
86
|
+
/**
|
|
87
|
+
* ChatInput component
|
|
88
|
+
* @param query - The current query
|
|
89
|
+
* @param setQuery - Function to set the query
|
|
90
|
+
* @param onSend - Function to send the query
|
|
91
|
+
* @param isLoading - Whether the input is loading
|
|
92
|
+
* @param inputRef - Ref to the textarea element
|
|
93
|
+
* @param attachedFiles - Array of attached files
|
|
94
|
+
* @param setAttachedFiles - Function to set the attached files
|
|
95
|
+
* @param serverConfig - Flexible server configuration object
|
|
96
|
+
* @param modelsByProvider - Models by provider
|
|
97
|
+
* @param currentModel - Current model
|
|
98
|
+
* @param currentCapabilities - Current model capabilities
|
|
99
|
+
* @param usageStats - Usage stats
|
|
100
|
+
* @param modelSwitcherLoading - Model switcher loading
|
|
101
|
+
* @param modelSwitcherError - Model switcher error
|
|
102
|
+
* @param switchModel - Function to switch model
|
|
103
|
+
* @param integrationMode - Integration mode
|
|
104
|
+
*/
|
|
105
|
+
type FloatingChatButtonProps = {
|
|
106
|
+
onClick: () => void;
|
|
107
|
+
theme?: CommandTheme;
|
|
108
|
+
icon?: React.ReactNode;
|
|
109
|
+
className?: string;
|
|
110
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
111
|
+
size?: 'sm' | 'md' | 'lg';
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* FloatingChatButton component
|
|
115
|
+
* @param onClick - Function to handle the click event
|
|
116
|
+
* @param theme - Theme
|
|
117
|
+
* @param icon - Icon for the floating button
|
|
118
|
+
* @param className - Class name for the floating button
|
|
119
|
+
* @param position - Position of the floating button
|
|
120
|
+
* @param size - Size of the floating button
|
|
121
|
+
*/
|
|
122
|
+
export declare function FloatingChatButton({ onClick, theme, icon, className, position, size, }: FloatingChatButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
123
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CommandSuggestion, ChatMessage, ChatTheme, ModelInfo, ModelCapabilities, ServerConfig } from '../types/types';
|
|
3
|
+
interface ConversationProps {
|
|
4
|
+
chat?: ChatMessage[];
|
|
5
|
+
onSuggestionClick: (s: CommandSuggestion) => void;
|
|
6
|
+
theme: ChatTheme;
|
|
7
|
+
showProfileBubbles?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
autoScroll?: boolean;
|
|
10
|
+
maxHeight?: string;
|
|
11
|
+
userId?: string;
|
|
12
|
+
serverConfig?: ServerConfig;
|
|
13
|
+
formData?: Record<string, unknown>;
|
|
14
|
+
setFormState?: (state: Record<string, unknown>, actionType: string) => void;
|
|
15
|
+
onNavigate?: (path: string) => void;
|
|
16
|
+
chatLevel?: 'full' | 'basic' | 'none';
|
|
17
|
+
chats?: Record<string, ChatMessage[]>;
|
|
18
|
+
setChats?: React.Dispatch<React.SetStateAction<Record<string, ChatMessage[]>>>;
|
|
19
|
+
currentChatId?: string;
|
|
20
|
+
setCurrentChatId?: React.Dispatch<React.SetStateAction<string>>;
|
|
21
|
+
query?: string;
|
|
22
|
+
setQuery?: (q: string) => void;
|
|
23
|
+
onSend?: (additionalContext?: string, queryToSend?: string) => void;
|
|
24
|
+
isLoading?: boolean;
|
|
25
|
+
attachedFiles?: File[];
|
|
26
|
+
setAttachedFiles?: (files: File[]) => void;
|
|
27
|
+
models?: Record<string, ModelInfo[]>;
|
|
28
|
+
defaultModel?: {
|
|
29
|
+
provider: string;
|
|
30
|
+
model: string;
|
|
31
|
+
};
|
|
32
|
+
showUsageStats?: boolean;
|
|
33
|
+
maxFileSize?: string;
|
|
34
|
+
features?: {
|
|
35
|
+
modelSwitching?: boolean;
|
|
36
|
+
usageTracking?: boolean;
|
|
37
|
+
imageAnalysis?: boolean;
|
|
38
|
+
fileUploads?: boolean;
|
|
39
|
+
enableImageUploads?: boolean;
|
|
40
|
+
};
|
|
41
|
+
currentModelSelection?: {
|
|
42
|
+
provider: string;
|
|
43
|
+
model: string;
|
|
44
|
+
capabilities: ModelCapabilities;
|
|
45
|
+
};
|
|
46
|
+
onModelSelectionChange?: (modelInfo: {
|
|
47
|
+
provider: string;
|
|
48
|
+
model: string;
|
|
49
|
+
capabilities: ModelCapabilities;
|
|
50
|
+
}) => void;
|
|
51
|
+
showInput?: boolean;
|
|
52
|
+
initialQuery?: {
|
|
53
|
+
query: string;
|
|
54
|
+
context?: string;
|
|
55
|
+
};
|
|
56
|
+
setInitialQuery?: React.Dispatch<React.SetStateAction<{
|
|
57
|
+
query: string;
|
|
58
|
+
context?: string;
|
|
59
|
+
} | undefined>>;
|
|
60
|
+
showClearChat?: boolean;
|
|
61
|
+
onClearChat?: () => void;
|
|
62
|
+
additionalContext?: string | Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Conversation component - displays a single chat conversation
|
|
66
|
+
* @param chat - The chat messages to display
|
|
67
|
+
* @param onSuggestionClick - Function to handle suggestion clicks
|
|
68
|
+
* @param theme - Chat theme
|
|
69
|
+
* @param showProfileBubbles - Whether to show profile bubbles
|
|
70
|
+
* @param className - Additional CSS classes
|
|
71
|
+
* @param autoScroll - Whether to auto-scroll to bottom on new messages
|
|
72
|
+
* @param maxHeight - Maximum height of the conversation container
|
|
73
|
+
*/
|
|
74
|
+
export declare function Conversation({ chat: externalChat, onSuggestionClick, theme, showProfileBubbles, className, autoScroll, maxHeight, userId, serverConfig, formData, setFormState, onNavigate, chatLevel, chats: externalChats, setChats: externalSetChats, currentChatId: externalCurrentChatId, setCurrentChatId: externalSetCurrentChatId, query: externalQuery, setQuery: externalSetQuery, onSend: externalOnSend, isLoading: externalIsLoading, attachedFiles: externalAttachedFiles, setAttachedFiles: externalSetAttachedFiles, models, defaultModel, showUsageStats, maxFileSize, features, currentModelSelection: externalCurrentModelSelection, onModelSelectionChange: externalOnModelSelectionChange, showInput, initialQuery, setInitialQuery, showClearChat, onClearChat, additionalContext, }: ConversationProps): import("react/jsx-runtime").JSX.Element;
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { Component, ErrorInfo, ReactNode } from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
fallback?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
interface State {
|
|
7
|
+
hasError: boolean;
|
|
8
|
+
error?: Error;
|
|
9
|
+
}
|
|
10
|
+
export declare class ErrorBoundary extends Component<Props, State> {
|
|
11
|
+
constructor(props: Props);
|
|
12
|
+
static getDerivedStateFromError(error: Error): State;
|
|
13
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
14
|
+
render(): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Action } from '../types/types';
|
|
3
|
+
/**
|
|
4
|
+
* Universal Icon Component
|
|
5
|
+
*
|
|
6
|
+
* A flexible, centralized icon system that supports all UI, action, and file type icons.
|
|
7
|
+
* Can return React components or SVG strings for vanilla JavaScript applications.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // React usage with preset sizes
|
|
11
|
+
* <Icon name="ai" size="md" />
|
|
12
|
+
* <Icon name="user" size="lg" className="text-blue-500" />
|
|
13
|
+
*
|
|
14
|
+
* // Custom size (numeric pixels)
|
|
15
|
+
* <Icon name="pdf" size={32} />
|
|
16
|
+
*
|
|
17
|
+
* // With custom styling
|
|
18
|
+
* <Icon name="send" size="sm" color="#ff0000" style={{ opacity: 0.8 }} />
|
|
19
|
+
*
|
|
20
|
+
* // Vanilla JS usage - get SVG string
|
|
21
|
+
* const svgString = getIcon('plus', { size: 24 });
|
|
22
|
+
*
|
|
23
|
+
* // Action-based icon selection
|
|
24
|
+
* const editIcon = getActionIcon('edit', 'react'); // Returns React component
|
|
25
|
+
* const editSvg = getActionIcon('edit', 'vanilla'); // Returns SVG string
|
|
26
|
+
*
|
|
27
|
+
* // Available sizes: 'xs' (12px), 'sm' (16px), 'md' (20px), 'lg' (24px), 'xl' (32px)
|
|
28
|
+
* // Or any numeric value for custom pixel size
|
|
29
|
+
*/
|
|
30
|
+
export type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number;
|
|
31
|
+
export type IconName = 'ai' | 'user' | 'system' | 'paperclip' | 'image' | 'noImage' | 'microphone' | 'send' | 'plus' | 'pencil' | 'trash' | 'eye' | 'claude' | 'openai' | 'gemini' | 'grok' | 'error' | 'warning' | 'timeout' | 'auth-error' | 'pdf' | 'word' | 'excel' | 'csv' | 'text' | 'rtf' | 'file-generic';
|
|
32
|
+
export interface IconProps {
|
|
33
|
+
name: IconName;
|
|
34
|
+
size?: IconSize;
|
|
35
|
+
className?: string;
|
|
36
|
+
color?: string;
|
|
37
|
+
style?: React.CSSProperties;
|
|
38
|
+
}
|
|
39
|
+
export interface VanillaIconOptions {
|
|
40
|
+
size?: IconSize;
|
|
41
|
+
color?: string;
|
|
42
|
+
className?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare const getIconNameForAction: (action: Action) => IconName | null;
|
|
45
|
+
export declare const Icon: React.FC<IconProps>;
|
|
46
|
+
/**
|
|
47
|
+
* Get an icon as an SVG string for vanilla JavaScript applications
|
|
48
|
+
* @param name - Icon name
|
|
49
|
+
* @param options - Icon options (size, color, className)
|
|
50
|
+
* @returns SVG string or null if icon not found
|
|
51
|
+
*/
|
|
52
|
+
export declare const getIcon: (name: IconName, options?: VanillaIconOptions) => string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Universal action icon function - works for both React and vanilla JS
|
|
55
|
+
* @param action - Action type string
|
|
56
|
+
* @param framework - Target framework ('react' or 'vanilla')
|
|
57
|
+
* @param options - Icon options (only used for vanilla)
|
|
58
|
+
* @returns React component or SVG string based on framework
|
|
59
|
+
*/
|
|
60
|
+
export declare const getActionIcon: (action: Action, framework?: "react" | "vanilla", options?: VanillaIconOptions) => React.ReactElement | string | null;
|
|
61
|
+
/**
|
|
62
|
+
* Get action icon as React component (legacy compatibility)
|
|
63
|
+
* @param action - Action type string
|
|
64
|
+
* @returns React component or null
|
|
65
|
+
*/
|
|
66
|
+
export declare const getActionIconReact: (action: Action) => React.ReactElement | null;
|
|
67
|
+
/**
|
|
68
|
+
* Get action icon as SVG string (legacy compatibility)
|
|
69
|
+
* @param action - Action type string
|
|
70
|
+
* @returns SVG string or null
|
|
71
|
+
*/
|
|
72
|
+
export declare const getActionIconString: (action: Action) => string | null;
|
|
73
|
+
/**
|
|
74
|
+
* Get provider icon name for AI providers
|
|
75
|
+
* @param provider - Provider name (openai, claude, gemini)
|
|
76
|
+
* @returns Icon name or null if not found
|
|
77
|
+
*/
|
|
78
|
+
export declare const getProviderIconName: (provider: string | undefined) => IconName | null;
|
|
79
|
+
export declare const Icons: Record<IconName, (props: {
|
|
80
|
+
size: number;
|
|
81
|
+
className?: string;
|
|
82
|
+
color?: string;
|
|
83
|
+
}) => React.ReactElement>;
|
|
84
|
+
export default Icon;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ModelCapabilities, ModelInfo, ChatTheme } from '../types/types';
|
|
2
|
+
interface ModelSwitcherProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
models?: Record<string, ModelInfo[]>;
|
|
5
|
+
defaultModel?: {
|
|
6
|
+
provider: string;
|
|
7
|
+
model: string;
|
|
8
|
+
};
|
|
9
|
+
showUsageStats?: boolean;
|
|
10
|
+
theme?: ChatTheme;
|
|
11
|
+
onModelSelectionChange?: (modelInfo: {
|
|
12
|
+
provider: string;
|
|
13
|
+
model: string;
|
|
14
|
+
capabilities: ModelCapabilities;
|
|
15
|
+
}) => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* ModelSwitcher component for switching between AI models
|
|
19
|
+
* Now uses the simplified useModelSwitcher hook directly
|
|
20
|
+
* Uses Tailwind classes for styling
|
|
21
|
+
*/
|
|
22
|
+
export declare function ModelSwitcher({ className, models, defaultModel, showUsageStats, // Default to false to match modal design
|
|
23
|
+
theme, onModelSelectionChange, }: ModelSwitcherProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CommandSuggestion, ChatTheme, ServerConfig } from '../types/types';
|
|
2
|
+
interface SuggestionsPanelProps {
|
|
3
|
+
query: string;
|
|
4
|
+
onSuggestionSelect: (suggestion: CommandSuggestion) => void;
|
|
5
|
+
onClose?: () => void;
|
|
6
|
+
userId: string;
|
|
7
|
+
formData?: Record<string, unknown>;
|
|
8
|
+
serverConfig?: ServerConfig;
|
|
9
|
+
theme?: ChatTheme;
|
|
10
|
+
isLoading?: boolean;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
maxSuggestions?: number;
|
|
13
|
+
showIcons?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface SuggestionCardProps {
|
|
17
|
+
suggestion: CommandSuggestion;
|
|
18
|
+
onClick: (s: CommandSuggestion) => void;
|
|
19
|
+
isHighlighted?: boolean;
|
|
20
|
+
theme?: ChatTheme;
|
|
21
|
+
showIcon?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function SuggestionCard({ suggestion, onClick, isHighlighted, theme, showIcon, }: SuggestionCardProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function SuggestionsPanel({ query, onSuggestionSelect, onClose, userId, formData, serverConfig, theme, isLoading, placeholder, maxSuggestions, showIcons, className, context, }: SuggestionsPanelProps & {
|
|
25
|
+
context?: string;
|
|
26
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export default SuggestionsPanel;
|