Skip to content
Open
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
1,094 changes: 770 additions & 324 deletions extensions/positron-assistant/package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions extensions/positron-assistant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1012,21 +1012,21 @@
"postinstall": "ts-node scripts/post-install.ts"
},
"devDependencies": {
"@ai-sdk/amazon-bedrock": "2.2.12",
"@ai-sdk/anthropic": "^1.0.5",
"@ai-sdk/azure": "^1.1.9",
"@ai-sdk/google": "^1.1.17",
"@ai-sdk/google-vertex": "^2.1.8",
"@ai-sdk/mistral": "^1.1.6",
"@ai-sdk/openai": "^1.0.8",
"@ai-sdk/amazon-bedrock": "^3.0.65",
"@ai-sdk/anthropic": "^2.0.53",
"@ai-sdk/azure": "^2.0.78",
"@ai-sdk/google": "^2.0.44",
"@ai-sdk/google-vertex": "^3.0.85",
"@ai-sdk/mistral": "^2.0.25",
"@ai-sdk/openai": "^2.0.76",
"@aws-sdk/credential-providers": "^3.734.0",
"@eslint/js": "^9.13.0",
"@openrouter/ai-sdk-provider": "^0.0.6",
"@openrouter/ai-sdk-provider": "^1.3.0",
"@stylistic/eslint-plugin": "^2.9.0",
"@types/mocha": "^9.1.0",
"@types/node": "^20",
"@types/sinon": "^17.0.3",
"ai": "^4.3.19",
"ai": "^5.0.106",
"eslint": "^9.13.0",
"google-auth-library": "^9.15.1",
"mocha": "^9.2.1",
Expand Down
4 changes: 2 additions & 2 deletions extensions/positron-assistant/src/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class AnthropicLanguageModel implements positron.ai.LanguageModelChatProv

async provideLanguageModelChatInformation(_options: { silent: boolean }, token: vscode.CancellationToken): Promise<vscode.LanguageModelChatInformation[]> {
log.debug(`[${this.providerName}] Preparing language model chat information...`);
const models = await this.resolveModels(token) ?? [];
const models = (await this.resolveModels(token)) ?? [];

log.debug(`[${this.providerName}] Resolved ${models.length} models.`);
return this.filterModels(models);
Expand Down Expand Up @@ -122,7 +122,7 @@ export class AnthropicLanguageModel implements positron.ai.LanguageModelChatProv

const body: Anthropic.MessageStreamParams = {
model: model.id,
max_tokens: options.modelOptions?.maxTokens ?? this.maxOutputTokens,
max_tokens: options.modelOptions?.maxOutputTokens ?? this.maxOutputTokens,
tools,
tool_choice,
system,
Expand Down
24 changes: 12 additions & 12 deletions extensions/positron-assistant/src/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class OpenAILegacyCompletion extends CompletionModel {
token: vscode.CancellationToken
): Promise<vscode.InlineCompletionItem[] | vscode.InlineCompletionList> {
// Check if the file should be excluded from AI features
if (!await positron.ai.areCompletionsEnabled(document.uri)) {
if (!(await positron.ai.areCompletionsEnabled(document.uri))) {
return [];
}

Expand Down Expand Up @@ -376,7 +376,7 @@ class VertexLegacyCompletion extends MistralCompletion {
// (Anthropic, OpenAI, Bedrock, OpenRouter, Gemini, Azure)

abstract class FimPromptCompletion extends CompletionModel {
protected abstract model: ai.LanguageModelV1;
protected abstract model: ai.LanguageModel;

async provideInlineCompletionItems(
document: vscode.TextDocument,
Expand All @@ -385,7 +385,7 @@ abstract class FimPromptCompletion extends CompletionModel {
token: vscode.CancellationToken
): Promise<vscode.InlineCompletionItem[] | vscode.InlineCompletionList> {
// Check if the file should be excluded from AI features
if (!await positron.ai.areCompletionsEnabled(document.uri)) {
if (!(await positron.ai.areCompletionsEnabled(document.uri))) {
return [];
}

Expand All @@ -412,7 +412,7 @@ abstract class FimPromptCompletion extends CompletionModel {
messages: [
{ role: 'user', content: `${relatedText}\n<|file_separator|>${document.fileName}\n<|fim_prefix|>${prefix}<|fim_suffix|>${suffix}\n<|fim_middle|>` }
],
maxTokens: 128,
maxOutputTokens: 128,
temperature: 0.2,
stopSequences: ['\n\n', '<|fim_prefix|>', '<|fim_suffix|>', '<|file_separator|>'],
abortSignal: signal,
Expand Down Expand Up @@ -500,7 +500,7 @@ class OpenAICompatibleCompletion extends OpenAICompletion {
}

class OpenRouterCompletion extends FimPromptCompletion {
protected model: ai.LanguageModelV1;
protected model: ai.LanguageModel;

static source: positron.ai.LanguageModelSource = {
type: positron.PositronLanguageModelType.Completion,
Expand All @@ -526,7 +526,7 @@ class OpenRouterCompletion extends FimPromptCompletion {
}

class AWSCompletion extends FimPromptCompletion {
protected model: ai.LanguageModelV1;
protected model: ai.LanguageModel;

static source: positron.ai.LanguageModelSource = {
type: positron.PositronLanguageModelType.Completion,
Expand All @@ -544,15 +544,15 @@ class AWSCompletion extends FimPromptCompletion {
constructor(_config: ModelConfig) {
super(_config);

// Cast to ai.LanguageModelV1 to satisfy base class type
// Cast to ai.LanguageModel to satisfy base class type
this.model = createAmazonBedrock({
credentialProvider: fromNodeProviderChain(),
})(this._config.model) as unknown as ai.LanguageModelV1;
})(this._config.model) as unknown as ai.LanguageModel;
}
}

class VertexCompletion extends FimPromptCompletion {
protected model: ai.LanguageModelV1;
protected model: ai.LanguageModel;

static source: positron.ai.LanguageModelSource = {
type: positron.PositronLanguageModelType.Completion,
Expand All @@ -579,7 +579,7 @@ class VertexCompletion extends FimPromptCompletion {
}

class GoogleCompletion extends FimPromptCompletion {
protected model: ai.LanguageModelV1;
protected model: ai.LanguageModel;

static source: positron.ai.LanguageModelSource = {
type: positron.PositronLanguageModelType.Completion,
Expand All @@ -606,7 +606,7 @@ class GoogleCompletion extends FimPromptCompletion {
}

class AzureCompletion extends FimPromptCompletion {
protected model: ai.LanguageModelV1;
protected model: ai.LanguageModel;

static source: positron.ai.LanguageModelSource = {
type: positron.PositronLanguageModelType.Completion,
Expand Down Expand Up @@ -663,7 +663,7 @@ export class CopilotCompletion implements vscode.InlineCompletionItemProvider {
token: vscode.CancellationToken
): Promise<vscode.InlineCompletionItem[] | vscode.InlineCompletionList | undefined> {
// Check if the file should be excluded from AI features
if (!await positron.ai.areCompletionsEnabled(document.uri)) {
if (!(await positron.ai.areCompletionsEnabled(document.uri))) {
return [];
}
return await this._copilotService.inlineCompletion(document, position, context, token);
Expand Down
5 changes: 4 additions & 1 deletion extensions/positron-assistant/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,7 @@ export const DEFAULT_MAX_CONNECTION_ATTEMPTS = 3;
/**
* Determines if the Posit Web environment is detected.
*/
export const IS_RUNNING_ON_PWB = !!process.env.RS_SERVER_URL && vscode.env.uiKind === vscode.UIKind.Web;
export const IS_RUNNING_ON_PWB = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing code left in!

Suggested change
export const IS_RUNNING_ON_PWB = true;
export const IS_RUNNING_ON_PWB = !!process.env.RS_SERVER_URL && vscode.env.uiKind === vscode.UIKind.Web;


/** The default max steps for an agent execution */
export const DEFAULT_MAX_STEPS = 50;
Loading
Loading