🎨 remove unused deps, improve prompt construction

This commit is contained in:
Nate Sesti 2024-01-22 11:12:31 -08:00
parent b5f96b65aa
commit 71ab7122bd
8 changed files with 663 additions and 2862 deletions

View file

@ -1,16 +1,25 @@
import { ChatHistory, ChatMessage } from "..";
import { ChatHistory, ChatMessage, MessagePart } from "..";
export function constructMessages(history: ChatHistory): ChatMessage[] {
const msgs: ChatMessage[] = [];
const msgs = [];
for (const historyItem of history) {
for (const ctxItem of historyItem.contextItems) {
msgs.push({
role: historyItem.message.role,
content: ctxItem.content,
});
}
msgs.push(historyItem.message);
for (let i = 0; i < history.length; i++) {
const historyItem = history[i];
let content = Array.isArray(historyItem.message.content)
? historyItem.message.content
: [{ type: "text", text: historyItem.message.content } as MessagePart];
const ctxItems = historyItem.contextItems.map((ctxItem) => {
return { type: "text", text: ctxItem.content + "\n" } as MessagePart;
});
content = [...ctxItems, ...content];
msgs.push({
role: historyItem.message.role,
content,
});
}
return msgs;

2571
core/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -24,12 +24,9 @@
"dotenv": "^16.3.1",
"fastest-levenshtein": "^1.0.16",
"handlebars": "^4.7.8",
"headless-chrome-crawler": "^1.8.0",
"jquery": "^3.7.1",
"js-tiktoken": "^1.0.8",
"node-html-markdown": "^1.3.0",
"openai": "^4.20.1",
"puppeteer": "^21.7.0",
"replicate": "^0.23.0",
"socket.io-client": "^4.7.3",
"sqlite": "^5.1.1",

File diff suppressed because it is too large Load diff

View file

@ -83,12 +83,9 @@
"dotenv": "^16.3.1",
"fastest-levenshtein": "^1.0.16",
"handlebars": "^4.7.8",
"headless-chrome-crawler": "^1.8.0",
"jquery": "^3.7.1",
"js-tiktoken": "^1.0.8",
"node-html-markdown": "^1.3.0",
"openai": "^4.20.1",
"puppeteer": "^21.7.0",
"replicate": "^0.23.0",
"socket.io-client": "^4.7.3",
"sqlite": "^5.1.1",

View file

@ -2274,12 +2274,9 @@ core-util-is@~1.0.0, core-util-is@1.0.2:
dotenv "^16.3.1"
fastest-levenshtein "^1.0.16"
handlebars "^4.7.8"
headless-chrome-crawler "^1.8.0"
jquery "^3.7.1"
js-tiktoken "^1.0.8"
node-html-markdown "^1.3.0"
openai "^4.20.1"
puppeteer "^21.7.0"
replicate "^0.23.0"
socket.io-client "^4.7.3"
sqlite "^5.1.1"

6
gui/package-lock.json generated
View file

@ -73,12 +73,9 @@
"dotenv": "^16.3.1",
"fastest-levenshtein": "^1.0.16",
"handlebars": "^4.7.8",
"headless-chrome-crawler": "^1.8.0",
"jquery": "^3.7.1",
"js-tiktoken": "^1.0.8",
"node-html-markdown": "^1.3.0",
"openai": "^4.20.1",
"puppeteer": "^21.7.0",
"replicate": "^0.23.0",
"socket.io-client": "^4.7.3",
"sqlite": "^5.1.1",
@ -7468,13 +7465,10 @@
"esbuild": "^0.19.11",
"fastest-levenshtein": "^1.0.16",
"handlebars": "^4.7.8",
"headless-chrome-crawler": "^1.8.0",
"jest": "^29.7.0",
"jquery": "^3.7.1",
"js-tiktoken": "^1.0.8",
"node-html-markdown": "^1.3.0",
"openai": "^4.20.1",
"puppeteer": "^21.7.0",
"replicate": "^0.23.0",
"socket.io-client": "^4.7.3",
"sqlite": "^5.1.1",

View file

@ -40,7 +40,6 @@ const ContextItemsPeek = (props: ContextItemsPeekProps) => {
}
function openContextItem(contextItem: ContextItemWithId) {
console.log("openContextItem", contextItem);
if (contextItem.description.startsWith("http")) {
window.open(contextItem.description, "_blank");
} else if (