Skip to content
Draft
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: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,15 @@
},
"when": "false"
}
],
"chatParticipants": [
{
"id": "jupyter.jupyterAgent",
"fullName": "Jupyter",
"name": "jupyter",
"description": "%jupyter.chatParticipant.description%",
"isSticky": true
}
]
},
"enabledApiProposals": [
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,6 @@
"jupyter.languageModelTools.configure_notebook.displayName": "Configure Jupyter Notebook",
"jupyter.languageModelTools.configure_notebook.userDescription": "Ensure Notebook is ready for use, such as running cells.",
"jupyter.languageModelTools.notebook_list_packages.userDescription": "Lists Python packages available in the selected Notebook Kernel.",
"jupyter.languageModelTools.notebook_install_packages.userDescription": "Installs Python packages in the selected Notebook Kernel."
"jupyter.languageModelTools.notebook_install_packages.userDescription": "Installs Python packages in the selected Notebook Kernel.",
"jupyter.chatParticipant.description": "Ask questions about Jupyter notebooks, kernels, and data science in VS Code."
}
54 changes: 54 additions & 0 deletions src/standalone/chat/agent.node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import * as vscode from 'vscode';
import { logger } from '../../platform/logging';

const JUPYTER_AGENT_ID = 'jupyter.jupyterAgent';

/**
* Creates and registers a Jupyter chat participant (agent) that can handle
* user requests for Jupyter notebook assistance.
*/
export function registerJupyterChatAgent(context: vscode.ExtensionContext): void {
const agent = vscode.chat.createChatParticipant(JUPYTER_AGENT_ID, handleChatRequest);
agent.iconPath = new vscode.ThemeIcon('notebook');

context.subscriptions.push(agent);
logger.info('Jupyter Chat Agent registered');
}

/**
* Handles incoming chat requests to the Jupyter agent.
*/
async function handleChatRequest(
_request: vscode.ChatRequest,
_context: vscode.ChatContext,
stream: vscode.ChatResponseStream,
token: vscode.CancellationToken
): Promise<vscode.ChatResult | undefined> {
if (token.isCancellationRequested) {
return undefined;
}

try {
// Stream a response to the user
stream.markdown(`I'm the Jupyter assistant. I can help you work with Jupyter notebooks.\n\n`);
stream.markdown(
`I can assist with:\n` +
`- Configuring notebooks and kernels\n` +
`- Installing packages in notebook kernels\n` +
`- Listing installed packages\n` +
`- Restarting kernels\n\n`
);
stream.markdown(`To get started, open a Jupyter notebook and I'll help you configure and work with it.`);

return {};
} catch (error) {
logger.error('Error handling Jupyter chat request', error);
stream.markdown(
`An error occurred while processing your request. Please check your input and try again, or report an issue if the problem persists.`
);
return undefined;
}
}
4 changes: 4 additions & 0 deletions src/standalone/chat/extension.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ import { ConfigurePythonNotebookTool } from './configureNotebook.python.node';
import { ConfigureNonPythonNotebookTool } from './configureNotebook.other.node';
import { RestartKernelTool } from './restartKernelTool.node';
import { INotebookCommandHandler } from '../../notebooks/notebookCommandListener';
import { registerJupyterChatAgent } from './agent.node';

export async function activate(context: vscode.ExtensionContext, serviceContainer: IServiceContainer): Promise<void> {
// Register the Jupyter Chat Agent
registerJupyterChatAgent(context);

context.subscriptions.push(
vscode.lm.registerTool(
InstallPackagesTool.toolName,
Expand Down