MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / fetchWorkflowsWithDesc

Function fetchWorkflowsWithDesc

frontend/src/utils/apiFunctions.js:188–232  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

186
187// Load the YAML file list from the API with names and descriptions
188export async function fetchWorkflowsWithDesc() {
189 try {
190 const response = await fetch(apiUrl('/api/workflows'))
191 if (!response.ok) {
192 throw new Error(`/api/workflows fetch error, status: ${response.status}`)
193 }
194 const data = await response.json()
195
196 // Fetch YAML descriptions by filename
197 const filesWithDesc = await Promise.all(
198 data.workflows.map(async (filename) => {
199 try {
200 const response = await fetch(apiUrl(`/api/workflows/${encodeURIComponent(filename)}/desc`))
201 const fileData = await response.json()
202 return {
203 name: filename,
204 description: getYAMLDescription(fileData.content)
205 }
206 } catch {
207 return { name: filename, description: 'No description' }
208 }
209 })
210 )
211
212 return {
213 success: true,
214 workflows: filesWithDesc
215 }
216 } catch (err) {
217 console.error('Failed to load YAML files:', err)
218 return {
219 success: false,
220 error: 'Failure loading YAML files, please run API service'
221 }
222 }
223
224 function getYAMLDescription(content) {
225 try {
226 const doc = yaml.load(content)
227 return doc.graph.description || 'No description'
228 } catch {
229 return 'No description'
230 }
231 }
232}
233
234// Fetch YAML file content
235export async function fetchWorkflowYAML(filename) {

Callers

nothing calls this directly

Calls 3

apiUrlFunction · 0.85
getYAMLDescriptionFunction · 0.85
errorMethod · 0.45

Tested by

no test coverage detected