nolo-cli 0.1.8 → 0.1.10
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 +32 -0
- package/agentRuntimeCommands.ts +3 -3
- package/ai/agent/_executeModel.ts +118 -0
- package/ai/agent/agentSlice.ts +525 -0
- package/ai/agent/appWorkingMemory.ts +126 -0
- package/ai/agent/avatarUtils.ts +24 -0
- package/ai/agent/buildEditingContext.ts +373 -0
- package/ai/agent/buildSystemPrompt.ts +532 -0
- package/ai/agent/cleanAgentMessages.ts +140 -0
- package/ai/agent/cliChatClient.ts +119 -0
- package/ai/agent/cliExecutor.ts +733 -0
- package/ai/agent/cliPrompt.ts +10 -0
- package/ai/agent/contextCompiler.ts +107 -0
- package/ai/agent/contextLayerContract.ts +44 -0
- package/ai/agent/createAgentSchema.ts +234 -0
- package/ai/agent/executeToolCall.ts +58 -0
- package/ai/agent/fetchAgentContexts.ts +42 -0
- package/ai/agent/generatePrompt.ts +3 -0
- package/ai/agent/getFullChatContextKeys.ts +168 -0
- package/ai/agent/hooks/fetchPublicAgents.ts +133 -0
- package/ai/agent/hooks/useAgentConfig.ts +61 -0
- package/ai/agent/hooks/useAgentDialog.ts +35 -0
- package/ai/agent/hooks/useAgentFormValidation.ts +202 -0
- package/ai/agent/hooks/usePublicAgents.ts +473 -0
- package/ai/agent/machineRunPermissions.ts +95 -0
- package/ai/agent/persistMessageWithFixedId.ts +37 -0
- package/ai/agent/planSlice.ts +259 -0
- package/ai/agent/referenceUtils.ts +229 -0
- package/ai/agent/runAgentBackground.ts +238 -0
- package/ai/agent/runAgentClientLoop.ts +138 -0
- package/ai/agent/runtimeGuidance.ts +97 -0
- package/ai/agent/runtimeServerBase.ts +37 -0
- package/ai/agent/server/fetchPublicAgents.ts +128 -0
- package/ai/agent/startParallelAgentStreams.ts +424 -0
- package/ai/agent/startupProtocol.ts +53 -0
- package/ai/agent/streamAgentChatTurn.ts +1278 -0
- package/ai/agent/streamAgentChatTurnUtils.ts +738 -0
- package/ai/agent/types.ts +71 -0
- package/ai/agent/utils/imageOutput.ts +33 -0
- package/ai/agent/utils/sortUtils.ts +250 -0
- package/ai/agent/web/referencePickerUtils.ts +146 -0
- package/ai/ai.locale.ts +1079 -0
- package/ai/chat/accumulateToolCallChunks.ts +95 -0
- package/ai/chat/fetchUtils.native.ts +276 -0
- package/ai/chat/fetchUtils.ts +153 -0
- package/ai/chat/parseApiError.ts +64 -0
- package/ai/chat/parseMultilineSSE.ts +95 -0
- package/ai/chat/sendOpenAICompletionsRequest.native.ts +682 -0
- package/ai/chat/sendOpenAICompletionsRequest.ts +703 -0
- package/ai/chat/sendOpenAIResponseRequest.ts +491 -0
- package/ai/chat/shouldUseServerProxy.ts +18 -0
- package/ai/chat/sseClient.native.ts +91 -0
- package/ai/chat/sseClient.ts +67 -0
- package/ai/chat/streamReader.native.ts +31 -0
- package/ai/chat/streamReader.ts +62 -0
- package/ai/chat/updateTotalUsage.ts +72 -0
- package/ai/context/buildReferenceContext.ts +437 -0
- package/ai/context/calculateContextUsage.ts +133 -0
- package/ai/context/retention.ts +165 -0
- package/ai/context/tokenUtils.ts +78 -0
- package/ai/index.ts +1 -0
- package/ai/llm/calculateGeminiImageTokens.ts +57 -0
- package/ai/llm/deepinfra.ts +28 -0
- package/ai/llm/fireworks.ts +50 -0
- package/ai/llm/generateRequestBody.ts +165 -0
- package/ai/llm/getModelContextWindow.ts +84 -0
- package/ai/llm/getNoloKey.ts +31 -0
- package/ai/llm/getPricing.ts +199 -0
- package/ai/llm/hooks/useModelPricing.ts +75 -0
- package/ai/llm/imagePricing.ts +40 -0
- package/ai/llm/isResponseAPIModel.ts +13 -0
- package/ai/llm/mimo.ts +71 -0
- package/ai/llm/mistral.ts +22 -0
- package/ai/llm/modelAvatar.ts +427 -0
- package/ai/llm/models.ts +45 -0
- package/ai/llm/openrouterModels.ts +269 -0
- package/ai/llm/providers.ts +306 -0
- package/ai/llm/reasoningModels.ts +28 -0
- package/ai/llm/types.ts +59 -0
- package/ai/llm/usageRequestOptions.ts +59 -0
- package/ai/memory/capture.ts +148 -0
- package/ai/memory/consolidate.ts +104 -0
- package/ai/memory/delete.ts +147 -0
- package/ai/memory/overlay.ts +84 -0
- package/ai/memory/query.ts +38 -0
- package/ai/memory/queryShared.ts +160 -0
- package/ai/memory/rank.ts +105 -0
- package/ai/memory/recentRelationshipRecap.ts +249 -0
- package/ai/memory/remember.ts +167 -0
- package/ai/memory/runtime.ts +76 -0
- package/ai/memory/store.ts +20 -0
- package/ai/memory/storeShared.ts +76 -0
- package/ai/memory/types.ts +46 -0
- package/ai/memory/understanding.ts +349 -0
- package/ai/memory/understandingGreeting.ts +264 -0
- package/ai/messages/type.ts +20 -0
- package/ai/policy/personalizationDialog.ts +333 -0
- package/ai/policy/runtimePolicy.ts +440 -0
- package/ai/policy/selfUpdateFields.ts +48 -0
- package/ai/policy/types.ts +64 -0
- package/ai/skills/referenceRuntime.ts +274 -0
- package/ai/skills/skillDiagnostics.ts +251 -0
- package/ai/skills/skillDocBuilder.ts +139 -0
- package/ai/skills/skillDocProtocol.ts +434 -0
- package/ai/skills/skillReferenceSummary.ts +63 -0
- package/ai/skills/skillSummaryMarker.ts +26 -0
- package/ai/token/calculatePrice.ts +544 -0
- package/ai/token/db.ts +98 -0
- package/ai/token/externalToolCost.ts +330 -0
- package/ai/token/hooks/useRecords.ts +65 -0
- package/ai/token/missingUsageEstimate.ts +42 -0
- package/ai/token/modelUsageQuery.ts +252 -0
- package/ai/token/normalizeUsage.ts +84 -0
- package/ai/token/openaiImageGenerationUsage.ts +56 -0
- package/ai/token/prepareTokenUsageData.ts +88 -0
- package/ai/token/query.ts +88 -0
- package/ai/token/queryUserTokens.ts +59 -0
- package/ai/token/resolveBillingTarget.ts +52 -0
- package/ai/token/saveTokenRecord.ts +53 -0
- package/ai/token/serverDialogProjection.ts +78 -0
- package/ai/token/serverTokenWriter.ts +143 -0
- package/ai/token/stats.ts +21 -0
- package/ai/token/tokenThunks.ts +24 -0
- package/ai/token/types.ts +93 -0
- package/ai/tools/agent/agentTools.ts +176 -0
- package/ai/tools/agent/agentUpdateShared.ts +311 -0
- package/ai/tools/agent/callAgentTool.ts +139 -0
- package/ai/tools/agent/createAgentTool.ts +512 -0
- package/ai/tools/agent/createDialogTool.ts +69 -0
- package/ai/tools/agent/createSkillAgentTool.ts +62 -0
- package/ai/tools/agent/parallelBudget.ts +221 -0
- package/ai/tools/agent/presets/appBuilderPreset.ts +145 -0
- package/ai/tools/agent/runLlmTool.ts +96 -0
- package/ai/tools/agent/runStreamingAgentTool.ts +73 -0
- package/ai/tools/agent/skillAgentArgs.ts +106 -0
- package/ai/tools/agent/skillAgentPreset.ts +89 -0
- package/ai/tools/agent/streamParallelAgentsTool.ts +122 -0
- package/ai/tools/agent/updateAgentTool.ts +96 -0
- package/ai/tools/agent/updateSelfTool.ts +113 -0
- package/ai/tools/amazonProductScraperTool.ts +86 -0
- package/ai/tools/apifyActorClient.ts +45 -0
- package/ai/tools/appEditGuard.ts +372 -0
- package/ai/tools/appReadSnapshot.ts +153 -0
- package/ai/tools/appTools.ts +1549 -0
- package/ai/tools/applyEditTool.ts +256 -0
- package/ai/tools/applyLineEditsTool.ts +312 -0
- package/ai/tools/browserTools/click.ts +33 -0
- package/ai/tools/browserTools/closeSession.ts +29 -0
- package/ai/tools/browserTools/common.ts +27 -0
- package/ai/tools/browserTools/openSession.ts +48 -0
- package/ai/tools/browserTools/readContent.ts +38 -0
- package/ai/tools/browserTools/selectOption.ts +46 -0
- package/ai/tools/browserTools/typeText.ts +42 -0
- package/ai/tools/category/createCategoryTool.ts +66 -0
- package/ai/tools/category/queryContentsByCategoryTool.ts +69 -0
- package/ai/tools/category/updateContentCategoryTool.ts +75 -0
- package/ai/tools/cfBrowserTools.ts +319 -0
- package/ai/tools/cfSpeechToTextTool.ts +49 -0
- package/ai/tools/checkEnvTool.ts +65 -0
- package/ai/tools/cloudflareCrawlTool.ts +289 -0
- package/ai/tools/codeSearchTool.ts +111 -0
- package/ai/tools/codeTools.ts +101 -0
- package/ai/tools/createDocTool.ts +132 -0
- package/ai/tools/createPlanTool.ts +999 -0
- package/ai/tools/createSkillDocTool.ts +155 -0
- package/ai/tools/createWorkflowTool.ts +154 -0
- package/ai/tools/deepseekOcrTool.ts +34 -0
- package/ai/tools/delayTool.ts +31 -0
- package/ai/tools/deleteSpacesTool.ts +325 -0
- package/ai/tools/deleteSpacesToolModel.ts +159 -0
- package/ai/tools/devReloadUtils.ts +29 -0
- package/ai/tools/dialogMessageSearch.ts +137 -0
- package/ai/tools/doctorSkillTool.ts +72 -0
- package/ai/tools/ecommerceScraperTool.ts +86 -0
- package/ai/tools/emailTools.ts +549 -0
- package/ai/tools/evalSkillTool.ts +92 -0
- package/ai/tools/exaSearchTool.ts +64 -0
- package/ai/tools/execBashTool.ts +379 -0
- package/ai/tools/executeSqlTool.ts +192 -0
- package/ai/tools/fetchWebpageSupport.ts +309 -0
- package/ai/tools/fetchWebpageTool.ts +84 -0
- package/ai/tools/geminiImagePreviewTool.ts +361 -0
- package/ai/tools/generateDocxTool.ts +215 -0
- package/ai/tools/googleSearchScraperTool.ts +106 -0
- package/ai/tools/importDataTool.ts +133 -0
- package/ai/tools/importSkillTool.ts +162 -0
- package/ai/tools/index.ts +1858 -0
- package/ai/tools/listFilesTool.ts +82 -0
- package/ai/tools/listUserSpacesTool.ts +113 -0
- package/ai/tools/modelUsageTools.ts +142 -0
- package/ai/tools/olmOcrTool.ts +34 -0
- package/ai/tools/openaiImageTool.ts +218 -0
- package/ai/tools/paddleOcrTool.ts +34 -0
- package/ai/tools/prepareTools.ts +23 -0
- package/ai/tools/readDocTool.ts +84 -0
- package/ai/tools/readFileTool.ts +211 -0
- package/ai/tools/readTool.ts +163 -0
- package/ai/tools/readXPostTool.ts +233 -0
- package/ai/tools/rememberMemoryTool.ts +84 -0
- package/ai/tools/remotionVideoTool.ts +151 -0
- package/ai/tools/searchDialogMessagesTool.ts +222 -0
- package/ai/tools/searchRepoTool.ts +115 -0
- package/ai/tools/searchWorkspaceTool.ts +259 -0
- package/ai/tools/skillFollowup.ts +86 -0
- package/ai/tools/surfWeatherTool.ts +169 -0
- package/ai/tools/table/addTableRowTool.ts +217 -0
- package/ai/tools/table/createTableTool.ts +315 -0
- package/ai/tools/table/rowTools.ts +366 -0
- package/ai/tools/table/schemaTools.ts +244 -0
- package/ai/tools/table/shareTableTool.ts +148 -0
- package/ai/tools/table/toolShared.ts +129 -0
- package/ai/tools/toolApiClient.ts +198 -0
- package/ai/tools/toolNameAliases.ts +57 -0
- package/ai/tools/toolResultError.ts +42 -0
- package/ai/tools/toolRunSlice.ts +303 -0
- package/ai/tools/toolSchemaCompatibility.ts +53 -0
- package/ai/tools/toolVisibility.ts +4 -0
- package/ai/tools/types.ts +20 -0
- package/ai/tools/uiAskChoiceTool.ts +104 -0
- package/ai/tools/updateContentTitleTool.ts +84 -0
- package/ai/tools/updateDocTool.ts +105 -0
- package/ai/tools/updateUserPreferenceProfileTool.ts +145 -0
- package/ai/tools/whisperTool.ts +77 -0
- package/ai/tools/writeFileTool.ts +210 -0
- package/ai/tools/youtubeScraperTool.ts +116 -0
- package/ai/tools/ziweiChartTool.ts +678 -0
- package/ai/types.ts +55 -0
- package/ai/workflow/workflowExecutor.ts +323 -0
- package/ai/workflow/workflowSlice.ts +73 -0
- package/ai/workflow/workflowTypes.ts +106 -0
- package/client/compactDialog.ts +222 -0
- package/connector-experimental/capabilities.ts +73 -0
- package/connector-experimental/codexBinary.ts +41 -0
- package/connector-experimental/heartbeatLoop.ts +22 -0
- package/connector-experimental/index.ts +5 -0
- package/connector-experimental/machineInfo.ts +46 -0
- package/connector-experimental/protocol.ts +54 -0
- package/machineCommands.ts +4 -4
- package/package.json +22 -6
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
// packages/ai/llm/modelAvatar.ts
|
|
2
|
+
// Maps provider/model name → @lobehub/icons Avatar component.
|
|
3
|
+
// Model-name check runs first so openrouter/deepinfra aggregators work correctly.
|
|
4
|
+
|
|
5
|
+
import { createElement, type CSSProperties, type ComponentType } from "react";
|
|
6
|
+
|
|
7
|
+
export type LobehubAvatarProps = {
|
|
8
|
+
size?: number | string;
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
type AvatarCtor = ComponentType<LobehubAvatarProps>;
|
|
13
|
+
type MonoModule = { default?: ComponentType<{ size?: number | string; style?: CSSProperties }> };
|
|
14
|
+
type AvatarModule = { default?: AvatarCtor };
|
|
15
|
+
type StyleModule = {
|
|
16
|
+
AVATAR_BACKGROUND?: string;
|
|
17
|
+
AVATAR_COLOR?: string;
|
|
18
|
+
AVATAR_ICON_MULTIPLE?: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type AvatarLoader = () => Promise<{ avatar?: AvatarModule; mono?: MonoModule; style?: StyleModule }>;
|
|
22
|
+
|
|
23
|
+
const scaleSize = (size: number | string, multiple: number) =>
|
|
24
|
+
typeof size === "number" ? size * multiple : `calc(${size} * ${multiple})`;
|
|
25
|
+
|
|
26
|
+
const createAvatarComponent = (
|
|
27
|
+
Mono: ComponentType<{ size?: number | string; style?: CSSProperties }>,
|
|
28
|
+
styleModule: StyleModule
|
|
29
|
+
): AvatarCtor => {
|
|
30
|
+
const background = styleModule.AVATAR_BACKGROUND ?? "#111";
|
|
31
|
+
const color = styleModule.AVATAR_COLOR ?? "#fff";
|
|
32
|
+
const iconMultiple = styleModule.AVATAR_ICON_MULTIPLE ?? 0.75;
|
|
33
|
+
|
|
34
|
+
const AvatarComponent: AvatarCtor = (rawProps) => {
|
|
35
|
+
const { size = 40, style, className } = rawProps ?? {};
|
|
36
|
+
|
|
37
|
+
return createElement(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
"aria-hidden": "true",
|
|
41
|
+
className,
|
|
42
|
+
style: {
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
background,
|
|
45
|
+
borderRadius: "50%",
|
|
46
|
+
color,
|
|
47
|
+
display: "inline-flex",
|
|
48
|
+
flex: "none",
|
|
49
|
+
height: size,
|
|
50
|
+
justifyContent: "center",
|
|
51
|
+
lineHeight: 1,
|
|
52
|
+
overflow: "hidden",
|
|
53
|
+
width: size,
|
|
54
|
+
...style,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
createElement(Mono, { size: scaleSize(size, iconMultiple), style: { flex: "none" } })
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return AvatarComponent;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// key → lazy import factory
|
|
65
|
+
const MAP: Record<string, AvatarLoader> = {
|
|
66
|
+
// ── 国际大厂 ─────────────────────────────────────
|
|
67
|
+
openai: () =>
|
|
68
|
+
Promise.all([
|
|
69
|
+
import("@lobehub/icons/es/OpenAI/components/Mono"),
|
|
70
|
+
import("@lobehub/icons/es/OpenAI/style"),
|
|
71
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
72
|
+
claude: () =>
|
|
73
|
+
Promise.all([
|
|
74
|
+
import("@lobehub/icons/es/Claude/components/Mono"),
|
|
75
|
+
import("@lobehub/icons/es/Claude/style"),
|
|
76
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
77
|
+
anthropic: () =>
|
|
78
|
+
Promise.all([
|
|
79
|
+
import("@lobehub/icons/es/Anthropic/components/Mono"),
|
|
80
|
+
import("@lobehub/icons/es/Anthropic/style"),
|
|
81
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
82
|
+
gemini: () =>
|
|
83
|
+
Promise.all([
|
|
84
|
+
import("@lobehub/icons/es/Gemini/components/Color"),
|
|
85
|
+
import("@lobehub/icons/es/Gemini/style"),
|
|
86
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
87
|
+
google: () =>
|
|
88
|
+
Promise.all([
|
|
89
|
+
import("@lobehub/icons/es/Google/components/Mono"),
|
|
90
|
+
import("@lobehub/icons/es/Google/style"),
|
|
91
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
92
|
+
grok: () =>
|
|
93
|
+
Promise.all([
|
|
94
|
+
import("@lobehub/icons/es/Grok/components/Mono"),
|
|
95
|
+
import("@lobehub/icons/es/Grok/style"),
|
|
96
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
97
|
+
xai: () =>
|
|
98
|
+
Promise.all([
|
|
99
|
+
import("@lobehub/icons/es/XAI/components/Mono"),
|
|
100
|
+
import("@lobehub/icons/es/XAI/style"),
|
|
101
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
102
|
+
mistral: () =>
|
|
103
|
+
Promise.all([
|
|
104
|
+
import("@lobehub/icons/es/Mistral/components/Mono"),
|
|
105
|
+
import("@lobehub/icons/es/Mistral/style"),
|
|
106
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
107
|
+
llama: () =>
|
|
108
|
+
Promise.all([
|
|
109
|
+
import("@lobehub/icons/es/Meta/components/Mono"),
|
|
110
|
+
import("@lobehub/icons/es/Meta/style"),
|
|
111
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
112
|
+
meta: () =>
|
|
113
|
+
Promise.all([
|
|
114
|
+
import("@lobehub/icons/es/Meta/components/Mono"),
|
|
115
|
+
import("@lobehub/icons/es/Meta/style"),
|
|
116
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
117
|
+
perplexity: () =>
|
|
118
|
+
Promise.all([
|
|
119
|
+
import("@lobehub/icons/es/Perplexity/components/Mono"),
|
|
120
|
+
import("@lobehub/icons/es/Perplexity/style"),
|
|
121
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
122
|
+
cohere: () =>
|
|
123
|
+
Promise.all([
|
|
124
|
+
import("@lobehub/icons/es/Cohere/components/Mono"),
|
|
125
|
+
import("@lobehub/icons/es/Cohere/style"),
|
|
126
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
127
|
+
gemma: () =>
|
|
128
|
+
Promise.all([
|
|
129
|
+
import("@lobehub/icons/es/Gemma/components/Mono"),
|
|
130
|
+
import("@lobehub/icons/es/Gemma/style"),
|
|
131
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
132
|
+
copilot: () =>
|
|
133
|
+
Promise.all([
|
|
134
|
+
import("@lobehub/icons/es/Copilot/components/Mono"),
|
|
135
|
+
import("@lobehub/icons/es/Copilot/style"),
|
|
136
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
137
|
+
|
|
138
|
+
// ── 中国模型 ─────────────────────────────────────
|
|
139
|
+
glm: () =>
|
|
140
|
+
Promise.all([
|
|
141
|
+
import("@lobehub/icons/es/ChatGLM/components/Mono"),
|
|
142
|
+
import("@lobehub/icons/es/ChatGLM/style"),
|
|
143
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
144
|
+
chatglm: () =>
|
|
145
|
+
Promise.all([
|
|
146
|
+
import("@lobehub/icons/es/ChatGLM/components/Mono"),
|
|
147
|
+
import("@lobehub/icons/es/ChatGLM/style"),
|
|
148
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
149
|
+
zhipu: () =>
|
|
150
|
+
Promise.all([
|
|
151
|
+
import("@lobehub/icons/es/Zhipu/components/Mono"),
|
|
152
|
+
import("@lobehub/icons/es/Zhipu/style"),
|
|
153
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
154
|
+
kimi: () =>
|
|
155
|
+
Promise.all([
|
|
156
|
+
import("@lobehub/icons/es/Kimi/components/Mono"),
|
|
157
|
+
import("@lobehub/icons/es/Kimi/style"),
|
|
158
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
159
|
+
moonshot: () =>
|
|
160
|
+
Promise.all([
|
|
161
|
+
import("@lobehub/icons/es/Moonshot/components/Mono"),
|
|
162
|
+
import("@lobehub/icons/es/Moonshot/style"),
|
|
163
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
164
|
+
minimax: () =>
|
|
165
|
+
Promise.all([
|
|
166
|
+
import("@lobehub/icons/es/Minimax/components/Mono"),
|
|
167
|
+
import("@lobehub/icons/es/Minimax/style"),
|
|
168
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
169
|
+
hailuo: () =>
|
|
170
|
+
Promise.all([
|
|
171
|
+
import("@lobehub/icons/es/Hailuo/components/Mono"),
|
|
172
|
+
import("@lobehub/icons/es/Hailuo/style"),
|
|
173
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
174
|
+
doubao: () =>
|
|
175
|
+
Promise.all([
|
|
176
|
+
import("@lobehub/icons/es/Doubao/components/Mono"),
|
|
177
|
+
import("@lobehub/icons/es/Doubao/style"),
|
|
178
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
179
|
+
hunyuan: () =>
|
|
180
|
+
Promise.all([
|
|
181
|
+
import("@lobehub/icons/es/Hunyuan/components/Mono"),
|
|
182
|
+
import("@lobehub/icons/es/Hunyuan/style"),
|
|
183
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
184
|
+
deepseek: () =>
|
|
185
|
+
Promise.all([
|
|
186
|
+
import("@lobehub/icons/es/DeepSeek/components/Mono"),
|
|
187
|
+
import("@lobehub/icons/es/DeepSeek/style"),
|
|
188
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
189
|
+
qwen: () =>
|
|
190
|
+
Promise.all([
|
|
191
|
+
import("@lobehub/icons/es/Qwen/components/Mono"),
|
|
192
|
+
import("@lobehub/icons/es/Qwen/style"),
|
|
193
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
194
|
+
wenxin: () =>
|
|
195
|
+
Promise.all([
|
|
196
|
+
import("@lobehub/icons/es/Wenxin/components/Mono"),
|
|
197
|
+
import("@lobehub/icons/es/Wenxin/style"),
|
|
198
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
199
|
+
ernie: () =>
|
|
200
|
+
Promise.all([
|
|
201
|
+
import("@lobehub/icons/es/Wenxin/components/Mono"),
|
|
202
|
+
import("@lobehub/icons/es/Wenxin/style"),
|
|
203
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
204
|
+
baichuan: () =>
|
|
205
|
+
Promise.all([
|
|
206
|
+
import("@lobehub/icons/es/Baichuan/components/Mono"),
|
|
207
|
+
import("@lobehub/icons/es/Baichuan/style"),
|
|
208
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
209
|
+
yi: () =>
|
|
210
|
+
Promise.all([
|
|
211
|
+
import("@lobehub/icons/es/Yi/components/Mono"),
|
|
212
|
+
import("@lobehub/icons/es/Yi/style"),
|
|
213
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
214
|
+
zeroone: () =>
|
|
215
|
+
Promise.all([
|
|
216
|
+
import("@lobehub/icons/es/ZeroOne/components/Mono"),
|
|
217
|
+
import("@lobehub/icons/es/ZeroOne/style"),
|
|
218
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
219
|
+
internlm: () =>
|
|
220
|
+
Promise.all([
|
|
221
|
+
import("@lobehub/icons/es/InternLM/components/Mono"),
|
|
222
|
+
import("@lobehub/icons/es/InternLM/style"),
|
|
223
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
224
|
+
spark: () =>
|
|
225
|
+
Promise.all([
|
|
226
|
+
import("@lobehub/icons/es/Spark/components/Mono"),
|
|
227
|
+
import("@lobehub/icons/es/Spark/style"),
|
|
228
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
229
|
+
iflyt: () =>
|
|
230
|
+
Promise.all([
|
|
231
|
+
import("@lobehub/icons/es/Spark/components/Mono"),
|
|
232
|
+
import("@lobehub/icons/es/Spark/style"),
|
|
233
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
234
|
+
stepfun: () =>
|
|
235
|
+
Promise.all([
|
|
236
|
+
import("@lobehub/icons/es/Stepfun/components/Mono"),
|
|
237
|
+
import("@lobehub/icons/es/Stepfun/style"),
|
|
238
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
239
|
+
step: () =>
|
|
240
|
+
Promise.all([
|
|
241
|
+
import("@lobehub/icons/es/Stepfun/components/Mono"),
|
|
242
|
+
import("@lobehub/icons/es/Stepfun/style"),
|
|
243
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
244
|
+
sensenova: () =>
|
|
245
|
+
Promise.all([
|
|
246
|
+
import("@lobehub/icons/es/SenseNova/components/Mono"),
|
|
247
|
+
import("@lobehub/icons/es/SenseNova/style"),
|
|
248
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
249
|
+
sensetime: () =>
|
|
250
|
+
Promise.all([
|
|
251
|
+
import("@lobehub/icons/es/SenseNova/components/Mono"),
|
|
252
|
+
import("@lobehub/icons/es/SenseNova/style"),
|
|
253
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
254
|
+
qingyan: () =>
|
|
255
|
+
Promise.all([
|
|
256
|
+
import("@lobehub/icons/es/Qingyan/components/Mono"),
|
|
257
|
+
import("@lobehub/icons/es/Qingyan/style"),
|
|
258
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
259
|
+
coze: () =>
|
|
260
|
+
Promise.all([
|
|
261
|
+
import("@lobehub/icons/es/Coze/components/Mono"),
|
|
262
|
+
import("@lobehub/icons/es/Coze/style"),
|
|
263
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
264
|
+
yuanbao: () =>
|
|
265
|
+
Promise.all([
|
|
266
|
+
import("@lobehub/icons/es/Yuanbao/components/Mono"),
|
|
267
|
+
import("@lobehub/icons/es/Yuanbao/style"),
|
|
268
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
269
|
+
tiangong: () =>
|
|
270
|
+
Promise.all([
|
|
271
|
+
import("@lobehub/icons/es/Tiangong/components/Mono"),
|
|
272
|
+
import("@lobehub/icons/es/Tiangong/style"),
|
|
273
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
274
|
+
skywork: () =>
|
|
275
|
+
Promise.all([
|
|
276
|
+
import("@lobehub/icons/es/Skywork/components/Mono"),
|
|
277
|
+
import("@lobehub/icons/es/Skywork/style"),
|
|
278
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
279
|
+
|
|
280
|
+
// ── 推理/托管平台 ─────────────────────────────────
|
|
281
|
+
groq: () =>
|
|
282
|
+
Promise.all([
|
|
283
|
+
import("@lobehub/icons/es/Groq/components/Mono"),
|
|
284
|
+
import("@lobehub/icons/es/Groq/style"),
|
|
285
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
286
|
+
together: () =>
|
|
287
|
+
Promise.all([
|
|
288
|
+
import("@lobehub/icons/es/Together/components/Mono"),
|
|
289
|
+
import("@lobehub/icons/es/Together/style"),
|
|
290
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
291
|
+
deepinfra: () =>
|
|
292
|
+
Promise.all([
|
|
293
|
+
import("@lobehub/icons/es/DeepInfra/components/Mono"),
|
|
294
|
+
import("@lobehub/icons/es/DeepInfra/style"),
|
|
295
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
296
|
+
fireworks: () =>
|
|
297
|
+
Promise.all([
|
|
298
|
+
import("@lobehub/icons/es/Fireworks/components/Mono"),
|
|
299
|
+
import("@lobehub/icons/es/Fireworks/style"),
|
|
300
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
301
|
+
openrouter: () =>
|
|
302
|
+
Promise.all([
|
|
303
|
+
import("@lobehub/icons/es/OpenRouter/components/Mono"),
|
|
304
|
+
import("@lobehub/icons/es/OpenRouter/style"),
|
|
305
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
306
|
+
novita: () =>
|
|
307
|
+
Promise.all([
|
|
308
|
+
import("@lobehub/icons/es/Novita/components/Mono"),
|
|
309
|
+
import("@lobehub/icons/es/Novita/style"),
|
|
310
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
311
|
+
sambanova: () =>
|
|
312
|
+
Promise.all([
|
|
313
|
+
import("@lobehub/icons/es/SambaNova/components/Mono"),
|
|
314
|
+
import("@lobehub/icons/es/SambaNova/style"),
|
|
315
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
316
|
+
cerebras: () =>
|
|
317
|
+
Promise.all([
|
|
318
|
+
import("@lobehub/icons/es/Cerebras/components/Mono"),
|
|
319
|
+
import("@lobehub/icons/es/Cerebras/style"),
|
|
320
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
321
|
+
siliconcloud: () =>
|
|
322
|
+
Promise.all([
|
|
323
|
+
import("@lobehub/icons/es/SiliconCloud/components/Mono"),
|
|
324
|
+
import("@lobehub/icons/es/SiliconCloud/style"),
|
|
325
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
326
|
+
ollama: () =>
|
|
327
|
+
Promise.all([
|
|
328
|
+
import("@lobehub/icons/es/Ollama/components/Mono"),
|
|
329
|
+
import("@lobehub/icons/es/Ollama/style"),
|
|
330
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
331
|
+
lmstudio: () =>
|
|
332
|
+
Promise.all([
|
|
333
|
+
import("@lobehub/icons/es/LmStudio/components/Mono"),
|
|
334
|
+
import("@lobehub/icons/es/LmStudio/style"),
|
|
335
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
336
|
+
huggingface: () =>
|
|
337
|
+
Promise.all([
|
|
338
|
+
import("@lobehub/icons/es/HuggingFace/components/Mono"),
|
|
339
|
+
import("@lobehub/icons/es/HuggingFace/style"),
|
|
340
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
341
|
+
replicate: () =>
|
|
342
|
+
Promise.all([
|
|
343
|
+
import("@lobehub/icons/es/Replicate/components/Mono"),
|
|
344
|
+
import("@lobehub/icons/es/Replicate/style"),
|
|
345
|
+
]).then(([mono, style]) => ({ mono, style })),
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const _cache: Record<string, AvatarCtor | null> = {};
|
|
349
|
+
const _pending: Record<string, Promise<AvatarCtor | null>> = {};
|
|
350
|
+
|
|
351
|
+
async function get(key: string): Promise<AvatarCtor | null> {
|
|
352
|
+
if (key in _cache) return _cache[key] ?? null;
|
|
353
|
+
if (_pending[key]) return _pending[key];
|
|
354
|
+
const factory = MAP[key];
|
|
355
|
+
if (!factory) return null;
|
|
356
|
+
_pending[key] = factory()
|
|
357
|
+
.then(({ avatar, mono, style }) => {
|
|
358
|
+
const builtInAvatar = avatar?.default;
|
|
359
|
+
if (builtInAvatar) {
|
|
360
|
+
_cache[key] = builtInAvatar;
|
|
361
|
+
return builtInAvatar;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const Mono = mono?.default;
|
|
365
|
+
const comp = Mono && style ? createAvatarComponent(Mono, style) : null;
|
|
366
|
+
_cache[key] = comp;
|
|
367
|
+
return comp;
|
|
368
|
+
})
|
|
369
|
+
.catch(() => {
|
|
370
|
+
_cache[key] = null;
|
|
371
|
+
return null;
|
|
372
|
+
})
|
|
373
|
+
.finally(() => {
|
|
374
|
+
delete _pending[key];
|
|
375
|
+
});
|
|
376
|
+
return _pending[key];
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Returns a lobehub Avatar React component for the model/provider, or null.
|
|
381
|
+
* Caller should fall back to default bot icon when null is returned.
|
|
382
|
+
*/
|
|
383
|
+
export async function getModelAvatarComponent(
|
|
384
|
+
provider?: string,
|
|
385
|
+
model?: string,
|
|
386
|
+
cliProvider?: string
|
|
387
|
+
): Promise<AvatarCtor | null> {
|
|
388
|
+
const m = (model || "").toLowerCase();
|
|
389
|
+
const p = (provider || "").toLowerCase();
|
|
390
|
+
const cliProviderKey = (cliProvider || "").toLowerCase();
|
|
391
|
+
|
|
392
|
+
if (cliProviderKey === "gemini") return get("gemini");
|
|
393
|
+
if (cliProviderKey === "copilot") return get("copilot");
|
|
394
|
+
if (cliProviderKey === "codex") return get("openai");
|
|
395
|
+
if (cliProviderKey === "claude") return get("claude");
|
|
396
|
+
|
|
397
|
+
// ── 按 model 名称匹配(优先,处理 openrouter/deepinfra 等聚合场景) ──
|
|
398
|
+
if (m.includes("claude")) return get("claude");
|
|
399
|
+
if (m.includes("gpt") || /\bo\d[-/]/.test(m)) return get("openai");
|
|
400
|
+
if (m.includes("gemini") || m.includes("gemma")) return get("gemini");
|
|
401
|
+
if (m.includes("deepseek")) return get("deepseek");
|
|
402
|
+
if (m.includes("qwen")) return get("qwen");
|
|
403
|
+
if (m.includes("grok")) return get("grok");
|
|
404
|
+
if (m.includes("mistral") || m.includes("mixtral")) return get("mistral");
|
|
405
|
+
if (m.includes("llama") || m.includes("meta/")) return get("llama");
|
|
406
|
+
if (m.includes("kimi")) return get("kimi");
|
|
407
|
+
if (m.includes("moonshot")) return get("moonshot");
|
|
408
|
+
if (m.includes("minimax") || m.includes("abab")) return get("minimax");
|
|
409
|
+
if (m.includes("glm") || m.includes("chatglm")) return get("glm");
|
|
410
|
+
if (m.includes("doubao")) return get("doubao");
|
|
411
|
+
if (m.includes("hunyuan")) return get("hunyuan");
|
|
412
|
+
if (m.includes("ernie") || m.includes("wenxin")) return get("wenxin");
|
|
413
|
+
if (m.includes("baichuan")) return get("baichuan");
|
|
414
|
+
if (m.includes("yi-") || /^yi\d/.test(m)) return get("yi");
|
|
415
|
+
if (m.includes("internlm")) return get("internlm");
|
|
416
|
+
if (m.includes("spark")) return get("spark");
|
|
417
|
+
if (m.includes("step-") || m.startsWith("step")) return get("stepfun");
|
|
418
|
+
if (m.includes("sensenova") || m.includes("nova-")) return get("sensenova");
|
|
419
|
+
if (m.includes("tiangong")) return get("tiangong");
|
|
420
|
+
if (m.includes("skywork")) return get("skywork");
|
|
421
|
+
if (m.includes("perplexity")) return get("perplexity");
|
|
422
|
+
if (m.includes("command")) return get("cohere");
|
|
423
|
+
|
|
424
|
+
// ── 按 provider 匹配 ──────────────────────────────
|
|
425
|
+
const providerKey = p.replace(/[-_\s]/g, "").toLowerCase();
|
|
426
|
+
return (await get(providerKey)) ?? (await get(p)) ?? null;
|
|
427
|
+
}
|
package/ai/llm/models.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// ai/llm/models.ts
|
|
2
|
+
|
|
3
|
+
import type { Model } from "./types";
|
|
4
|
+
|
|
5
|
+
// 导入所有提供商的模型数据
|
|
6
|
+
import { deepSeekModels } from "integrations/deepseek/models";
|
|
7
|
+
import { googleModels } from "integrations/google/models";
|
|
8
|
+
import { openAIModels } from "integrations/openai/models";
|
|
9
|
+
import { deepinfraModels } from "./deepinfra";
|
|
10
|
+
import { openrouterModels } from "./openrouterModels";
|
|
11
|
+
import { fireworksModels } from "./fireworks";
|
|
12
|
+
import { mistralModels } from "./mistral";
|
|
13
|
+
import { mimoModels } from "./mimo";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @interface ModelWithProvider
|
|
17
|
+
* 扩展基础 Model 类型,增加了 provider 字段,用于UI显示和逻辑处理。
|
|
18
|
+
*/
|
|
19
|
+
export interface ModelWithProvider extends Model {
|
|
20
|
+
provider: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 将一组模型打上 provider 标记的纯函数,方便复用和测试
|
|
25
|
+
*/
|
|
26
|
+
const withProvider =
|
|
27
|
+
(provider: ModelWithProvider["provider"]) =>
|
|
28
|
+
(models: Model[]): ModelWithProvider[] =>
|
|
29
|
+
models.map((model) => ({ ...model, provider }));
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @const ALL_MODELS
|
|
33
|
+
* 聚合了所有来源的模型数据,并为每个模型附加了其提供商信息。
|
|
34
|
+
* 这是整个应用中模型选择器的唯一数据源。
|
|
35
|
+
*/
|
|
36
|
+
export const ALL_MODELS: ModelWithProvider[] = [
|
|
37
|
+
...withProvider("google")(googleModels),
|
|
38
|
+
...withProvider("openai")(openAIModels),
|
|
39
|
+
...withProvider("openrouter")(openrouterModels),
|
|
40
|
+
...withProvider("deepseek")(deepSeekModels),
|
|
41
|
+
...withProvider("deepinfra")(deepinfraModels),
|
|
42
|
+
...withProvider("fireworks")(fireworksModels),
|
|
43
|
+
...withProvider("mistral")(mistralModels),
|
|
44
|
+
...withProvider("mimo")(mimoModels),
|
|
45
|
+
];
|