MCPcopy Index your code
hub / github.com/deepnote/deepnote / messageToOutput

Method messageToOutput

packages/runtime-core/src/kernel-client.ts:195–238  ·  view source on GitHub ↗

* Convert a Jupyter message to an IOutput object.

(msg: { header: { msg_type: string }; content: unknown })

Source from the content-addressed store, hash-verified

193 * Convert a Jupyter message to an IOutput object.
194 */
195 private messageToOutput(msg: { header: { msg_type: string }; content: unknown }): IOutput {
196 const msgType = msg.header.msg_type
197 const content = msg.content as Record<string, unknown>
198
199 switch (msgType) {
200 case 'stream':
201 return {
202 output_type: 'stream',
203 name: content.name as 'stdout' | 'stderr',
204 text: content.text as string,
205 }
206
207 case 'execute_result':
208 return {
209 output_type: 'execute_result',
210 data: content.data as IExecuteResult['data'],
211 metadata: (content.metadata ?? {}) as IExecuteResult['metadata'],
212 execution_count: content.execution_count as number,
213 }
214
215 case 'display_data':
216 return {
217 output_type: 'display_data',
218 data: content.data as IDisplayData['data'],
219 metadata: (content.metadata ?? {}) as IDisplayData['metadata'],
220 }
221
222 case 'error':
223 return {
224 output_type: 'error',
225 ename: content.ename as string,
226 evalue: content.evalue as string,
227 traceback: content.traceback as string[],
228 }
229
230 default:
231 return {
232 output_type: 'error',
233 ename: 'UnknownMsgType',
234 evalue: `Received unknown message type: ${msgType}`,
235 traceback: [],
236 }
237 }
238 }
239}

Callers 1

executeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected