Merge branch 'dev' into pe/jb-granular-diff-actions

This commit is contained in:
Patrick Erichsen 2024-10-11 14:18:01 -07:00 • committed by GitHub
commit 9e879b9e97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 362 additions and 49 deletions

View file

@ -37,20 +37,29 @@ class HttpContextProvider extends BaseContextProvider {
body: JSON.stringify({
query: query || "",
fullInput: extras.fullInput,
options: this.options.options,
}),
});
const json = await response.json();
const createContextItem = (item: any) => ({
description: item.description ?? "HTTP Context Item",
content: item.content ?? "",
name: item.name ?? this.options.title ?? "HTTP",
});
try {
const createContextItem = (item: any) => ({
description: item.description ?? "HTTP Context Item",
content: item.content ?? "",
name: item.name ?? this.options.title ?? "HTTP",
});
return Array.isArray(json)
? json.map(createContextItem)
: [createContextItem(json)];
return Array.isArray(json)
? json.map(createContextItem)
: [createContextItem(json)];
} catch (e) {
console.warn(
`Failed to parse response from custom HTTP context provider.\nError:\n${e}\nResponse from server:\n`,
json,
);
return [];
}
}
}

1
core/index.d.ts vendored
View file

@ -801,6 +801,7 @@ export interface ModelDescription {
}
export type EmbeddingsProviderName =
| "sagemaker"
| "bedrock"
| "huggingface-tei"
| "transformers.js"

View file

@ -0,0 +1,114 @@
import {
InvokeEndpointCommand,
SageMakerRuntimeClient,
} from "@aws-sdk/client-sagemaker-runtime";
import { fromIni } from "@aws-sdk/credential-providers";
import {
EmbeddingsProviderName,
EmbedOptions,
FetchFunction,
} from "../../index.js";
import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js";
class SageMakerEmbeddingsProvider extends BaseEmbeddingsProvider {
static providerName: EmbeddingsProviderName = "sagemaker";
static defaultOptions: Partial<EmbedOptions> | undefined = {
region: "us-west-2",
maxBatchSize: 1,
};
profile?: string | undefined;
constructor(options: EmbedOptions, fetch: FetchFunction) {
super(options, fetch);
if (!options.apiBase) {
options.apiBase = `https://runtime.sagemaker.${options.region}.amazonaws.com`;
}
if (options.profile) {
this.profile = options.profile;
} else {
this.profile = "sagemaker";
}
}
async embed(chunks: string[]) {
const credentials = await this._getCredentials();
const client = new SageMakerRuntimeClient({
region: this.options.region,
credentials: {
accessKeyId: credentials.accessKeyId,
secretAccessKey: credentials.secretAccessKey,
sessionToken: credentials.sessionToken || "",
},
});
const batchedChunks = this.getBatchedChunks(chunks);
return (
await Promise.all(
batchedChunks.map(async (batch) => {
const input = this._generateInvokeModelCommandInput(
batch,
this.options,
);
const command = new InvokeEndpointCommand(input);
const response = await client.send(command);
if (response.Body) {
const responseBody = JSON.parse(
new TextDecoder().decode(response.Body),
);
// If the body contains a key called "embedding" or "embeddings", return the value, otherwise return the whole body
if (responseBody.embedding) {
return responseBody.embedding;
} else if (responseBody.embeddings) {
return responseBody.embeddings;
} else {
return responseBody;
}
}
}),
)
).flat();
}
private _generateInvokeModelCommandInput(
prompts: string | string[],
options: EmbedOptions,
): any {
const payload = {
inputs: prompts,
normalize: true,
// ...(options.requestOptions?.extraBodyProperties || {}),
};
if (options.requestOptions?.extraBodyProperties) {
Object.assign(payload, options.requestOptions.extraBodyProperties);
}
return {
EndpointName: this.options.model,
Body: JSON.stringify(payload),
ContentType: "application/json",
CustomAttributes: "accept_eula=false",
};
}
private async _getCredentials() {
try {
return await fromIni({
profile: this.profile,
ignoreCache: true,
})();
} catch (e) {
console.warn(
`AWS profile with name ${this.profile} not found in ~/.aws/credentials, using default profile`,
);
return await fromIni()();
}
}
}
export default SageMakerEmbeddingsProvider;

View file

@ -1,5 +1,6 @@
import { EmbeddingsProviderName } from "../../index.js";
import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js";
import SageMakerEmbeddingsProvider from "./SageMakerEmbeddingsProvider.js";
import BedrockEmbeddingsProvider from "./BedrockEmbeddingsProvider.js";
import CohereEmbeddingsProvider from "./CohereEmbeddingsProvider.js";
import ContinueProxyEmbeddingsProvider from "./ContinueProxyEmbeddingsProvider.js";
@ -22,6 +23,7 @@ export const allEmbeddingsProviders: Record<
EmbeddingsProviderName,
EmbeddingsProviderConstructor
> = {
sagemaker: SageMakerEmbeddingsProvider,
bedrock: BedrockEmbeddingsProvider,
ollama: OllamaEmbeddingsProvider,
"transformers.js": TransformersJsEmbeddingsProvider,

View file

@ -1,8 +1,8 @@
# AWS SageMaker
SageMaker provider support SageMaker endpoint deployed with [LMI](https://docs.djl.ai/docs/serving/serving/docs/lmi/index.html)
SageMaker can be used for both chat and embedding models. Chat models are supported for endpoints deployed with [LMI](https://docs.djl.ai/docs/serving/serving/docs/lmi/index.html), and embedding models are supported for endpoints deployed with [HuggingFace TEI](https://huggingface.co/blog/sagemaker-huggingface-embedding)
To setup SageMaker, add the following to your `config.json` file:
To setup SageMaker as a chat model provider, add the following to your `config.json` file:
```json title="config.json"
{
@ -13,7 +13,11 @@ To setup SageMaker, add the following to your `config.json` file:
"model": "lmi-model-deepseek-coder-xxxxxxx",
"region": "us-west-2"
}
]
],
"embeddingsProvider": {
"provider": "sagemaker",
"model": "mxbai-embed-large-v1-endpoint"
},
}
```

View file

@ -22,7 +22,7 @@ We recommend configuring **GPT-4o** as your chat model.
## Autocomplete model
We recommend configuring **Codestral** as your autocomplete model.
We recommend configuring **Codestral** as your autocomplete model. There are not currently any other models in Azure that are capable of autocomplete.
```json title="config.json"
"tabAutocompleteModel": [{

View file

@ -180,12 +180,15 @@ If you'd like to write a context provider in a language other than TypeScript, y
"url": "https://myserver.com/context-provider",
"title": "http",
"description": "Custom HTTP Context Provider",
"displayTitle": "My Custom Context"
"displayTitle": "My Custom Context",
"options": {}
}
}
```
<!-- Then, create a server that responds to requests as are made from [HttpContextProvider.ts](../../../core/context/providers/HttpContextProvider.ts). See the `hello` endpoint in [context_provider_server.py](../../../core/context/providers/context_provider_server.py) for an example that uses FastAPI. -->
Then, create a server that responds to requests as are made from [HttpContextProvider.ts](../../../../core/context/providers/HttpContextProvider.ts). See the `hello` endpoint in [context_provider_server.py](../../../../core/context/providers/context_provider_server.py) for an example that uses FastAPI.
The `"options"` property can be used to send additional parameters to your endpoint, which will be included in the request body.
## Extension API for VSCode

View file

@ -246,7 +246,25 @@
"region": {
"title": "Region",
"description": "The region where the model is hosted",
"type": "string"
"anyOf": [
{
"enum": [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"eu-west-1",
"eu-central-1",
"ap-southeast-1",
"ap-northeast-1",
"ap-south-1"
],
"type": "string"
},
{
"type": "string"
}
]
},
"profile": {
"title": "Profile",
@ -1389,7 +1407,6 @@
"enum": [
"issue",
"share",
"so",
"cmd",
"edit",
"comment",
@ -1401,7 +1418,6 @@
"markdownEnumDescriptions": [
"Generate a link to a drafted GitHub issue",
"Export the current chat session to markdown",
"Reference StackOverflow to answer the question",
"Generate a terminal command and paste it into the terminal",
"Edit the highlighted code with given instructions",
"Add comments to the highlighted code",
@ -1855,6 +1871,11 @@
"url": {
"type": "string",
"description": "The HTTP endpoint of your context provider server."
},
"options": {
"title": "Custom Options",
"description": "Additional options to pass to your custom HTTP server.",
"type": "object"
}
},
"required": ["url"]
@ -2145,7 +2166,8 @@
"gemini",
"voyage",
"nvidia",
"bedrock"
"bedrock",
"sagemaker"
]
},
"model": {
@ -2179,7 +2201,7 @@
"region": {
"title": "Region",
"description": "The region where the model is hosted",
"type": "string"
"$ref": "#/definitions/ModelDescription/properties/region"
},
"profile": {
"title": "Profile",
@ -2201,6 +2223,24 @@
"then": {
"required": ["apiKey"]
}
},
{
"if": {
"properties": {
"provider": {
"enum": ["sagemaker"]
}
},
"required": ["provider"]
},
"then": {
"properties": {
"model": {
"markdownDescription": "SageMaker endpoint name"
}
},
"required": ["model"]
}
}
]
},

View file

@ -3,13 +3,13 @@ pluginGroup=com.github.continuedev.continueintellijextension
pluginName=continue-intellij-extension
pluginRepositoryUrl=https://github.com/continuedev/continue
# SemVer format -> https://semver.org
pluginVersion=0.0.74
pluginVersion=0.0.75
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild=223
#pluginUntilBuild = 232.*
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType=IC
platformVersion=2022.3.3
platformVersion=2023.2
#platformVersion = LATEST-EAP-SNAPSHOT
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22

View file

@ -126,7 +126,12 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware {
continuePluginService.coreMessenger?.request("config/ideSettingsUpdate", settings, null) { _ -> }
continuePluginService.sendToWebview(
"didChangeIdeSettings", mapOf(
"settings" to settings
"settings" to mapOf(
"remoteConfigServerUrl" to settings.remoteConfigServerUrl,
"remoteConfigSyncPeriod" to settings.remoteConfigSyncPeriod,
"userToken" to settings.userToken,
"enableControlServerBeta" to settings.enableContinueTeamsBeta
)
)
)
}

View file

@ -100,7 +100,7 @@ class ContinueAuthService {
updateRefreshToken(refreshToken)
}
kotlinx.coroutines.delay(30 * 60 * 1000)
kotlinx.coroutines.delay(15 * 60 * 1000) // 15 minutes in milliseconds
}
}
}
@ -140,19 +140,30 @@ class ContinueAuthService {
}
private fun retrieveSecret(key: String): String? {
val attributes = createCredentialAttributes(key, CREDENTIALS_USER)
val passwordSafe: PasswordSafe = PasswordSafe.instance
return try {
val attributes = createCredentialAttributes(key, CREDENTIALS_USER)
val passwordSafe: PasswordSafe = PasswordSafe.instance
val credentials: Credentials? = passwordSafe[attributes!!]
return credentials?.getPasswordAsString()
val credentials: Credentials? = passwordSafe[attributes!!]
credentials?.getPasswordAsString()
} catch (e: Exception) {
// Log the exception or handle it as needed
println("Error retrieving secret for key $key: ${e.message}")
null
}
}
private fun storeSecret(key: String, secret: String) {
val attributes = createCredentialAttributes(key, CREDENTIALS_USER)
val passwordSafe: PasswordSafe = PasswordSafe.instance
try {
val attributes = createCredentialAttributes(key, CREDENTIALS_USER)
val passwordSafe: PasswordSafe = PasswordSafe.instance
val credentials = Credentials(CREDENTIALS_USER, secret)
passwordSafe.set(attributes!!, credentials)
val credentials = Credentials(CREDENTIALS_USER, secret)
passwordSafe.set(attributes!!, credentials)
} catch (e: Exception) {
// Log the exception or handle it as needed
println("Error storing secret for key $key: ${e.message}")
}
}
private fun getAccessToken(): String? {

View file

@ -730,9 +730,7 @@ class IdeProtocolClient(
respond(File.separator)
}
else -> {
println("Unknown messageType: $messageType")
}
else -> {}
}
} catch (error: Exception) {
showToast("error", "Error handling message of type $messageType: $error")

View file

@ -246,7 +246,25 @@
"region": {
"title": "Region",
"description": "The region where the model is hosted",
"type": "string"
"anyOf": [
{
"enum": [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"eu-west-1",
"eu-central-1",
"ap-southeast-1",
"ap-northeast-1",
"ap-south-1"
],
"type": "string"
},
{
"type": "string"
}
]
},
"profile": {
"title": "Profile",
@ -1389,7 +1407,6 @@
"enum": [
"issue",
"share",
"so",
"cmd",
"edit",
"comment",
@ -1401,7 +1418,6 @@
"markdownEnumDescriptions": [
"Generate a link to a drafted GitHub issue",
"Export the current chat session to markdown",
"Reference StackOverflow to answer the question",
"Generate a terminal command and paste it into the terminal",
"Edit the highlighted code with given instructions",
"Add comments to the highlighted code",
@ -1855,6 +1871,11 @@
"url": {
"type": "string",
"description": "The HTTP endpoint of your context provider server."
},
"options": {
"title": "Custom Options",
"description": "Additional options to pass to your custom HTTP server.",
"type": "object"
}
},
"required": ["url"]
@ -2145,7 +2166,8 @@
"gemini",
"voyage",
"nvidia",
"bedrock"
"bedrock",
"sagemaker"
]
},
"model": {
@ -2179,7 +2201,7 @@
"region": {
"title": "Region",
"description": "The region where the model is hosted",
"type": "string"
"$ref": "#/definitions/ModelDescription/properties/region"
},
"profile": {
"title": "Profile",
@ -2201,6 +2223,24 @@
"then": {
"required": ["apiKey"]
}
},
{
"if": {
"properties": {
"provider": {
"enum": ["sagemaker"]
}
},
"required": ["provider"]
},
"then": {
"properties": {
"model": {
"markdownDescription": "SageMaker endpoint name"
}
},
"required": ["model"]
}
}
]
},

View file

@ -246,7 +246,25 @@
"region": {
"title": "Region",
"description": "The region where the model is hosted",
"type": "string"
"anyOf": [
{
"enum": [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"eu-west-1",
"eu-central-1",
"ap-southeast-1",
"ap-northeast-1",
"ap-south-1"
],
"type": "string"
},
{
"type": "string"
}
]
},
"profile": {
"title": "Profile",
@ -1389,7 +1407,6 @@
"enum": [
"issue",
"share",
"so",
"cmd",
"edit",
"comment",
@ -1401,7 +1418,6 @@
"markdownEnumDescriptions": [
"Generate a link to a drafted GitHub issue",
"Export the current chat session to markdown",
"Reference StackOverflow to answer the question",
"Generate a terminal command and paste it into the terminal",
"Edit the highlighted code with given instructions",
"Add comments to the highlighted code",
@ -1855,6 +1871,11 @@
"url": {
"type": "string",
"description": "The HTTP endpoint of your context provider server."
},
"options": {
"title": "Custom Options",
"description": "Additional options to pass to your custom HTTP server.",
"type": "object"
}
},
"required": ["url"]
@ -2145,7 +2166,8 @@
"gemini",
"voyage",
"nvidia",
"bedrock"
"bedrock",
"sagemaker"
]
},
"model": {
@ -2179,7 +2201,7 @@
"region": {
"title": "Region",
"description": "The region where the model is hosted",
"type": "string"
"$ref": "#/definitions/ModelDescription/properties/region"
},
"profile": {
"title": "Profile",
@ -2201,6 +2223,24 @@
"then": {
"required": ["apiKey"]
}
},
{
"if": {
"properties": {
"provider": {
"enum": ["sagemaker"]
}
},
"required": ["provider"]
},
"then": {
"properties": {
"model": {
"markdownDescription": "SageMaker endpoint name"
}
},
"required": ["model"]
}
}
]
},

View file

@ -249,7 +249,25 @@
"region": {
"title": "Region",
"description": "The region where the model is hosted",
"type": "string"
"anyOf": [
{
"enum": [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"eu-west-1",
"eu-central-1",
"ap-southeast-1",
"ap-northeast-1",
"ap-south-1"
],
"type": "string"
},
{
"type": "string"
}
]
},
"profile": {
"title": "Profile",
@ -1543,7 +1561,6 @@
"enum": [
"issue",
"share",
"so",
"cmd",
"edit",
"comment",
@ -1555,7 +1572,6 @@
"markdownEnumDescriptions": [
"Generate a link to a drafted GitHub issue",
"Export the current chat session to markdown",
"Reference StackOverflow to answer the question",
"Generate a terminal command and paste it into the terminal",
"Edit the highlighted code with given instructions",
"Add comments to the highlighted code",
@ -2076,6 +2092,11 @@
"url": {
"type": "string",
"description": "The HTTP endpoint of your context provider server."
},
"options": {
"title": "Custom Options",
"description": "Additional options to pass to your custom HTTP server.",
"type": "object"
}
},
"required": [
@ -2391,7 +2412,8 @@
"gemini",
"voyage",
"nvidia",
"bedrock"
"bedrock",
"sagemaker"
]
},
"model": {
@ -2425,7 +2447,7 @@
"region": {
"title": "Region",
"description": "The region where the model is hosted",
"type": "string"
"$ref": "#/definitions/ModelDescription/properties/region"
},
"profile": {
"title": "Profile",
@ -2458,6 +2480,30 @@
"apiKey"
]
}
},
{
"if": {
"properties": {
"provider": {
"enum": [
"sagemaker"
]
}
},
"required": [
"provider"
]
},
"then": {
"properties": {
"model": {
"markdownDescription": "SageMaker endpoint name"
}
},
"required": [
"model"
]
}
}
]
},