MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / invoke

Function invoke

src/standalone/chat/helper.ts:51–89  ·  view source on GitHub ↗
(options: LanguageModelToolInvocationOptions<T>, token: CancellationToken)

Source from the content-addressed store, hash-verified

49 constructor(private readonly toolName: string) {}
50
51 public async invoke(options: LanguageModelToolInvocationOptions<T>, token: CancellationToken) {
52 if (!workspace.isTrusted) {
53 return new LanguageModelToolResult([
54 new LanguageModelTextPart('Cannot use this tool in an untrusted workspace.')
55 ]);
56 }
57
58 let error: Error | undefined;
59 let notebookUri: Uri | undefined;
60 try {
61 const notebook = await resolveNotebookFromFilePath(options.input.filePath);
62 return await this.invokeImpl(options, notebook, token);
63 } catch (ex) {
64 error = ex;
65 throw ex;
66 } finally {
67 const isCancelled = token.isCancellationRequested || (error ? isCancellationError(error, true) : false);
68 const failed = !!error || isCancelled ? 'true' : 'false';
69 const failureCategory = isCancelled
70 ? 'cancelled'
71 : error
72 ? error instanceof BaseError
73 ? error.category
74 : 'error'
75 : undefined;
76 const resourceHash = notebookUri
77 ? // eslint-disable-next-line local-rules/dont-use-fspath
78 getTelemetrySafeHashedString(notebookUri.fsPath)
79 : Promise.resolve(undefined);
80 void resourceHash.then((resourceHash) => {
81 sendTelemetryEvent(Telemetry.InvokeTool, undefined, {
82 toolName: this.toolName,
83 resourceHash,
84 failed,
85 failureCategory
86 });
87 });
88 }
89 }
90
91 async prepareInvocation(
92 options: LanguageModelToolInvocationPrepareOptions<T>,

Callers

nothing calls this directly

Calls 6

isCancellationErrorFunction · 0.90
sendTelemetryEventFunction · 0.90
resolveMethod · 0.65
invokeImplMethod · 0.45

Tested by

no test coverage detected