MCPcopy Create free account
hub / github.com/echoVic/blade-code / generateExample

Method generateExample

src/tools/format-converter.ts:203–226  ·  view source on GitHub ↗

* 生成工具调用示例

(tool: OpenAITool)

Source from the content-addressed store, hash-verified

201 * 生成工具调用示例
202 */
203 static generateExample(tool: OpenAITool): string {
204 const params = tool.function.parameters;
205 const properties = params?.properties || {};
206 const required = params?.required || [];
207
208 const exampleParams: any = {};
209
210 // 为必需参数生成示例值
211 for (const paramName of required) {
212 const paramSchema = properties[paramName];
213 if (paramSchema) {
214 exampleParams[paramName] = this.generateExampleValue(paramSchema);
215 }
216 }
217
218 return JSON.stringify(
219 {
220 name: tool.function.name,
221 arguments: exampleParams,
222 },
223 null,
224 2
225 );
226 }
227
228 /**
229 * 根据参数模式生成示例值

Callers 1

Calls 1

generateExampleValueMethod · 0.95

Tested by

no test coverage detected