MCPcopy Create free account
hub / github.com/experdot/pointer / createLLMConfig

Function createLLMConfig

src/renderer/src/services/settingsService.ts:42–74  ·  view source on GitHub ↗
(
  data: Omit<LLMConfig, 'id' | 'createdAt' | 'order' | 'parentFolderId'>,
  afterItemId?: string,
  inFolderId?: string
)

Source from the content-addressed store, hash-verified

40// ==================== LLM 配置 ====================
41
42export function createLLMConfig(
43 data: Omit<LLMConfig, 'id' | 'createdAt' | 'order' | 'parentFolderId'>,
44 afterItemId?: string,
45 inFolderId?: string
46): LLMConfig {
47 const { settings } = stores
48 let parentFolderId: string | undefined
49 let order: number
50
51 if (inFolderId) {
52 parentFolderId = inFolderId
53 const itemsInFolder = [
54 ...settings.settings.llmConfigs.items.filter((i) => i.parentFolderId === inFolderId),
55 ...settings.settings.llmConfigs.folders.filter((f) => f.parentFolderId === inFolderId)
56 ]
57 order = itemsInFolder.length > 0 ? Math.max(...itemsInFolder.map((i) => i.order ?? 0)) + 1 : 0
58 } else {
59 const position = prepareInsertPosition(settings.settings.llmConfigs, afterItemId)
60 parentFolderId = position.parentFolderId
61 order = position.order
62 }
63
64 const config: LLMConfig = {
65 ...data,
66 id: uuidv4(),
67 parentFolderId,
68 order,
69 createdAt: Date.now()
70 }
71
72 settings.addLLMConfig(config)
73 return config
74}
75
76export function updateLLMConfig(id: string, updates: Partial<LLMConfig>): void {
77 stores.settings.updateLLMConfig(id, updates)

Callers 1

copyLLMConfigFunction · 0.85

Calls 2

addLLMConfigMethod · 0.80
prepareInsertPositionFunction · 0.70

Tested by

no test coverage detected