MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / write_json

Function write_json

ui/src/utils/chat.ts:52–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50 }
51
52 const write_json = async () => {
53 try {
54 while (true) {
55 const { done, value } = await reader.read()
56
57 if (done) {
58 const result_block = JSON.parse(tempResult)
59 if (result_block.code === 500) {
60 return Promise.reject(result_block.message)
61 } else {
62 if (result_block.content) {
63 ChatManagement.append(chat.id, result_block.content)
64 }
65 }
66 ChatManagement.close(chat.id)
67 return
68 }
69
70 if (value) {
71 const decoder = new TextDecoder('utf-8')
72 tempResult += decoder.decode(value)
73 }
74 }
75 } catch (e) {
76 return Promise.reject(e)
77 }
78 }
79
80 return stream ? write_stream : write_json
81}

Callers

nothing calls this directly

Calls 5

readMethod · 0.80
decodeMethod · 0.80
parseMethod · 0.45
appendMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected