🐛 fixing many small bugs

This commit is contained in:
Nate Sesti 2024-02-08 09:50:09 -08:00
parent c12ffde939
commit ce9fdf0acf
11 changed files with 159 additions and 70 deletions

View file

@ -13,7 +13,7 @@ export const Typescript = {
export const Python = {
stopWords: ["def", "class"],
comment: "#",
endOfLine: [""],
endOfLine: [],
};
export const Java = {

View file

@ -45,7 +45,7 @@ The last line is incomplete, and you should provide the rest of that line. If th
};
export function getTemplateForModel(model: string): AutocompleteTemplate {
const lowerCaseModel = model.toLowerCase()
const lowerCaseModel = model.toLowerCase();
if (
lowerCaseModel.includes("starcoder") ||
lowerCaseModel.includes("star-coder") ||

View file

@ -174,42 +174,50 @@ async function intermediateToFinalConfig(
if (!llm) continue;
if (llm.model === "AUTODETECT") {
const modelNames = await llm.listModels();
const detectedModels = await Promise.all(
modelNames.map(async (modelName) => {
return await llmFromDescription(
{
...desc,
model: modelName,
title: llm.title + " - " + modelName,
},
readFile,
config.completionOptions,
config.systemMessage
);
})
);
models.push(
...(detectedModels.filter(
(x) => typeof x !== "undefined"
) as BaseLLM[])
);
try {
const modelNames = await llm.listModels();
const detectedModels = await Promise.all(
modelNames.map(async (modelName) => {
return await llmFromDescription(
{
...desc,
model: modelName,
title: llm.title + " - " + modelName,
},
readFile,
config.completionOptions,
config.systemMessage
);
})
);
models.push(
...(detectedModels.filter(
(x) => typeof x !== "undefined"
) as BaseLLM[])
);
} catch (e) {
console.warn("Error listing models: ", e);
}
} else {
models.push(llm);
}
} else {
const llm = new CustomLLMClass(desc);
if (llm.model === "AUTODETECT") {
const modelNames = await llm.listModels();
const models = modelNames.map(
(modelName) =>
new CustomLLMClass({
...desc,
options: { ...desc.options, model: modelName },
})
);
try {
const modelNames = await llm.listModels();
const models = modelNames.map(
(modelName) =>
new CustomLLMClass({
...desc,
options: { ...desc.options, model: modelName },
})
);
models.push(...models);
models.push(...models);
} catch (e) {
console.warn("Error listing models: ", e);
}
} else {
models.push(llm);
}

View file

@ -27,7 +27,11 @@ class OllamaEmbeddingsProvider extends BaseEmbeddingsProvider {
}
embed(chunks: string[]) {
return Promise.all(chunks.map((chunk) => embedOne(chunk, this.options)));
const results: any = [];
for (const chunk of chunks) {
results.push(embedOne(chunk, this.options));
}
return results;
}
}

View file

@ -1,27 +1,21 @@
import ReplicateClient from "replicate";
import { BaseLLM } from "..";
import {
ChatMessage,
CompletionOptions,
LLMOptions,
ModelProvider,
} from "../..";
import { stripImages } from "../countTokens";
import { CompletionOptions, LLMOptions, ModelProvider } from "../..";
class Replicate extends BaseLLM {
private static MODEL_IDS: {
[name: string]: `${string}/${string}:${string}`;
} = {
"codellama-7b":
"meta/codellama-7b-instruct:6527b83e01e41412db37de5110a8670e3701ee95872697481a355e05ce12af0e",
"meta/codellama-7b-instruct:aac3ab196f8a75729aab9368cd45ea6ad3fc793b6cda93b1ded17299df369332",
"codellama-13b":
"meta/codellama-13b-instruct:1f01a52ff933873dff339d5fb5e1fd6f24f77456836f514fa05e91c1a42699c7",
"meta/codellama-13b-instruct:a5e2d67630195a09b96932f5fa541fe64069c97d40cd0b69cdd91919987d0e7f",
"codellama-34b":
"meta/codellama-34b-instruct:8281a5c610f6e88237ff3ddaf3c33b56f60809e2bdd19fbec2fda742aa18167e",
"llama2-7b":
"meta/llama-2-7b-chat:8e6975e5ed6174911a6ff3d60540dfd4844201974602551e10e9e87ab143d81e",
"llama2-13b":
"meta/llama-2-13b-chat:f4e2de70d66816a838a89eeeb621910adffb0dd0baba3976c96980970978018d",
"meta/codellama-34b-instruct:eeb928567781f4e90d2aba57a51baef235de53f907c214a4ab42adabf5bb9736",
"codellama-70b":
"meta/codellama-70b-instruct:a279116fe47a0f65701a8817188601e2fe8f4b9e04a518789655ea7b995851bf",
"llama2-7b": "meta/llama-2-7b-chat" as any,
"llama2-13b": "meta/llama-2-13b-chat" as any,
"zephyr-7b":
"nateraw/zephyr-7b-beta:b79f33de5c6c4e34087d44eaea4a9d98ce5d3f3a09522f7328eea0685003a931",
"mistral-7b":
@ -69,18 +63,23 @@ class Replicate extends BaseLLM {
prompt: string,
options: CompletionOptions
): AsyncGenerator<string> {
yield await this._complete(prompt, options);
const [model, args] = this._convertArgs(options, prompt);
for await (const event of this._replicate.stream(model, args)) {
if (event.event === "output") {
yield event.data;
}
}
}
protected async *_streamChat(
messages: ChatMessage[],
options: CompletionOptions
): AsyncGenerator<ChatMessage> {
const resp = await this.complete(
stripImages(messages[0]?.content || ""),
options
);
}
// protected async *_streamChat(
// messages: ChatMessage[],
// options: CompletionOptions
// ): AsyncGenerator<ChatMessage> {
// const resp = await this.complete(
// stripImages(messages[0]?.content || ""),
// options
// );
// }
}
export default Replicate;

60
core/package-lock.json generated
View file

@ -22,7 +22,7 @@
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
"openai": "^4.20.1",
"replicate": "^0.23.0",
"replicate": "^0.26.0",
"socket.io-client": "^4.7.3",
"sqlite": "^5.1.1",
"sqlite3": "^5.1.7",
@ -5808,6 +5808,15 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
"optional": true,
"engines": {
"node": ">= 0.6.0"
}
},
"node_modules/promise-inflight": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz",
@ -5950,14 +5959,57 @@
}
},
"node_modules/replicate": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/replicate/-/replicate-0.23.0.tgz",
"integrity": "sha512-mR9cb4aDXWDAn7/GUMlOL3Jc7rnUys/AG6+R9Cum0xyU3e72a/o8NJ71pgQ6mCXZnEL5iWp/i6AD8Cgh8TA/bw==",
"version": "0.26.0",
"resolved": "https://registry.npmjs.org/replicate/-/replicate-0.26.0.tgz",
"integrity": "sha512-BR7zI/pJp11IuCZZ38hdJVZ07ZCfe6b3tbPuUpRIbt76sVKoGtQhn4Cp2H6/r6qU1fOO6dHadl2VKK4Y0j9Lkg==",
"engines": {
"git": ">=2.11.0",
"node": ">=18.0.0",
"npm": ">=7.19.0",
"yarn": ">=1.7.0"
},
"optionalDependencies": {
"readable-stream": ">=4.0.0"
}
},
"node_modules/replicate/node_modules/buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"optional": true,
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
},
"node_modules/replicate/node_modules/readable-stream": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz",
"integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==",
"optional": true,
"dependencies": {
"abort-controller": "^3.0.0",
"buffer": "^6.0.3",
"events": "^3.3.0",
"process": "^0.11.10",
"string_decoder": "^1.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
},
"node_modules/require-directory": {

View file

@ -31,7 +31,7 @@
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
"openai": "^4.20.1",
"replicate": "^0.23.0",
"replicate": "^0.26.0",
"socket.io-client": "^4.7.3",
"sqlite": "^5.1.1",
"sqlite3": "^5.1.7",

View file

@ -1246,6 +1246,14 @@ buffer@^5.5.0:
base64-js "^1.3.1"
ieee754 "^1.1.13"
buffer@^6.0.3:
version "6.0.3"
resolved "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz"
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.2.1"
cacache@^15.2.0:
version "15.3.0"
resolved "https://registry.npmjs.org/cacache/-/cacache-15.3.0.tgz"
@ -2126,7 +2134,7 @@ iconv-lite@^0.6.2:
dependencies:
safer-buffer ">= 2.1.2 < 3.0.0"
ieee754@^1.1.13:
ieee754@^1.1.13, ieee754@^1.2.1:
version "1.2.1"
resolved "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
@ -3276,6 +3284,11 @@ pretty-format@^29.0.0, pretty-format@^29.7.0:
ansi-styles "^5.0.0"
react-is "^18.0.0"
process@^0.11.10:
version "0.11.10"
resolved "https://registry.npmjs.org/process/-/process-0.11.10.tgz"
integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==
promise-inflight@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz"
@ -3363,15 +3376,28 @@ readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.6.0:
string_decoder "^1.1.1"
util-deprecate "^1.0.1"
readable-stream@>=4.0.0:
version "4.5.2"
resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz"
integrity sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==
dependencies:
abort-controller "^3.0.0"
buffer "^6.0.3"
events "^3.3.0"
process "^0.11.10"
string_decoder "^1.3.0"
repeat-string@^1.5.4:
version "1.6.1"
resolved "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz"
integrity sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==
replicate@^0.23.0:
version "0.23.0"
resolved "https://registry.npmjs.org/replicate/-/replicate-0.23.0.tgz"
integrity sha512-mR9cb4aDXWDAn7/GUMlOL3Jc7rnUys/AG6+R9Cum0xyU3e72a/o8NJ71pgQ6mCXZnEL5iWp/i6AD8Cgh8TA/bw==
replicate@^0.26.0:
version "0.26.0"
resolved "https://registry.npmjs.org/replicate/-/replicate-0.26.0.tgz"
integrity sha512-BR7zI/pJp11IuCZZ38hdJVZ07ZCfe6b3tbPuUpRIbt76sVKoGtQhn4Cp2H6/r6qU1fOO6dHadl2VKK4Y0j9Lkg==
optionalDependencies:
readable-stream ">=4.0.0"
require-directory@^2.1.1:
version "2.1.1"
@ -3621,7 +3647,7 @@ streamx@^2.15.0:
fast-fifo "^1.1.0"
queue-tick "^1.0.1"
string_decoder@^1.1.1:
string_decoder@^1.1.1, string_decoder@^1.3.0:
version "1.3.0"
resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz"
integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==

View file

@ -96,7 +96,7 @@
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
"openai": "^4.20.1",
"replicate": "^0.23.0",
"replicate": "^0.26.0",
"socket.io-client": "^4.7.3",
"sqlite": "^5.1.1",
"sqlite3": "^5.1.7",

View file

@ -2309,7 +2309,7 @@ core-util-is@1.0.2:
node-html-markdown "^1.3.0"
ollama "^0.4.6"
openai "^4.20.1"
replicate "^0.23.0"
replicate "^0.26.0"
socket.io-client "^4.7.3"
sqlite "^5.1.1"
sqlite3 "^5.1.7"

2
gui/package-lock.json generated
View file

@ -86,7 +86,7 @@
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
"openai": "^4.20.1",
"replicate": "^0.23.0",
"replicate": "^0.26.0",
"socket.io-client": "^4.7.3",
"sqlite": "^5.1.1",
"sqlite3": "^5.1.7",