Skip to content
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
6 changes: 4 additions & 2 deletions extensions/positron-assistant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@
"modelDescription": "View the current active plot if one exists. Don't invoke this tool if there are no plots in the session.",
"canBeReferencedInPrompt": false,
"tags": [
"positron-assistant"
"positron-assistant",
"requires-session"
]
},
{
Expand Down Expand Up @@ -390,7 +391,8 @@
]
},
"tags": [
"positron-assistant"
"positron-assistant",
"requires-session"
]
},
{
Expand Down
21 changes: 17 additions & 4 deletions extensions/positron-assistant/src/participants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,26 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
const positronContext = await positron.ai.getPositronChatContext(request);
log.debug(`[context] Positron context for request ${request.id}:\n${JSON.stringify(positronContext, null, 2)}`);

// Build a list of languages for which we have active sessions.
//
// See IChatRuntimeSessionContext for the structure of the active
// session context objects
const activeSessions: Set<string> = new Set();
let hasVariables = false;
let hasConsoleSessions = false;
for (const reference of request.references) {
const value = reference.value as any;

// Build a list of languages for which we have active sessions.
if (value.activeSession) {
activeSessions.add(value.activeSession.languageId);
if (value.activeSession.mode === positron.LanguageRuntimeSessionMode.Console) {
hasConsoleSessions = true;
}
}

// Check if there are variables defined in the session.
if (value.variables && value.variables.length > 0) {
hasVariables = true;
}
}

// List of tools for use by the language model.
Expand Down Expand Up @@ -274,9 +280,16 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
return inChatPane && (isEditMode || isAgentMode);
// Only include the getTableSummary tool for Python sessions until supported in R
case PositronAssistantToolName.GetTableSummary:
// TODO: Remove this restriction when the tool is supported in R https://github.com/posit-dev/positron/issues/8343
// TODO: Remove the python-specific restriction when the tool is supported in R https://github.com/posit-dev/positron/issues/8343
// The logic above with TOOL_TAG_REQUIRES_ACTIVE_SESSION will handle checking for active sessions once this is removed.
return activeSessions.has('python');
// We'll still want to check that variables are defined.
return activeSessions.has('python') && hasVariables;
// Only include the getPlot tool if there is a plot available.
case PositronAssistantToolName.GetPlot:
return positronContext.plots?.hasPlots === true;
// Only include the inspectVariables tool if there are variables defined.
case PositronAssistantToolName.InspectVariables:
return hasVariables;
// Otherwise, include the tool if it is tagged for use with Positron Assistant.
// Allow all tools in Agent mode.
default:
Expand Down
Loading