Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump prompt-tsx #67

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
"unzipper": "^0.12.3"
},
"dependencies": {
"@vscode/prompt-tsx": "^0.3.0-alpha.10",
"@vscode/prompt-tsx": "^0.3.0-alpha.12",
"sanitize-filename": "^1.6.3"
}
}
4 changes: 2 additions & 2 deletions src/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class ToolCalls extends PromptElement<ToolCallsProps, void> {
}

private async _renderOneRound(round: ToolCallRound, sizing: PromptSizing, toolInvocationToken: vscode.ChatParticipantToolToken | undefined): Promise<{ promptPiece: PromptPiece, hasError: boolean, size: number }> {
const assistantToolCalls: ToolCall[] = round.toolCalls.map(tc => ({ type: 'function', function: { name: tc.name, arguments: JSON.stringify(tc.parameters) }, id: tc.callId }));
const assistantToolCalls: ToolCall[] = round.toolCalls.map(tc => ({ type: 'function', function: { name: tc.name, arguments: JSON.stringify(tc.input) }, id: tc.callId }));

const toolCallIds = round.toolCalls
.map((call) => call.name)
Expand Down Expand Up @@ -445,7 +445,7 @@ class ToolCalls extends PromptElement<ToolCallsProps, void> {
const toolResult = await vscode.lm.invokeTool(
tool.name,
{
parameters: toolCall.parameters,
input: toolCall.input,
toolInvocationToken: toolInvocationToken,
tokenizationOptions: {
tokenBudget: sizing.tokenBudget,
Expand Down
3 changes: 1 addition & 2 deletions src/dataAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ export class DataAgent implements vscode.Disposable {
const allTools = vscode.lm.tools.map((tool): vscode.LanguageModelChatTool => {
return {
name: tool.name,
description: tool.description,
parametersSchema: tool.parametersSchema ?? {}
description: tool.description
};
});

Expand Down
4 changes: 2 additions & 2 deletions src/exportCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import * as fs from 'fs';
import { EOL } from 'os';
import { unescape } from 'querystring';
import sanitize from 'sanitize-filename';
import { promisify } from 'util';
import { CancellationToken, ChatContext, ChatRequest, ChatResponseMarkdownPart, ChatResponseStream, ChatResponseTurn, ExtensionContext, l10n, NotebookCellData, NotebookCellKind, NotebookCellOutput, NotebookData, ThemeIcon, Uri, window, workspace } from "vscode";
import { getToolResultValue, isErrorMessageResponse, TsxToolUserMetadata } from "./base";
import { logger } from "./logger";
import { uint8ArrayToBase64 } from "./platform/common/string";
import { RunPythonTool } from "./tools";
import sanitize from 'sanitize-filename';

const JupyterNotebookView = 'jupyter-notebook';
// enum CellOutputMimeTypes {
Expand Down Expand Up @@ -104,7 +104,7 @@ export class JupyterNotebookExporter {
return;
}

const parameters = tool.parameters as { code: string; reason: string };
const parameters = tool.input as { code: string; reason: string };
if (!parameters.code && !parameters.reason) {
logger.warn(`Ignoring tool call as code & reason are empty`);
return;
Expand Down
4 changes: 2 additions & 2 deletions src/test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ suite('Extension Test Suite', () => {
let code = '';
if (Array.isArray(toolcall)) {
for (const call of toolcall) {
code = (call.toolCalls.find(t => t.name === RunPythonTool.Id)!.parameters as any)!.code;
code = (call.toolCalls.find(t => t.name === RunPythonTool.Id)!.input as any)!.code;
if (code) {
const fragments = expectedCode.slice();
const found = fragments.filter(fragment => code.toLowerCase().includes(fragment.toLowerCase()));
Expand All @@ -110,7 +110,7 @@ suite('Extension Test Suite', () => {
}
assert.fail(`Code ${expectedCode.join(', ')} not found in toolcall`);
} else {
code = (toolcall.toolCalls.find(t => t.name === RunPythonTool.Id)!.parameters as any)!.code;
code = (toolcall.toolCalls.find(t => t.name === RunPythonTool.Id)!.input as any)!.code;
assert.isOk(code);
for (const fragment of expectedCode) {
assert.include(code.toLowerCase(), fragment.toLowerCase());
Expand Down
10 changes: 5 additions & 5 deletions src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class FindFilesTool implements vscode.LanguageModelTool<IFindFilesParamet
options: vscode.LanguageModelToolInvocationOptions<IFindFilesParameters>,
token: vscode.CancellationToken
) {
const params = options.parameters as IFindFilesParameters;
const params = options.input as IFindFilesParameters;
let files = await vscode.workspace.findFiles(params.pattern, '**/node_modules/**', undefined, token);
if (files.length === 0) {
files = await vscode.workspace.findFiles(`**/${params.pattern}`, '**/node_modules/**', undefined, token);
Expand All @@ -46,7 +46,7 @@ export class FindFilesTool implements vscode.LanguageModelTool<IFindFilesParamet
_token: vscode.CancellationToken
) {
return {
invocationMessage: `Searching workspace for "${options.parameters.pattern}"`
invocationMessage: `Searching workspace for "${options.input.pattern}"`
};
}
}
Expand Down Expand Up @@ -87,8 +87,8 @@ export class RunPythonTool implements vscode.LanguageModelTool<IRunPythonParamet
options: vscode.LanguageModelToolInvocationOptions<IRunPythonParameters>,
_token: vscode.CancellationToken
) {
const code = sanitizePythonCode(options.parameters.code);
logger.debug(`Executing Python Code for "${options.parameters.reason}"`);
const code = sanitizePythonCode(options.input.code);
logger.debug(`Executing Python Code for "${options.input.reason}"`);
logger.debug(`Code => `);
logger.debug(code);

Expand Down Expand Up @@ -121,7 +121,7 @@ export class RunPythonTool implements vscode.LanguageModelTool<IRunPythonParamet
options: vscode.LanguageModelToolInvocationPrepareOptions<IRunPythonParameters>,
_token: vscode.CancellationToken
) {
const reasonMessage = options.parameters.reason ? `: "${options.parameters.reason}"` : '';
const reasonMessage = options.input.reason ? `: "${options.input.reason}"` : '';
return {
invocationMessage: `Executing Code${reasonMessage}`
};
Expand Down