MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / forceFullModelDetailsLoad

Function forceFullModelDetailsLoad

src/api/providers/fetchers/lmstudio.ts:12–35  ·  view source on GitHub ↗
(baseUrl: string, modelId: string)

Source from the content-addressed store, hash-verified

10export const hasLoadedFullDetails = (modelId: string): boolean => modelsWithLoadedDetails.has(modelId)
11
12export const forceFullModelDetailsLoad = async (baseUrl: string, modelId: string): Promise<void> => {
13 try {
14 // Test the connection to LM Studio first
15 // Crrors will be caught further down.
16 await axios.get(`${baseUrl}/v1/models`)
17 const lmsUrl = baseUrl.replace(/^http:\/\//, "ws://").replace(/^https:\/\//, "wss://")
18
19 const client = new LMStudioClient({ baseUrl: lmsUrl })
20 await client.llm.model(modelId)
21 // Flush and refresh cache to get updated model details
22 await flushModels({ provider: "lmstudio", baseUrl }, true)
23
24 // Mark this model as having full details loaded.
25 modelsWithLoadedDetails.add(modelId)
26 } catch (error) {
27 if (error.code === "ECONNREFUSED") {
28 console.warn(`Error connecting to LMStudio at ${baseUrl}`)
29 } else {
30 console.error(
31 `Error refreshing LMStudio model details: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
32 )
33 }
34 }
35}
36
37export const parseLMStudioModel = (rawModel: LLMInstanceInfo | LLMInfo): ModelInfo => {
38 // Handle both LLMInstanceInfo (from loaded models) and LLMInfo (from downloaded models)

Callers 1

Calls 5

flushModelsFunction · 0.90
getMethod · 0.65
replaceMethod · 0.65
warnMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected