MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / summarizeChartForModel

Function summarizeChartForModel

packages/tools/src/definitions/render-chart.ts:101–120  ·  view source on GitHub ↗
(
  type: string,
  title: string,
  rows: Record<string, unknown>[],
  truncated: boolean,
  locale?: string
)

Source from the content-addressed store, hash-verified

99}
100
101function summarizeChartForModel(
102 type: string,
103 title: string,
104 rows: Record<string, unknown>[],
105 truncated: boolean,
106 locale?: string
107): string {
108 const summary = summarizeChart(type, title, rows.length, truncated, locale)
109 const previewRows = rows.slice(0, DEFAULT_PREVIEW_ROWS)
110 const coverage = locale?.startsWith('zh')
111 ? `图表已使用${truncated ? '截断后的' : '全部'} ${rows.length} 行数据生成;下面只是数据预览,不要为了查看预览外的行重复调用 render_chart。`
112 : `The chart already uses ${truncated ? 'the truncated' : 'all'} ${rows.length} rows; the rows below are only a preview. Do not call render_chart again just to inspect rows outside the preview.`
113 if (previewRows.length === 0) return `${summary}\n${coverage}`
114
115 const preview = JSON.stringify(previewRows)
116 if (locale?.startsWith('zh')) {
117 return `${summary}\n${coverage}\n数据预览(前 ${previewRows.length} 行,用于分析峰值、低谷和差异):${preview}`
118 }
119 return `${summary}\n${coverage}\nData preview (first ${previewRows.length} rows; use this to identify peaks, lows, and differences): ${preview}`
120}
121
122async function handler(params: Record<string, unknown>, context: ToolExecutionContext): Promise<ToolResult> {
123 if (!context.dataProvider) throw new Error('render_chart requires a data provider')

Callers 1

handlerFunction · 0.85

Calls 1

summarizeChartFunction · 0.85

Tested by

no test coverage detected