orchid-ai 1.2.2 → 1.2.4
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 +3 -3
- package/dist/cli/components/ChatPanel.d.ts +2 -1
- package/dist/cli/components/Conversation.d.ts +2 -1
- package/dist/cli/components/ModelSwitcher.d.ts +2 -1
- package/dist/cli/hooks/useModelSwitcher.d.ts +7 -4
- package/dist/cli/hooks/useResolvedDefaultModel.d.ts +21 -0
- package/dist/cli/hooks/useStreamingAI.d.ts +3 -2
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/server/contextual-service.d.ts +49 -1
- package/dist/cli/server/intent-detection.d.ts +2 -0
- package/dist/cli/server/utils.d.ts +0 -12
- package/dist/cli/types/types.d.ts +2 -1
- package/dist/components/ChatPanel.d.ts +2 -1
- package/dist/components/Conversation.d.ts +2 -1
- package/dist/components/ModelSwitcher.d.ts +2 -1
- package/dist/hooks/useModelSwitcher.d.ts +7 -4
- package/dist/hooks/useResolvedDefaultModel.d.ts +21 -0
- package/dist/hooks/useStreamingAI.d.ts +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +425 -39
- package/dist/index.js +425 -38
- package/dist/server/components/ChatPanel.d.ts +2 -1
- package/dist/server/components/Conversation.d.ts +2 -1
- package/dist/server/components/ModelSwitcher.d.ts +2 -1
- package/dist/server/contextual-service.d.ts +49 -1
- package/dist/server/hooks/useModelSwitcher.d.ts +7 -4
- package/dist/server/hooks/useResolvedDefaultModel.d.ts +21 -0
- package/dist/server/hooks/useStreamingAI.d.ts +3 -2
- package/dist/server/index.esm.js +507 -151
- package/dist/server/index.js +473 -99
- package/dist/server/intent-detection.d.ts +2 -0
- package/dist/server/server/contextual-service.d.ts +49 -1
- package/dist/server/server/intent-detection.d.ts +2 -0
- package/dist/server/server/utils.d.ts +0 -12
- package/dist/server/types/types.d.ts +2 -1
- package/dist/server/utils.d.ts +0 -12
- package/dist/types/types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import type { ContextualServiceConfig, ContextualRequest } from '../types/types.js';
|
|
2
2
|
export declare class ContextualCommandService {
|
|
3
3
|
private config;
|
|
4
|
+
private modelsCache;
|
|
5
|
+
private cacheFilePath;
|
|
6
|
+
private readonly CACHE_TTL_MS;
|
|
4
7
|
private verboseLogging;
|
|
5
8
|
private usage;
|
|
6
9
|
constructor(config: ContextualServiceConfig);
|
|
10
|
+
/**
|
|
11
|
+
* Load models cache from file if it exists and is fresh
|
|
12
|
+
*/
|
|
13
|
+
private loadModelsCache;
|
|
14
|
+
/**
|
|
15
|
+
* Save models cache to file
|
|
16
|
+
*/
|
|
17
|
+
private saveModelsCache;
|
|
7
18
|
private autoConfigureProviders;
|
|
8
19
|
private log;
|
|
9
20
|
private handleError;
|
|
@@ -30,14 +41,51 @@ export declare class ContextualCommandService {
|
|
|
30
41
|
*/
|
|
31
42
|
getSuggestions(request: ContextualRequest): Promise<any[]>;
|
|
32
43
|
/**
|
|
33
|
-
*
|
|
44
|
+
* Static utility to read cached models from file (for use in other services)
|
|
45
|
+
*/
|
|
46
|
+
static getCachedModelsSync(): Array<{
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
provider: string;
|
|
50
|
+
available: boolean;
|
|
51
|
+
computeWeight?: number;
|
|
52
|
+
supportsImages?: boolean;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Static utility to get the fastest model for a provider from cache
|
|
56
|
+
*/
|
|
57
|
+
static getFastestModelSync(provider: string): string | null;
|
|
58
|
+
/**
|
|
59
|
+
* Get available models from API or use cached/defaults
|
|
60
|
+
* Uses file-based cache that refreshes every 24 hours
|
|
34
61
|
*/
|
|
35
62
|
getAvailableModels(): Promise<{
|
|
36
63
|
id: string;
|
|
37
64
|
name: string;
|
|
38
65
|
provider: string;
|
|
39
66
|
available: boolean;
|
|
67
|
+
computeWeight?: number;
|
|
68
|
+
supportsImages?: boolean;
|
|
40
69
|
}[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Get the latest default model for a provider (balanced tier, or fallback to hardcoded)
|
|
72
|
+
* This should be used instead of DEFAULT_CONFIG.model when possible
|
|
73
|
+
*/
|
|
74
|
+
getLatestDefaultModel(provider?: string): Promise<string>;
|
|
75
|
+
/**
|
|
76
|
+
* Get default models by tier for a provider
|
|
77
|
+
* @param provider - Provider name
|
|
78
|
+
* @param tier - 'fast' (lowest computeWeight = cheapest), 'balanced' (medium), or 'powerful' (highest = most expensive)
|
|
79
|
+
*/
|
|
80
|
+
getDefaultModelByTier(provider: string, tier?: 'fast' | 'balanced' | 'powerful'): Promise<string | null>;
|
|
81
|
+
/**
|
|
82
|
+
* Get latest models from each tier for all configured providers
|
|
83
|
+
*/
|
|
84
|
+
getLatestModelsByTier(): Promise<Record<string, {
|
|
85
|
+
fast: string;
|
|
86
|
+
balanced: string;
|
|
87
|
+
powerful: string;
|
|
88
|
+
}>>;
|
|
41
89
|
/**
|
|
42
90
|
* Get usage statistics
|
|
43
91
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModelInfo } from '../types/types';
|
|
1
|
+
import { ModelInfo, ServerConfig } from '../types/types';
|
|
2
2
|
interface CurrentModel {
|
|
3
3
|
provider: string;
|
|
4
4
|
model: string;
|
|
@@ -25,16 +25,19 @@ interface UsageStats {
|
|
|
25
25
|
interface UseModelSwitcherOptions {
|
|
26
26
|
initialProvider?: string;
|
|
27
27
|
initialModel?: string;
|
|
28
|
+
initialTier?: 'fast' | 'balanced' | 'powerful';
|
|
28
29
|
customModels?: Record<string, ModelInfo[]>;
|
|
30
|
+
serverConfig?: ServerConfig;
|
|
29
31
|
}
|
|
30
|
-
export declare function useModelSwitcher({ initialProvider, initialModel,
|
|
32
|
+
export declare function useModelSwitcher({ initialProvider, initialModel, initialTier, // Can be undefined - don't default here, let Conversation handle it
|
|
33
|
+
customModels, serverConfig, }?: UseModelSwitcherOptions): {
|
|
31
34
|
models: ModelInfo[];
|
|
32
35
|
modelsByProvider: Record<string, ModelInfo[]>;
|
|
33
36
|
currentModel: CurrentModel;
|
|
34
37
|
currentCapabilities: ModelCapabilities;
|
|
35
38
|
usageStats: UsageStats;
|
|
36
39
|
isLoading: boolean;
|
|
37
|
-
error: null;
|
|
40
|
+
error: string | null;
|
|
38
41
|
switchModel: (model: string, provider?: string) => {
|
|
39
42
|
success: boolean;
|
|
40
43
|
current: {
|
|
@@ -48,7 +51,7 @@ export declare function useModelSwitcher({ initialProvider, initialModel, custom
|
|
|
48
51
|
provider: string;
|
|
49
52
|
model: string;
|
|
50
53
|
capabilities: ModelCapabilities;
|
|
51
|
-
};
|
|
54
|
+
} | null;
|
|
52
55
|
modelState: {
|
|
53
56
|
models: ModelInfo[];
|
|
54
57
|
current: CurrentModel;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ModelCapabilities } from '../types/types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to resolve tier-based default model config to actual model
|
|
4
|
+
*
|
|
5
|
+
* This hook takes a default model configuration that may include a tier
|
|
6
|
+
* (like 'fast', 'balanced', 'powerful') and resolves it to an actual model
|
|
7
|
+
* by fetching the available models from the server and selecting the best
|
|
8
|
+
* match for the provider and tier combination.
|
|
9
|
+
*
|
|
10
|
+
* @param defaultModel - The model configuration to resolve
|
|
11
|
+
* @returns The resolved model with provider, model name, and capabilities
|
|
12
|
+
*/
|
|
13
|
+
export declare function useResolvedDefaultModel(defaultModel?: {
|
|
14
|
+
provider: string;
|
|
15
|
+
model?: string;
|
|
16
|
+
tier?: 'fast' | 'balanced' | 'powerful';
|
|
17
|
+
}): {
|
|
18
|
+
provider: string;
|
|
19
|
+
model: string;
|
|
20
|
+
capabilities: ModelCapabilities;
|
|
21
|
+
} | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ChatMessage, ModelCapabilities, ServerConfig } from '../types/types';
|
|
2
2
|
interface ModelSelection {
|
|
3
3
|
provider: string;
|
|
4
|
-
model
|
|
5
|
-
|
|
4
|
+
model?: string;
|
|
5
|
+
tier?: 'fast' | 'balanced' | 'powerful';
|
|
6
|
+
capabilities?: ModelCapabilities;
|
|
6
7
|
}
|
|
7
8
|
export declare function useStreamingAI({ userId, serverConfig, formData, chats: externalChats, setChats: externalSetChats, currentChatId: externalCurrentChatId, setCurrentChatId: externalSetCurrentChatId, modelSelection, onUsageTracked, chatLevel, additionalContext, verbose, }: {
|
|
8
9
|
userId: string;
|