MCPcopy Create free account
hub / github.com/aetherstate/GODMOD3.AI / fetchFileList

Function fetchFileList

api/lib/hf-reader.ts:103–125  ·  view source on GitHub ↗
(prefix?: string)

Source from the content-addressed store, hash-verified

101// ── Core: List Files in HF Repo ──────────────────────────────────────
102
103async function fetchFileList(prefix?: string): Promise<HFFileEntry[]> {
104 const { token, repo, branch } = getConfig()
105 if (!token || !repo) return []
106
107 const path = prefix ? `/${prefix}` : ''
108 const url = `${HF_API}/datasets/${repo}/tree/${branch}${path}`
109
110 try {
111 const res = await fetch(url, {
112 headers: { 'Authorization': `Bearer ${token}` },
113 })
114
115 if (!res.ok) {
116 console.error(`[HF Reader] List failed (${res.status}): ${await res.text().catch(() => '')}`)
117 return []
118 }
119
120 return await res.json() as HFFileEntry[]
121 } catch (err) {
122 console.error(`[HF Reader] Network error listing files:`, (err as Error).message)
123 return []
124 }
125}
126
127export async function listBatchFiles(forceRefresh = false): Promise<BatchInfo[]> {
128 const now = Date.now()

Callers 1

listBatchFilesFunction · 0.85

Calls 1

getConfigFunction · 0.70

Tested by

no test coverage detected