@nextsparkjs/plugin-ai 0.1.0-beta.1
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/.env.example +79 -0
- package/README.md +529 -0
- package/api/README.md +65 -0
- package/api/ai-history/[id]/route.ts +112 -0
- package/api/embeddings/route.ts +129 -0
- package/api/generate/route.ts +160 -0
- package/docs/01-getting-started/01-introduction.md +237 -0
- package/docs/01-getting-started/02-installation.md +447 -0
- package/docs/01-getting-started/03-configuration.md +416 -0
- package/docs/02-features/01-text-generation.md +523 -0
- package/docs/02-features/02-embeddings.md +241 -0
- package/docs/02-features/03-ai-history.md +549 -0
- package/docs/03-advanced-usage/01-core-utilities.md +500 -0
- package/docs/04-use-cases/01-content-generation.md +453 -0
- package/entities/ai-history/ai-history.config.ts +123 -0
- package/entities/ai-history/ai-history.fields.ts +330 -0
- package/entities/ai-history/messages/en.json +56 -0
- package/entities/ai-history/messages/es.json +56 -0
- package/entities/ai-history/migrations/001_ai_history_table.sql +167 -0
- package/entities/ai-history/migrations/002_ai_history_metas.sql +103 -0
- package/lib/ai-history-meta-service.ts +379 -0
- package/lib/ai-history-service.ts +391 -0
- package/lib/ai-sdk.ts +7 -0
- package/lib/core-utils.ts +217 -0
- package/lib/plugin-env.ts +252 -0
- package/lib/sanitize.ts +122 -0
- package/lib/save-example.ts +237 -0
- package/lib/server-env.ts +104 -0
- package/package.json +23 -0
- package/plugin.config.ts +55 -0
- package/public/docs/login-404-error.png +0 -0
- package/tsconfig.json +47 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/types/ai.types.ts +51 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Plugin Core Types
|
|
3
|
+
*
|
|
4
|
+
* Minimal types for core utilities only
|
|
5
|
+
*/
|
|
6
|
+
import type { LanguageModel } from 'ai'
|
|
7
|
+
|
|
8
|
+
// Core provider types
|
|
9
|
+
export type AIProvider = 'openai' | 'anthropic' | 'ollama'
|
|
10
|
+
|
|
11
|
+
// Basic model selection result
|
|
12
|
+
export interface ModelSelection {
|
|
13
|
+
provider: AIProvider
|
|
14
|
+
model: LanguageModel
|
|
15
|
+
modelName: string
|
|
16
|
+
isLocal: boolean
|
|
17
|
+
costConfig: {
|
|
18
|
+
input: number
|
|
19
|
+
output: number
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// AI SDK result type for extractTokens function
|
|
24
|
+
export interface AIResult {
|
|
25
|
+
text: string
|
|
26
|
+
usage?: {
|
|
27
|
+
inputTokens?: number
|
|
28
|
+
outputTokens?: number
|
|
29
|
+
totalTokens?: number
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Token usage
|
|
34
|
+
export interface TokenUsage {
|
|
35
|
+
input: number
|
|
36
|
+
output: number
|
|
37
|
+
total: number
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Plugin validation result
|
|
41
|
+
export interface PluginValidation {
|
|
42
|
+
valid: boolean
|
|
43
|
+
error?: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Error result for handleAIError
|
|
47
|
+
export interface AIErrorResult {
|
|
48
|
+
error: string
|
|
49
|
+
message: string
|
|
50
|
+
status: number
|
|
51
|
+
}
|