mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-10-04 01:40:12 +02:00
History per workspace (#126)
* Enable saving history value per workspace * added history * added history * Changes re: the PR for message limits from history
This commit is contained in:
parent
82d132427c
commit
98d7266291
@ -140,6 +140,40 @@ export default function WorkspaceSettings({ workspace }) {
|
|||||||
onChange={() => setHasChanges(true)}
|
onChange={() => setHasChanges(true)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div className="flex flex-col gap-y-1 mb-4">
|
||||||
|
<label
|
||||||
|
htmlFor="name"
|
||||||
|
className="block text-sm font-medium text-gray-900 dark:text-white"
|
||||||
|
>
|
||||||
|
Chat History
|
||||||
|
</label>
|
||||||
|
<p className="text-xs text-gray-600 dark:text-stone-400">
|
||||||
|
Chat history: The number of previous chats that
|
||||||
|
will be included in the response's short-term memory.
|
||||||
|
<br />
|
||||||
|
Recommend 20. Anything more than 45 is likely to lead to
|
||||||
|
continuous chat failures depending on message size.
|
||||||
|
<br />
|
||||||
|
Recommended: 20
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
name="openAiHistory"
|
||||||
|
type="number"
|
||||||
|
min={1}
|
||||||
|
max={45}
|
||||||
|
step={1}
|
||||||
|
onWheel={(e) => e.target.blur()}
|
||||||
|
defaultValue={workspace?.openAiHistory ?? 20}
|
||||||
|
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-stone-600 dark:border-stone-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
|
placeholder="20"
|
||||||
|
required={true}
|
||||||
|
autoComplete="off"
|
||||||
|
onChange={() => setHasChanges(true)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
|
@ -10,6 +10,7 @@ const Workspace = {
|
|||||||
"slug",
|
"slug",
|
||||||
"vectorTag",
|
"vectorTag",
|
||||||
"openAiTemp",
|
"openAiTemp",
|
||||||
|
"openAiHistory",
|
||||||
"lastUpdatedAt",
|
"lastUpdatedAt",
|
||||||
],
|
],
|
||||||
colsInit: `
|
colsInit: `
|
||||||
@ -19,6 +20,7 @@ const Workspace = {
|
|||||||
vectorTag TEXT DEFAULT NULL,
|
vectorTag TEXT DEFAULT NULL,
|
||||||
createdAt TEXT DEFAULT CURRENT_TIMESTAMP,
|
createdAt TEXT DEFAULT CURRENT_TIMESTAMP,
|
||||||
openAiTemp REAL DEFAULT NULL,
|
openAiTemp REAL DEFAULT NULL,
|
||||||
|
openAiHistory INTEGER DEFAULT 20,
|
||||||
lastUpdatedAt TEXT DEFAULT CURRENT_TIMESTAMP
|
lastUpdatedAt TEXT DEFAULT CURRENT_TIMESTAMP
|
||||||
`,
|
`,
|
||||||
migrateTable: async function () {
|
migrateTable: async function () {
|
||||||
@ -42,6 +44,11 @@ const Workspace = {
|
|||||||
END`,
|
END`,
|
||||||
doif: true,
|
doif: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
colName: "openAiHistory",
|
||||||
|
execCmd: `ALTER TABLE ${this.tablename} ADD COLUMN openAiHistory INTEGER DEFAULT 20`,
|
||||||
|
doif: false,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
db: async function (tracing = true) {
|
db: async function (tracing = true) {
|
||||||
@ -120,7 +127,7 @@ const Workspace = {
|
|||||||
return { success: false, message: error.message };
|
return { success: false, message: error.message };
|
||||||
});
|
});
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
if (!success) {
|
if (!success) {
|
||||||
return { workspace: null, message };
|
return { workspace: null, message };
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,9 @@ async function chatWithWorkspace(workspace, message, chatMode = "chat") {
|
|||||||
error: null,
|
error: null,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const rawHistory = await WorkspaceChats.forWorkspace(workspace.id, 20);
|
var messageLimit = workspace?.openAiHistory;
|
||||||
|
|
||||||
|
const rawHistory = await WorkspaceChats.forWorkspace(workspace.id, messageLimit);
|
||||||
const chatHistory = convertToPromptHistory(rawHistory);
|
const chatHistory = convertToPromptHistory(rawHistory);
|
||||||
const {
|
const {
|
||||||
response,
|
response,
|
||||||
|
Loading…
Reference in New Issue
Block a user