MCPcopy
hub / github.com/OpenBMB/ChatDev / postYaml

Function postYaml

frontend/src/utils/apiFunctions.js:17–67  ·  view source on GitHub ↗
(filename, content)

Source from the content-addressed store, hash-verified

15
16// Upload a YAML file
17export async function postYaml(filename, content) {
18 try {
19 const fullFilename = addYamlSuffix(filename)
20 const response = await fetch(apiUrl('/api/workflows/upload/content'), {
21 method: 'POST',
22 headers: {
23 'Content-Type': 'application/json',
24 },
25 body: JSON.stringify({
26 filename: fullFilename,
27 content: content
28 })
29 })
30
31 // Return 400 when content is invalid
32 if (response.ok || response.status === 400) {
33 const data = await response.json()
34
35 // If status is missing, content validation failed and detail contains the error
36 if (data.status) {
37 return {
38 success: true,
39 message: 'YAML file saved successfully!'
40 }
41 } else if (data.detail) {
42 return {
43 success: false,
44 detail: data.detail
45 }
46 } else {
47 return {
48 success: false,
49 message: 'Unknown error saving YAML file'
50 }
51 }
52 } else {
53 const errorData = await response.json().catch(() => ({}))
54 console.error('Error saving YAML file:', errorData)
55 return {
56 success: false,
57 message: `Error saving YAML file: ${errorData.message || response.statusText}`
58 }
59 }
60 } catch (error) {
61 console.error('Error saving YAML file:', error)
62 return {
63 success: false,
64 message: 'API error'
65 }
66 }
67}
68
69export async function updateYaml(filename, content) {
70 try {

Callers

nothing calls this directly

Calls 3

addYamlSuffixFunction · 0.85
apiUrlFunction · 0.85
errorMethod · 0.45

Tested by

no test coverage detected