mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-04 22:10:12 +01: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)}
|
||||
/>
|
||||
</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>
|
||||
|
||||
{error && (
|
||||
|
@ -10,6 +10,7 @@ const Workspace = {
|
||||
"slug",
|
||||
"vectorTag",
|
||||
"openAiTemp",
|
||||
"openAiHistory",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
colsInit: `
|
||||
@ -19,6 +20,7 @@ const Workspace = {
|
||||
vectorTag TEXT DEFAULT NULL,
|
||||
createdAt TEXT DEFAULT CURRENT_TIMESTAMP,
|
||||
openAiTemp REAL DEFAULT NULL,
|
||||
openAiHistory INTEGER DEFAULT 20,
|
||||
lastUpdatedAt TEXT DEFAULT CURRENT_TIMESTAMP
|
||||
`,
|
||||
migrateTable: async function () {
|
||||
@ -42,6 +44,11 @@ const Workspace = {
|
||||
END`,
|
||||
doif: true,
|
||||
},
|
||||
{
|
||||
colName: "openAiHistory",
|
||||
execCmd: `ALTER TABLE ${this.tablename} ADD COLUMN openAiHistory INTEGER DEFAULT 20`,
|
||||
doif: false,
|
||||
},
|
||||
];
|
||||
},
|
||||
db: async function (tracing = true) {
|
||||
@ -106,7 +113,7 @@ const Workspace = {
|
||||
const values = Object.values(data);
|
||||
if (validKeys.length === 0 || validKeys.length !== values.length)
|
||||
return { workspace: { id }, message: "No valid fields to update!" };
|
||||
|
||||
|
||||
const template = `UPDATE ${this.tablename} SET ${validKeys.map((key) => {
|
||||
return `${key}=?`;
|
||||
})} WHERE id = ?`;
|
||||
@ -120,7 +127,7 @@ const Workspace = {
|
||||
return { success: false, message: error.message };
|
||||
});
|
||||
|
||||
db.close();
|
||||
db.close();
|
||||
if (!success) {
|
||||
return { workspace: null, message };
|
||||
}
|
||||
|
@ -104,7 +104,9 @@ async function chatWithWorkspace(workspace, message, chatMode = "chat") {
|
||||
error: null,
|
||||
};
|
||||
} 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 {
|
||||
response,
|
||||
|
Loading…
Reference in New Issue
Block a user