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

Function postYamlCopy

frontend/src/utils/apiFunctions.js:148–185  ·  view source on GitHub ↗
(filename, newFilename)

Source from the content-addressed store, hash-verified

146
147// Copy YAML file
148export async function postYamlCopy(filename, newFilename) {
149 try {
150 const yamlFilename = addYamlSuffix(filename)
151 const yamlNewFilename = addYamlSuffix(newFilename)
152 const response = await fetch(apiUrl(`/api/workflows/${encodeURIComponent(yamlFilename)}/copy`), {
153 method: 'POST',
154 headers: {
155 'Content-Type': 'application/json',
156 },
157 body: JSON.stringify({
158 new_filename: yamlNewFilename
159 })
160 })
161
162 const data = await response.json().catch(() => ({}))
163
164 if (response.ok) {
165 return {
166 success: true,
167 filename: data?.filename || yamlNewFilename,
168 message: data?.message || 'Workflow copied successfully'
169 }
170 }
171
172 return {
173 success: false,
174 detail: data?.detail,
175 message: data?.message || 'Failed to copy workflow',
176 status: response.status
177 }
178 } catch (error) {
179 console.error('Error copying workflow YAML:', error)
180 return {
181 success: false,
182 message: 'API error'
183 }
184 }
185}
186
187// Load the YAML file list from the API with names and descriptions
188export async function fetchWorkflowsWithDesc() {

Callers

nothing calls this directly

Calls 3

addYamlSuffixFunction · 0.85
apiUrlFunction · 0.85
errorMethod · 0.45

Tested by

no test coverage detected