@geenius/ai 0.1.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/.changeset/config.json +11 -0
- package/.env.example +2 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +16 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +11 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +10 -0
- package/.github/dependabot.yml +11 -0
- package/.github/workflows/ci.yml +23 -0
- package/.github/workflows/release.yml +29 -0
- package/.node-version +1 -0
- package/.nvmrc +1 -0
- package/.prettierrc +7 -0
- package/.project/ACCOUNT.yaml +4 -0
- package/.project/IDEAS.yaml +7 -0
- package/.project/PROJECT.yaml +11 -0
- package/.project/ROADMAP.yaml +15 -0
- package/CHANGELOG.md +15 -0
- package/CODE_OF_CONDUCT.md +26 -0
- package/CONTRIBUTING.md +61 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/SECURITY.md +18 -0
- package/SUPPORT.md +14 -0
- package/package.json +75 -0
- package/packages/convex/package.json +42 -0
- package/packages/convex/src/index.ts +8 -0
- package/packages/convex/src/mutations/messages.ts +29 -0
- package/packages/convex/src/queries/messages.ts +24 -0
- package/packages/convex/src/schema.ts +20 -0
- package/packages/convex/tsconfig.json +11 -0
- package/packages/convex/tsup.config.ts +17 -0
- package/packages/react/README.md +1 -0
- package/packages/react/package.json +60 -0
- package/packages/react/src/components/AILogTable.tsx +90 -0
- package/packages/react/src/components/ChatWindow.tsx +118 -0
- package/packages/react/src/components/GenerationCard.tsx +73 -0
- package/packages/react/src/components/ImageGenerator.tsx +103 -0
- package/packages/react/src/components/ModelSelector.tsx +44 -0
- package/packages/react/src/components/ModelTestRunner.tsx +148 -0
- package/packages/react/src/components/VoiceSelector.tsx +51 -0
- package/packages/react/src/components/index.ts +9 -0
- package/packages/react/src/hooks/index.ts +12 -0
- package/packages/react/src/hooks/useAI.ts +158 -0
- package/packages/react/src/hooks/useAILogs.ts +40 -0
- package/packages/react/src/hooks/useAIModels.ts +53 -0
- package/packages/react/src/hooks/useChat.ts +141 -0
- package/packages/react/src/hooks/useContentManager.ts +108 -0
- package/packages/react/src/hooks/useImageGeneration.ts +82 -0
- package/packages/react/src/hooks/useMemory.ts +161 -0
- package/packages/react/src/hooks/useModelTest.ts +126 -0
- package/packages/react/src/hooks/useRealtimeAudio.ts +203 -0
- package/packages/react/src/hooks/useSkills.ts +114 -0
- package/packages/react/src/hooks/useTextToSpeech.ts +99 -0
- package/packages/react/src/hooks/useTranscription.ts +119 -0
- package/packages/react/src/hooks/useVideoGeneration.ts +79 -0
- package/packages/react/src/index.ts +42 -0
- package/packages/react/src/pages/AILogsPage.tsx +98 -0
- package/packages/react/src/pages/ChatPage.tsx +42 -0
- package/packages/react/src/pages/ModelTestPage.tsx +33 -0
- package/packages/react/src/pages/index.ts +5 -0
- package/packages/react/tsconfig.json +26 -0
- package/packages/react/tsup.config.ts +22 -0
- package/packages/react-css/README.md +1 -0
- package/packages/react-css/package.json +45 -0
- package/packages/react-css/src/ai.css +857 -0
- package/packages/react-css/src/components/AILogTable.tsx +90 -0
- package/packages/react-css/src/components/ChatWindow.tsx +118 -0
- package/packages/react-css/src/components/GenerationCard.tsx +73 -0
- package/packages/react-css/src/components/ImageGenerator.tsx +103 -0
- package/packages/react-css/src/components/ModelSelector.tsx +44 -0
- package/packages/react-css/src/components/ModelTestRunner.tsx +148 -0
- package/packages/react-css/src/components/VoiceSelector.tsx +51 -0
- package/packages/react-css/src/components/index.ts +9 -0
- package/packages/react-css/src/hooks/index.ts +12 -0
- package/packages/react-css/src/hooks/useAI.ts +153 -0
- package/packages/react-css/src/hooks/useAILogs.ts +40 -0
- package/packages/react-css/src/hooks/useAIModels.ts +51 -0
- package/packages/react-css/src/hooks/useChat.ts +145 -0
- package/packages/react-css/src/hooks/useContentManager.ts +108 -0
- package/packages/react-css/src/hooks/useImageGeneration.ts +82 -0
- package/packages/react-css/src/hooks/useMemory.ts +161 -0
- package/packages/react-css/src/hooks/useModelTest.ts +122 -0
- package/packages/react-css/src/hooks/useRealtimeAudio.ts +203 -0
- package/packages/react-css/src/hooks/useSkills.ts +114 -0
- package/packages/react-css/src/hooks/useTextToSpeech.ts +99 -0
- package/packages/react-css/src/hooks/useTranscription.ts +119 -0
- package/packages/react-css/src/hooks/useVideoGeneration.ts +79 -0
- package/packages/react-css/src/index.ts +35 -0
- package/packages/react-css/src/pages/AILogsPage.tsx +98 -0
- package/packages/react-css/src/pages/ChatPage.tsx +42 -0
- package/packages/react-css/src/pages/ModelTestPage.tsx +33 -0
- package/packages/react-css/src/pages/index.ts +5 -0
- package/packages/react-css/src/styles.css +127 -0
- package/packages/react-css/tsconfig.json +26 -0
- package/packages/react-css/tsup.config.ts +2 -0
- package/packages/shared/README.md +1 -0
- package/packages/shared/package.json +71 -0
- package/packages/shared/src/__tests__/ai.test.ts +67 -0
- package/packages/shared/src/ai-client.ts +243 -0
- package/packages/shared/src/config.ts +235 -0
- package/packages/shared/src/content.ts +249 -0
- package/packages/shared/src/convex/helpers.ts +163 -0
- package/packages/shared/src/convex/index.ts +16 -0
- package/packages/shared/src/convex/schemas.ts +146 -0
- package/packages/shared/src/convex/validators.ts +136 -0
- package/packages/shared/src/index.ts +107 -0
- package/packages/shared/src/memory.ts +197 -0
- package/packages/shared/src/providers/base.ts +103 -0
- package/packages/shared/src/providers/elevenlabs.ts +155 -0
- package/packages/shared/src/providers/index.ts +28 -0
- package/packages/shared/src/providers/openai-compatible.ts +286 -0
- package/packages/shared/src/providers/registry.ts +113 -0
- package/packages/shared/src/providers/replicate-fal.ts +230 -0
- package/packages/shared/src/skills.ts +273 -0
- package/packages/shared/src/types.ts +501 -0
- package/packages/shared/tsconfig.json +25 -0
- package/packages/shared/tsup.config.ts +22 -0
- package/packages/shared/vitest.config.ts +4 -0
- package/packages/solidjs/README.md +1 -0
- package/packages/solidjs/package.json +59 -0
- package/packages/solidjs/src/components/ChatWindow.tsx +78 -0
- package/packages/solidjs/src/components/GenerationCard.tsx +62 -0
- package/packages/solidjs/src/components/ModelTestRunner.tsx +119 -0
- package/packages/solidjs/src/components/index.ts +5 -0
- package/packages/solidjs/src/index.ts +32 -0
- package/packages/solidjs/src/pages/ChatPage.tsx +22 -0
- package/packages/solidjs/src/pages/ModelTestPage.tsx +22 -0
- package/packages/solidjs/src/pages/index.ts +4 -0
- package/packages/solidjs/src/primitives/createAI.ts +79 -0
- package/packages/solidjs/src/primitives/createChat.ts +100 -0
- package/packages/solidjs/src/primitives/createContentManager.ts +61 -0
- package/packages/solidjs/src/primitives/createImageGeneration.ts +46 -0
- package/packages/solidjs/src/primitives/createMemory.ts +127 -0
- package/packages/solidjs/src/primitives/createModelTest.ts +89 -0
- package/packages/solidjs/src/primitives/createSkills.ts +83 -0
- package/packages/solidjs/src/primitives/createTextToSpeech.ts +56 -0
- package/packages/solidjs/src/primitives/createVideoGeneration.ts +46 -0
- package/packages/solidjs/src/primitives/index.ts +8 -0
- package/packages/solidjs/tsconfig.json +27 -0
- package/packages/solidjs/tsup.config.ts +21 -0
- package/packages/solidjs-css/README.md +1 -0
- package/packages/solidjs-css/package.json +44 -0
- package/packages/solidjs-css/src/ai.css +857 -0
- package/packages/solidjs-css/src/components/ChatWindow.tsx +78 -0
- package/packages/solidjs-css/src/components/GenerationCard.tsx +62 -0
- package/packages/solidjs-css/src/components/ModelTestRunner.tsx +119 -0
- package/packages/solidjs-css/src/components/index.ts +5 -0
- package/packages/solidjs-css/src/index.ts +26 -0
- package/packages/solidjs-css/src/pages/ChatPage.tsx +22 -0
- package/packages/solidjs-css/src/pages/ModelTestPage.tsx +22 -0
- package/packages/solidjs-css/src/pages/index.ts +4 -0
- package/packages/solidjs-css/src/primitives/createAI.ts +79 -0
- package/packages/solidjs-css/src/primitives/createChat.ts +100 -0
- package/packages/solidjs-css/src/primitives/createContentManager.ts +61 -0
- package/packages/solidjs-css/src/primitives/createImageGeneration.ts +46 -0
- package/packages/solidjs-css/src/primitives/createMemory.ts +127 -0
- package/packages/solidjs-css/src/primitives/createModelTest.ts +89 -0
- package/packages/solidjs-css/src/primitives/createSkills.ts +83 -0
- package/packages/solidjs-css/src/primitives/createTextToSpeech.ts +56 -0
- package/packages/solidjs-css/src/primitives/createVideoGeneration.ts +46 -0
- package/packages/solidjs-css/src/primitives/index.ts +1 -0
- package/packages/solidjs-css/src/styles.css +127 -0
- package/packages/solidjs-css/tsconfig.json +27 -0
- package/packages/solidjs-css/tsup.config.ts +2 -0
- package/pnpm-workspace.yaml +2 -0
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
// @geenius-ai/shared — src/types.ts
|
|
2
|
+
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// Provider & Model Types
|
|
5
|
+
// ============================================================================
|
|
6
|
+
|
|
7
|
+
export type AIProviderType =
|
|
8
|
+
| 'openai'
|
|
9
|
+
| 'anthropic'
|
|
10
|
+
| 'google'
|
|
11
|
+
| 'nvidia'
|
|
12
|
+
| 'ollama'
|
|
13
|
+
| 'groq'
|
|
14
|
+
| 'together'
|
|
15
|
+
| 'elevenlabs'
|
|
16
|
+
| 'stability'
|
|
17
|
+
| 'replicate'
|
|
18
|
+
| 'fal'
|
|
19
|
+
| 'custom'
|
|
20
|
+
|
|
21
|
+
export type AIGenerationType =
|
|
22
|
+
| 'text'
|
|
23
|
+
| 'image'
|
|
24
|
+
| 'audio'
|
|
25
|
+
| 'video'
|
|
26
|
+
| 'speech'
|
|
27
|
+
| 'transcription'
|
|
28
|
+
| 'embedding'
|
|
29
|
+
| 'vision'
|
|
30
|
+
| 'structured-output'
|
|
31
|
+
| 'image-edit'
|
|
32
|
+
| 'voice-clone'
|
|
33
|
+
| 'music'
|
|
34
|
+
| 'sound-effect'
|
|
35
|
+
|
|
36
|
+
export type AIModelCapability =
|
|
37
|
+
| 'text'
|
|
38
|
+
| 'vision'
|
|
39
|
+
| 'image-generation'
|
|
40
|
+
| 'image-editing'
|
|
41
|
+
| 'audio-generation'
|
|
42
|
+
| 'speech-to-text'
|
|
43
|
+
| 'text-to-speech'
|
|
44
|
+
| 'video-generation'
|
|
45
|
+
| 'embedding'
|
|
46
|
+
| 'function-calling'
|
|
47
|
+
| 'streaming'
|
|
48
|
+
| 'structured-output'
|
|
49
|
+
| 'realtime-audio'
|
|
50
|
+
| 'voice-cloning'
|
|
51
|
+
| 'music-generation'
|
|
52
|
+
| 'sound-effects'
|
|
53
|
+
|
|
54
|
+
export interface AIModel {
|
|
55
|
+
id: string
|
|
56
|
+
provider: AIProviderType
|
|
57
|
+
name: string
|
|
58
|
+
displayName?: string
|
|
59
|
+
capabilities: AIModelCapability[]
|
|
60
|
+
inputCostPer1k: number
|
|
61
|
+
outputCostPer1k: number
|
|
62
|
+
/** Fixed cost per call (e.g., image generation) */
|
|
63
|
+
costPerCall?: number
|
|
64
|
+
maxTokens?: number
|
|
65
|
+
contextWindow?: number
|
|
66
|
+
isActive: boolean
|
|
67
|
+
/** Metadata for specialized models */
|
|
68
|
+
meta?: Record<string, unknown>
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface AIProviderConfig {
|
|
72
|
+
name: string
|
|
73
|
+
type: AIProviderType
|
|
74
|
+
baseUrl: string
|
|
75
|
+
apiKeyEnvVar: string
|
|
76
|
+
isActive: boolean
|
|
77
|
+
models: string[]
|
|
78
|
+
defaultModel?: string
|
|
79
|
+
headers?: Record<string, string>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// Message & Conversation Types
|
|
84
|
+
// ============================================================================
|
|
85
|
+
|
|
86
|
+
export type AIMessageRole = 'system' | 'user' | 'assistant' | 'tool'
|
|
87
|
+
|
|
88
|
+
export interface AIMessageContentPart {
|
|
89
|
+
type: 'text' | 'image_url' | 'audio' | 'video'
|
|
90
|
+
text?: string
|
|
91
|
+
image_url?: { url: string; detail?: 'low' | 'high' | 'auto' }
|
|
92
|
+
audio?: { data: string; format: 'mp3' | 'wav' | 'opus' }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface AIMessage {
|
|
96
|
+
role: AIMessageRole
|
|
97
|
+
content: string | AIMessageContentPart[]
|
|
98
|
+
tool_calls?: AIToolCall[]
|
|
99
|
+
tool_call_id?: string
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface AIToolCall {
|
|
103
|
+
id: string
|
|
104
|
+
type: 'function'
|
|
105
|
+
function: { name: string; arguments: string }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface AIToolDefinition {
|
|
109
|
+
type: 'function'
|
|
110
|
+
function: {
|
|
111
|
+
name: string
|
|
112
|
+
description: string
|
|
113
|
+
parameters: Record<string, unknown>
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type AIConversationStatus = 'active' | 'archived'
|
|
118
|
+
|
|
119
|
+
export interface AIConversation {
|
|
120
|
+
id: string
|
|
121
|
+
userId: string
|
|
122
|
+
title: string
|
|
123
|
+
model: string
|
|
124
|
+
systemPrompt?: string
|
|
125
|
+
status: AIConversationStatus
|
|
126
|
+
favorite: boolean
|
|
127
|
+
tags: string[]
|
|
128
|
+
folderId?: string
|
|
129
|
+
messageCount: number
|
|
130
|
+
createdAt: number
|
|
131
|
+
updatedAt: number
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface AIChatMessage {
|
|
135
|
+
id: string
|
|
136
|
+
conversationId: string
|
|
137
|
+
userId: string
|
|
138
|
+
role: AIMessageRole
|
|
139
|
+
content: string
|
|
140
|
+
model?: string
|
|
141
|
+
tokens?: number
|
|
142
|
+
durationMs?: number
|
|
143
|
+
attachments?: AIAttachment[]
|
|
144
|
+
createdAt: number
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface AIAttachment {
|
|
148
|
+
type: 'image' | 'audio' | 'video' | 'file'
|
|
149
|
+
url: string
|
|
150
|
+
name?: string
|
|
151
|
+
mimeType?: string
|
|
152
|
+
sizeBytes?: number
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// ============================================================================
|
|
156
|
+
// Generation Options & Results
|
|
157
|
+
// ============================================================================
|
|
158
|
+
|
|
159
|
+
export interface AIGenerateTextOptions {
|
|
160
|
+
model: string
|
|
161
|
+
messages: AIMessage[]
|
|
162
|
+
temperature?: number
|
|
163
|
+
maxTokens?: number
|
|
164
|
+
topP?: number
|
|
165
|
+
caller?: string
|
|
166
|
+
responseFormat?: any
|
|
167
|
+
stream?: boolean
|
|
168
|
+
tools?: AIToolDefinition[]
|
|
169
|
+
toolChoice?: 'auto' | 'none' | { type: 'function'; function: { name: string } }
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface AIStructuredOutputOptions {
|
|
173
|
+
model: string
|
|
174
|
+
messages: AIMessage[]
|
|
175
|
+
schema: Record<string, unknown>
|
|
176
|
+
schemaName?: string
|
|
177
|
+
temperature?: number
|
|
178
|
+
maxTokens?: number
|
|
179
|
+
caller?: string
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface AIGenerateImageOptions {
|
|
183
|
+
model?: string
|
|
184
|
+
prompt: string
|
|
185
|
+
negativePrompt?: string
|
|
186
|
+
n?: number
|
|
187
|
+
size?: string
|
|
188
|
+
quality?: 'standard' | 'hd'
|
|
189
|
+
style?: 'natural' | 'vivid'
|
|
190
|
+
responseFormat?: 'b64_json' | 'url'
|
|
191
|
+
/** Seed for reproducible generations */
|
|
192
|
+
seed?: number
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface AIEditImageOptions {
|
|
196
|
+
model?: string
|
|
197
|
+
image: string // base64
|
|
198
|
+
maskImage?: string // base64
|
|
199
|
+
prompt: string
|
|
200
|
+
n?: number
|
|
201
|
+
size?: string
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface AIGenerateAudioOptions {
|
|
205
|
+
model?: string
|
|
206
|
+
prompt: string
|
|
207
|
+
voice?: string
|
|
208
|
+
speed?: number
|
|
209
|
+
responseFormat?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm'
|
|
210
|
+
/** ElevenLabs voice settings */
|
|
211
|
+
voiceSettings?: {
|
|
212
|
+
stability?: number
|
|
213
|
+
similarityBoost?: number
|
|
214
|
+
style?: number
|
|
215
|
+
useSpeakerBoost?: boolean
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface AITranscribeOptions {
|
|
220
|
+
model?: string
|
|
221
|
+
audio: string // base64
|
|
222
|
+
language?: string
|
|
223
|
+
prompt?: string
|
|
224
|
+
/** Return word-level timestamps */
|
|
225
|
+
timestampGranularities?: ('word' | 'segment')[]
|
|
226
|
+
responseFormat?: 'json' | 'text' | 'srt' | 'vtt' | 'verbose_json'
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface AIGenerateVideoOptions {
|
|
230
|
+
model?: string
|
|
231
|
+
prompt: string
|
|
232
|
+
duration?: number
|
|
233
|
+
aspectRatio?: '16:9' | '9:16' | '1:1'
|
|
234
|
+
resolution?: '720p' | '1080p' | '4k'
|
|
235
|
+
/** Start image for image-to-video */
|
|
236
|
+
startImage?: string
|
|
237
|
+
/** End image for video interpolation */
|
|
238
|
+
endImage?: string
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface AIEmbeddingOptions {
|
|
242
|
+
model?: string
|
|
243
|
+
input: string | string[]
|
|
244
|
+
dimensions?: number
|
|
245
|
+
encodingFormat?: 'float' | 'base64'
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface AIGenerateMusicOptions {
|
|
249
|
+
model?: string
|
|
250
|
+
prompt: string
|
|
251
|
+
duration?: number
|
|
252
|
+
genre?: string
|
|
253
|
+
mood?: string
|
|
254
|
+
tempo?: number
|
|
255
|
+
instruments?: string[]
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export interface AIGenerateSoundEffectOptions {
|
|
259
|
+
model?: string
|
|
260
|
+
prompt: string
|
|
261
|
+
duration?: number
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface AIVoiceCloneOptions {
|
|
265
|
+
model?: string
|
|
266
|
+
name: string
|
|
267
|
+
/** Audio samples as base64 */
|
|
268
|
+
samples: string[]
|
|
269
|
+
description?: string
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface AIGenerationResult {
|
|
273
|
+
content: string
|
|
274
|
+
model: string
|
|
275
|
+
provider: AIProviderType
|
|
276
|
+
type: AIGenerationType
|
|
277
|
+
tokens?: {
|
|
278
|
+
prompt: number
|
|
279
|
+
completion: number
|
|
280
|
+
total: number
|
|
281
|
+
}
|
|
282
|
+
cost?: {
|
|
283
|
+
input: number
|
|
284
|
+
output: number
|
|
285
|
+
total: number
|
|
286
|
+
}
|
|
287
|
+
durationMs: number
|
|
288
|
+
finishReason?: string
|
|
289
|
+
metadata?: Record<string, unknown>
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export interface AIEmbeddingResult {
|
|
293
|
+
embeddings: number[][]
|
|
294
|
+
model: string
|
|
295
|
+
provider: AIProviderType
|
|
296
|
+
tokens: number
|
|
297
|
+
durationMs: number
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface AITranscriptionResult {
|
|
301
|
+
text: string
|
|
302
|
+
language?: string
|
|
303
|
+
duration?: number
|
|
304
|
+
segments?: AITranscriptionSegment[]
|
|
305
|
+
words?: AITranscriptionWord[]
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export interface AITranscriptionSegment {
|
|
309
|
+
id: number
|
|
310
|
+
start: number
|
|
311
|
+
end: number
|
|
312
|
+
text: string
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export interface AITranscriptionWord {
|
|
316
|
+
word: string
|
|
317
|
+
start: number
|
|
318
|
+
end: number
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// ============================================================================
|
|
322
|
+
// Realtime Audio Types
|
|
323
|
+
// ============================================================================
|
|
324
|
+
|
|
325
|
+
export interface AIRealtimeConfig {
|
|
326
|
+
model?: string
|
|
327
|
+
voice?: string
|
|
328
|
+
instructions?: string
|
|
329
|
+
inputAudioFormat?: 'pcm16' | 'g711_ulaw' | 'g711_alaw'
|
|
330
|
+
outputAudioFormat?: 'pcm16' | 'g711_ulaw' | 'g711_alaw'
|
|
331
|
+
turnDetection?: {
|
|
332
|
+
type: 'server_vad'
|
|
333
|
+
threshold?: number
|
|
334
|
+
prefixPaddingMs?: number
|
|
335
|
+
silenceDurationMs?: number
|
|
336
|
+
}
|
|
337
|
+
tools?: AIToolDefinition[]
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export type AIRealtimeEvent =
|
|
341
|
+
| { type: 'session.created' }
|
|
342
|
+
| { type: 'input_audio_buffer.speech_started' }
|
|
343
|
+
| { type: 'input_audio_buffer.speech_stopped' }
|
|
344
|
+
| { type: 'response.audio.delta'; delta: string }
|
|
345
|
+
| { type: 'response.audio.done' }
|
|
346
|
+
| { type: 'response.text.delta'; delta: string }
|
|
347
|
+
| { type: 'response.text.done'; text: string }
|
|
348
|
+
| { type: 'response.done'; usage?: { input_tokens: number; output_tokens: number } }
|
|
349
|
+
| { type: 'error'; error: { message: string; code?: string } }
|
|
350
|
+
| { type: 'input_audio_buffer.committed' }
|
|
351
|
+
| { type: 'conversation.item.created'; item: any }
|
|
352
|
+
|
|
353
|
+
// ============================================================================
|
|
354
|
+
// Logging Types
|
|
355
|
+
// ============================================================================
|
|
356
|
+
|
|
357
|
+
export type AIRequestStatus = 'success' | 'error'
|
|
358
|
+
|
|
359
|
+
export interface AILogEntry {
|
|
360
|
+
requestId: string
|
|
361
|
+
model: string
|
|
362
|
+
provider: AIProviderType | string
|
|
363
|
+
caller: string
|
|
364
|
+
type: AIGenerationType | string
|
|
365
|
+
timestamp: number
|
|
366
|
+
durationMs: number
|
|
367
|
+
systemPrompt: string
|
|
368
|
+
userPrompt: string
|
|
369
|
+
hasImage: boolean
|
|
370
|
+
imageSizeBytes?: number
|
|
371
|
+
temperature?: number
|
|
372
|
+
maxTokens?: number
|
|
373
|
+
requestBodySize: number
|
|
374
|
+
status: AIRequestStatus
|
|
375
|
+
httpStatus: number
|
|
376
|
+
responseContent: string
|
|
377
|
+
responseSize: number
|
|
378
|
+
finishReason?: string
|
|
379
|
+
promptTokens?: number
|
|
380
|
+
completionTokens?: number
|
|
381
|
+
totalTokens?: number
|
|
382
|
+
errorMessage?: string
|
|
383
|
+
inputCostUsd?: number
|
|
384
|
+
outputCostUsd?: number
|
|
385
|
+
totalCostUsd?: number
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// ============================================================================
|
|
389
|
+
// Stats Types
|
|
390
|
+
// ============================================================================
|
|
391
|
+
|
|
392
|
+
export interface AIUsageStats {
|
|
393
|
+
totalCalls: number
|
|
394
|
+
successCalls: number
|
|
395
|
+
errorCalls: number
|
|
396
|
+
totalTokens: number
|
|
397
|
+
totalCostUsd: number
|
|
398
|
+
avgDurationMs: number
|
|
399
|
+
byModel: Record<string, { calls: number; tokens: number; cost: number }>
|
|
400
|
+
byProvider: Record<string, { calls: number; tokens: number; cost: number }>
|
|
401
|
+
byType: Record<string, { calls: number; tokens: number; cost: number }>
|
|
402
|
+
byDay: Array<{ date: string; calls: number; tokens: number; cost: number }>
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// ============================================================================
|
|
406
|
+
// Config Types
|
|
407
|
+
// ============================================================================
|
|
408
|
+
|
|
409
|
+
export interface AIConfig {
|
|
410
|
+
defaultProvider: AIProviderType
|
|
411
|
+
defaultModel: string
|
|
412
|
+
providers: AIProviderConfig[]
|
|
413
|
+
models: AIModel[]
|
|
414
|
+
logging: {
|
|
415
|
+
enabled: boolean
|
|
416
|
+
maxPromptLength: number
|
|
417
|
+
maxResponseLength: number
|
|
418
|
+
}
|
|
419
|
+
retries: {
|
|
420
|
+
maxAttempts: number
|
|
421
|
+
retryableStatusCodes: number[]
|
|
422
|
+
backoffMultiplierMs: number
|
|
423
|
+
}
|
|
424
|
+
/** Model defaults for each generation type */
|
|
425
|
+
generationDefaults?: {
|
|
426
|
+
image?: string
|
|
427
|
+
audio?: string
|
|
428
|
+
video?: string
|
|
429
|
+
embedding?: string
|
|
430
|
+
transcription?: string
|
|
431
|
+
music?: string
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// ============================================================================
|
|
436
|
+
// Component Props (shared across React / SolidJS)
|
|
437
|
+
// ============================================================================
|
|
438
|
+
|
|
439
|
+
export interface ChatWindowProps {
|
|
440
|
+
conversationId?: string
|
|
441
|
+
model?: string
|
|
442
|
+
systemPrompt?: string
|
|
443
|
+
className?: string
|
|
444
|
+
onNewConversation?: (id: string) => void
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export interface ModelTestPageProps {
|
|
448
|
+
className?: string
|
|
449
|
+
defaultTab?: AIGenerationType
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export interface AILogTableProps {
|
|
453
|
+
className?: string
|
|
454
|
+
limit?: number
|
|
455
|
+
filters?: {
|
|
456
|
+
model?: string
|
|
457
|
+
provider?: string
|
|
458
|
+
status?: AIRequestStatus
|
|
459
|
+
caller?: string
|
|
460
|
+
type?: AIGenerationType
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
export interface ImageGeneratorProps {
|
|
465
|
+
className?: string
|
|
466
|
+
models?: string[]
|
|
467
|
+
defaultModel?: string
|
|
468
|
+
onGenerate?: (result: AIGenerationResult) => void
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export interface AudioPlayerProps {
|
|
472
|
+
className?: string
|
|
473
|
+
src: string
|
|
474
|
+
format?: string
|
|
475
|
+
autoPlay?: boolean
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
export interface VoiceSelectorProps {
|
|
479
|
+
className?: string
|
|
480
|
+
voices: AIVoiceOption[]
|
|
481
|
+
selectedVoice?: string
|
|
482
|
+
onSelect: (voiceId: string) => void
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export interface AIVoiceOption {
|
|
486
|
+
id: string
|
|
487
|
+
name: string
|
|
488
|
+
provider: AIProviderType
|
|
489
|
+
language?: string
|
|
490
|
+
gender?: 'male' | 'female' | 'neutral'
|
|
491
|
+
preview?: string
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
export interface RealtimeAudioProps {
|
|
495
|
+
className?: string
|
|
496
|
+
model?: string
|
|
497
|
+
voice?: string
|
|
498
|
+
instructions?: string
|
|
499
|
+
onTranscript?: (text: string) => void
|
|
500
|
+
onResponse?: (text: string) => void
|
|
501
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"outDir": "./dist",
|
|
10
|
+
"rootDir": "./src",
|
|
11
|
+
"strict": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"isolatedModules": true
|
|
17
|
+
},
|
|
18
|
+
"include": [
|
|
19
|
+
"src"
|
|
20
|
+
],
|
|
21
|
+
"exclude": [
|
|
22
|
+
"node_modules",
|
|
23
|
+
"dist"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: {
|
|
5
|
+
index: 'src/index.ts',
|
|
6
|
+
config: 'src/config.ts',
|
|
7
|
+
'providers/index': 'src/providers/index.ts',
|
|
8
|
+
'convex/index': 'src/convex/index.ts',
|
|
9
|
+
content: 'src/content.ts',
|
|
10
|
+
memory: 'src/memory.ts',
|
|
11
|
+
skills: 'src/skills.ts',
|
|
12
|
+
},
|
|
13
|
+
format: ['esm'],
|
|
14
|
+
dts: true,
|
|
15
|
+
clean: true,
|
|
16
|
+
sourcemap: true,
|
|
17
|
+
external: [
|
|
18
|
+
'convex',
|
|
19
|
+
'convex/server',
|
|
20
|
+
'convex/values',
|
|
21
|
+
],
|
|
22
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# ✦ @geenius-ai/solidjs\n\n> SolidJS primitives, components, and pages for geenius-ai\n\n---\n\n## Overview\nBuilt with Steve Jobs-level minimalism and Jony Ive-level craftsmanship, this package is designed to deliver unparalleled developer experience (DX) and rock-solid performance.\n\n## Installation\n\n```bash\npnpm add @geenius-ai/solidjs\n```\n\n## Usage\n\n```typescript\nimport { init } from '@geenius-ai/solidjs';\n\n// Initialize the module with absolute precision\ninit({\n mode: 'premium',\n});\n```\n\n## Architecture\n- **Zero-config**: It just works.\n- **Strictly Typed**: Fully written in TypeScript for flawless IntelliSense.\n- **Framework Agnostic**: seamlessly integrates into the Geenius ecosystem.\n\n---\n\n*Designed by Antigravity HQ*\n
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geenius-ai/solidjs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "SolidJS primitives, components, and pages for geenius-ai",
|
|
7
|
+
"author": "Antigravity HQ",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./primitives": {
|
|
18
|
+
"types": "./dist/primitives/index.d.ts",
|
|
19
|
+
"import": "./dist/primitives/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./components": {
|
|
22
|
+
"types": "./dist/components/index.d.ts",
|
|
23
|
+
"import": "./dist/components/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./pages": {
|
|
26
|
+
"types": "./dist/pages/index.d.ts",
|
|
27
|
+
"import": "./dist/pages/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"src"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsup",
|
|
36
|
+
"clean": "rm -rf dist",
|
|
37
|
+
"type-check": "tsc --noEmit",
|
|
38
|
+
"prepublishOnly": "pnpm clean && pnpm build"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@geenius-ai/shared": "workspace:*"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"convex": ">=1.0.0",
|
|
45
|
+
"solid-js": ">=1.0.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"convex": "^1.34.0",
|
|
49
|
+
"solid-js": "^1.9.0",
|
|
50
|
+
"tsup": "^8.5.1",
|
|
51
|
+
"typescript": "~6.0.2"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=20.0.0"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// @geenius-ai/solidjs — src/components/ChatWindow.tsx
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SolidJS chat window component.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createSignal, For, Show, type Component, type JSX } from 'solid-js'
|
|
8
|
+
import type { AIChatMessage } from '@geenius-ai/shared'
|
|
9
|
+
import { createChat, type CreateChatOptions } from '../primitives/createChat'
|
|
10
|
+
|
|
11
|
+
export interface SolidChatWindowProps extends CreateChatOptions {
|
|
12
|
+
className?: string
|
|
13
|
+
renderMessage?: (message: AIChatMessage) => JSX.Element
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const ChatWindow: Component<SolidChatWindowProps> = (props) => {
|
|
17
|
+
const [input, setInput] = createSignal('')
|
|
18
|
+
const chat = createChat(props)
|
|
19
|
+
|
|
20
|
+
const handleSubmit = async (e: Event) => {
|
|
21
|
+
e.preventDefault()
|
|
22
|
+
const content = input().trim()
|
|
23
|
+
if (!content || chat.isSending()) return
|
|
24
|
+
setInput('')
|
|
25
|
+
await chat.sendMessage(content)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div class={props.className} data-ai-component="chat-window">
|
|
30
|
+
<div data-ai-messages>
|
|
31
|
+
<Show when={chat.messages().length === 0}>
|
|
32
|
+
<div data-ai-empty><p>Start a conversation</p></div>
|
|
33
|
+
</Show>
|
|
34
|
+
|
|
35
|
+
<For each={chat.messages()}>
|
|
36
|
+
{(msg) => props.renderMessage ? props.renderMessage(msg) : (
|
|
37
|
+
<div data-ai-message data-ai-role={msg.role}>
|
|
38
|
+
<div data-ai-message-role>{msg.role}</div>
|
|
39
|
+
<div data-ai-message-content>{msg.content}</div>
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
42
|
+
</For>
|
|
43
|
+
|
|
44
|
+
<Show when={chat.isSending()}>
|
|
45
|
+
<div data-ai-message data-ai-role="assistant" data-ai-loading>
|
|
46
|
+
<span>Thinking…</span>
|
|
47
|
+
</div>
|
|
48
|
+
</Show>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<Show when={chat.error()}>
|
|
52
|
+
<div data-ai-error role="alert">
|
|
53
|
+
<span>{chat.error()}</span>
|
|
54
|
+
<button onClick={chat.clearError}>×</button>
|
|
55
|
+
</div>
|
|
56
|
+
</Show>
|
|
57
|
+
|
|
58
|
+
<form onSubmit={handleSubmit} data-ai-input-form>
|
|
59
|
+
<textarea
|
|
60
|
+
value={input()}
|
|
61
|
+
onInput={(e) => setInput(e.currentTarget.value)}
|
|
62
|
+
placeholder="Type a message…"
|
|
63
|
+
disabled={chat.isSending()}
|
|
64
|
+
data-ai-input
|
|
65
|
+
onKeyDown={(e) => {
|
|
66
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
67
|
+
e.preventDefault()
|
|
68
|
+
handleSubmit(e)
|
|
69
|
+
}
|
|
70
|
+
}}
|
|
71
|
+
/>
|
|
72
|
+
<button type="submit" disabled={chat.isSending() || !input().trim()} data-ai-send>
|
|
73
|
+
{chat.isSending() ? 'Sending…' : 'Send'}
|
|
74
|
+
</button>
|
|
75
|
+
</form>
|
|
76
|
+
</div>
|
|
77
|
+
)
|
|
78
|
+
}
|