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
54 changes: 25 additions & 29 deletions commands/predict.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,40 @@ const { alitaService, workspaceService, windowService } = require("../services")

module.exports = async function () {
alitaService.checkLLMConfig();
if (alitaService.init_done === 0) {
try {
await alitaService.serviceProvider.init();
alitaService.init_done = 1;
} catch (ex) {
alitaService.init_done = 0;
await vscode.window.showErrorMessage(
`Alita is not able to connect to ${alitaService.serviceProvider.getPromptsUrl}`
);
return;
}
}

const promptsList = await workspaceService.updatePrompts();
const applicationList = await alitaService.getApplications({});
// renderring list
const entities = [...promptsList]
.map((prompt) => ({
label: prompt.label.replace(/(_prompt|_datasource)$/, ""),
description: prompt.description,
iconPath: new vscode.ThemeIcon(
prompt.label.endsWith("_datasource") ? "database" : prompt.external ? "terminal" : "remote-explorer"
),
full_name: prompt.label,
let entities = []
entities.push({
label: "No agent",
description: "",
iconPath: "terminal",
full_name: "",
});
[...applicationList]
.forEach((application) => entities.push({
label: application.name,
description: application.description,
iconPath: new vscode.ThemeIcon("remote-explorer"),
full_name: application.label,
}));
let selection = await windowService.showQuickPick([...entities]);
selection = [...promptsList].find((prompt) => prompt.label === selection.full_name);
if (!selection) return;
// select required version
if (!selection.label.endsWith("_datasource") && selection.external) {
var prompt_details_response = await alitaService.getPromptDetail(selection.prompt_id);
let selection = await windowService.showQuickPick([...entities], {
activeItem: entities[entities.length - 1]
});
selection = [...applicationList].find((application) => application.label === selection.full_name);
if (!selection) {

} else {
// select required version
var prompt_details_response = await alitaService.getApplicationDetail(selection.id);

// if prompt has 2+ versions - show them
selection.version =
prompt_details_response.versions.length === 1
? prompt_details_response.versions[0]
: await handleVersions(prompt_details_response.versions);
}



vscode.window.withProgress(
{
location: vscode.ProgressLocation.Window,
Expand Down
2 changes: 1 addition & 1 deletion commands/syncEmbeddings.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = async function () {
await workspaceService.updateEmbeddings();
} catch (e) {
await vscode.window.showErrorMessage(
`Alita is not able to connec to ${alitaService.serviceProvider.getEmbeddingsUrl}`
`Alita is not able to connec to ${alitaService.serviceProvider.getConfigurationsUrl}`
);
}
};
38 changes: 3 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,6 @@
"command": "eliteacode.predict",
"title": "Predict"
},
{
"command": "eliteacode.createPrompt",
"title": "Create Prompt"
},
{
"command": "eliteacode.addContext",
"title": "Extend Context"
},
{
"command": "eliteacode.syncPrompts",
"title": "Sync External Prompts"
},
{
"command": "eliteacode.initAlita",
"title": "Init"
},
{
"command": "eliteacode.getAvailableAIModels",
"title": "Get available AI models from the server"
Expand All @@ -54,24 +38,8 @@
],
"eliteacode.submenu": [
{
"when": "editorHasSelection && editorFocus && !editorReadonly && eliteacode.init",
"when": "editorHasSelection && editorFocus && !editorReadonly",
"command": "eliteacode.predict"
},
{
"when": "editorFocus && !editorReadonly && eliteacode.init && eliteacode.LocalPrompts",
"command": "eliteacode.createPrompt"
},
{
"when": "editorFocus && !eliteacode.init && eliteacode.LLMProvider != 'None'",
"command": "eliteacode.initAlita"
},
{
"when": "editorHasSelection && editorFocus && !editorReadonly && eliteacode.init && eliteacode.LocalPrompts",
"command": "eliteacode.addContext"
},
{
"when": "eliteacode.init && eliteacode.LLMProvider in eliteacode.ExtentablePlatforms",
"command": "eliteacode.syncPrompts"
}
]
},
Expand Down Expand Up @@ -241,7 +209,7 @@
"@vscode/webview-ui-toolkit": "^1.4.0",
"axios": "^1.6.8",
"form-data": "^4.0.0",
"squirrelly": "7.9.2",
"squirrelly": "^9.1.0",
"yaml": "^2.4.1"
},
"devDependencies": {
Expand All @@ -251,7 +219,7 @@
"@types/vscode": "^1.78.0",
"@vscode/test-electron": "^2.3.2",
"@vscode/vsce": "^2.25.0",
"esbuild": "^0.19.12",
"esbuild": "0.25.9",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"glob": "^8.1.0",
Expand Down
92 changes: 37 additions & 55 deletions services/alita.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = class AlitaService {
this.serviceProvider = new llmServierProvider[newProvier]();
this.currentProvider = newProvier;
this.init_done = 0;
this.integrationData = undefined;
this.configurationData = undefined;
}
} catch (ex) {
console.log(ex);
Expand All @@ -59,7 +59,7 @@ module.exports = class AlitaService {
return `${fnDesc} not supported by this LLM Provider`;
}
} catch (error) {
await Notifications.showError({ error, message: `Alita Code ${functionName}`, showOutputButton: true });
await Notifications.showError({ error, message: `Elitea Code ${functionName}`, showOutputButton: true });
return "You need to configure LLM Provider first";
}
}
Expand All @@ -69,7 +69,7 @@ module.exports = class AlitaService {
this.checkLLMConfig();
return await this.serviceProvider.predict(template, prompt, prompt_template);
} catch (error) {
await Notifications.showError({ error, message: "Alita is not able to connect", showOutputButton: true });
await Notifications.showError({ error, message: "Elitea is not able to connect", showOutputButton: true });
return "You need to configure LLM Provider first";
}
}
Expand All @@ -82,21 +82,6 @@ module.exports = class AlitaService {
return this.invokeMethod("getModelSettings", "Get model settings");
}

async getPrompts({ page = 0, query }) {
return await this.invokeMethod("getPrompts", "List prompts", { page, query });
}

async getPromptDetail(promptId) {
return await this.invokeMethod("getPromptDetail", "Get prompt detail", promptId);
}

async getDatasourceDetail(id) {
return await this.invokeMethod("getDatasourceDetail", "Get prompt detail", id);
}

async getDatasources() {
return await this.invokeMethod("getDatasources", "List datasources");
}

async getApplicationDetail(id) {
return await this.invokeMethod("getAppllicationDetail", "Get application detail", id);
Expand All @@ -106,6 +91,10 @@ module.exports = class AlitaService {
return await this.invokeMethod("getApplications", "List applications");
}

async createConversation(name) {
return await this.invokeMethod("createConversation", "Create conversation", name);
}

async getDeployments() {
return await this.invokeMethod("getDeployments", "Get deployments");
}
Expand All @@ -114,10 +103,6 @@ module.exports = class AlitaService {
return await this.invokeMethod("stopApplicationTask", "Stop application task", taskId);
}

async stopDatasourceTask(taskId) {
return await this.invokeMethod("stopDatasourceTask", "Stop datasource task", taskId);
}

async chat(params) {
return await this.invokeMethod("chat", "Chat", params);
}
Expand All @@ -127,64 +112,61 @@ module.exports = class AlitaService {
}

async getAIModelNames() {
this.integrationData = await this.getEmbeddings();
this.configurationData = await this.getEmbeddings();
const array = [];
this.integrationData.forEach((entry) => {
if (entry.settings && Array.isArray(entry.settings.models)) {
entry.settings.models.forEach((model) => {
if (model.name && entry.name) {
array.push({ [entry.config.name]: model.name });
}
});
}
});
if (this.configurationData.shared && Array.isArray(this.configurationData.shared.items)) {
this.configurationData.shared.items.forEach((model) => {
if (model.data.name && model.alita_title) {
array.push({ [model.alita_title]: model.data.name });
}
});
}
return array;
}

async getAIModelUid(integrationConfigName, isUsedCashedData) {
const data = isUsedCashedData ? this.integrationData : await this.getEmbeddings();
return data
.filter((integration) => integration.config.name === integrationConfigName)
.map((integration) => integration.uid);
const data = isUsedCashedData ? this.configurationData : await this.getEmbeddings();
return data.shared.items
.filter((configuration) => configuration.alita_title === integrationConfigName)
.map((configuration) => configuration.uuid);
}

async getAIModelIntegrationName(integrationConfigName, isUsedCashedData) {
const data = isUsedCashedData ? this.integrationData : await this.getEmbeddings();
return data
.filter((integration) => integration.config.name === integrationConfigName)
.map((integration) => integration.name);
const data = isUsedCashedData ? this.configurationData : await this.getEmbeddings();
return data.shared.items
.filter((configuration) => configuration.alita_title === integrationConfigName)
.map((configuration) => configuration.data.name);
}

async getEmbeddings() {
return await this.invokeMethod("getEmbeddings", "Get available integrations");
}


async getAIModelNames() {
const data = await this.getEmbeddings();
const array = [];
data.forEach((entry) => {
if (entry.settings && Array.isArray(entry.settings.models)) {
entry.settings.models.forEach((model) => {
if (model.name && entry.name) {
array.push({ [entry.config.name]: model.name });
}
});
}
});
if (data.shared && Array.isArray(data.shared.items)) {
data.shared.items.forEach((model) => {
if (model.data.name && model.alita_title) {
array.push({ [model.alita_title]: model.data.name });
}
});
}
return array;
}

async getAIModelUid(integrationConfigName) {
const data = await this.getEmbeddings();
return data
.filter((integration) => integration.config.name === integrationConfigName)
.map((integration) => integration.uid);
return data.shared.items
.filter((configuration) => configuration.alita_title === integrationConfigName)
.map((configuration) => configuration.uuid);
}

async getAIModelIntegrationName(integrationConfigName) {
const data = await this.getEmbeddings();
return data
.filter((integration) => integration.config.name === integrationConfigName)
.map((integration) => integration.name);
return data.shared.items
.filter((configuration) => configuration.alita_title === integrationConfigName)
.map((configuration) => configuration.data.name);
}
};
Loading
Loading