Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Anything Llm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
Mintplex Labs
Anything Llm
Commits
24823cb5
Commit
24823cb5
authored
1 year ago
by
timothycarambat
Browse files
Options
Downloads
Patches
Plain Diff
patch workspace chat history windows to persist most recent chats, not the top n
parent
67c85f15
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/models/workspaceChats.js
+9
-8
9 additions, 8 deletions
server/models/workspaceChats.js
server/utils/chats/index.js
+25
-7
25 additions, 7 deletions
server/utils/chats/index.js
with
34 additions
and
15 deletions
server/models/workspaceChats.js
+
9
−
8
View file @
24823cb5
...
...
@@ -21,7 +21,8 @@ const WorkspaceChats = {
forWorkspaceByUser
:
async
function
(
workspaceId
=
null
,
userId
=
null
,
limit
=
null
limit
=
null
,
orderBy
=
null
)
{
if
(
!
workspaceId
||
!
userId
)
return
[];
try
{
...
...
@@ -32,9 +33,7 @@ const WorkspaceChats = {
include
:
true
,
},
...(
limit
!==
null
?
{
take
:
limit
}
:
{}),
orderBy
:
{
id
:
"
asc
"
,
},
...(
orderBy
!==
null
?
{
orderBy
}
:
{
orderBy
:
{
id
:
"
asc
"
}
}),
});
return
chats
;
}
catch
(
error
)
{
...
...
@@ -43,7 +42,11 @@ const WorkspaceChats = {
}
},
forWorkspace
:
async
function
(
workspaceId
=
null
,
limit
=
null
)
{
forWorkspace
:
async
function
(
workspaceId
=
null
,
limit
=
null
,
orderBy
=
null
)
{
if
(
!
workspaceId
)
return
[];
try
{
const
chats
=
await
prisma
.
workspace_chats
.
findMany
({
...
...
@@ -52,9 +55,7 @@ const WorkspaceChats = {
include
:
true
,
},
...(
limit
!==
null
?
{
take
:
limit
}
:
{}),
orderBy
:
{
id
:
"
asc
"
,
},
...(
orderBy
!==
null
?
{
orderBy
}
:
{
orderBy
:
{
id
:
"
asc
"
}
}),
});
return
chats
;
}
catch
(
error
)
{
...
...
This diff is collapsed.
Click to expand it.
server/utils/chats/index.js
+
25
−
7
View file @
24823cb5
...
...
@@ -87,10 +87,22 @@ async function chatWithWorkspace(
};
}
const
messageLimit
=
workspace
?.
openAiHistory
||
20
;
const
hasVectorizedSpace
=
await
VectorDb
.
hasNamespace
(
workspace
.
slug
);
const
embeddingsCount
=
await
VectorDb
.
namespaceCount
(
workspace
.
slug
);
if
(
!
hasVectorizedSpace
||
embeddingsCount
===
0
)
{
const
rawHistory
=
await
WorkspaceChats
.
forWorkspace
(
workspace
.
id
);
const
rawHistory
=
(
user
?
await
WorkspaceChats
.
forWorkspaceByUser
(
workspace
.
id
,
user
.
id
,
messageLimit
,
{
id
:
"
desc
"
}
)
:
await
WorkspaceChats
.
forWorkspace
(
workspace
.
id
,
messageLimit
,
{
id
:
"
desc
"
,
})
).
reverse
();
const
chatHistory
=
convertToPromptHistory
(
rawHistory
);
const
response
=
await
LLMConnector
.
sendChat
(
chatHistory
,
...
...
@@ -114,12 +126,18 @@ async function chatWithWorkspace(
error
:
null
,
};
}
else
{
var
messageLimit
=
workspace
?.
openAiHistory
;
const
rawHistory
=
await
WorkspaceChats
.
forWorkspace
(
workspace
.
id
,
messageLimit
);
const
rawHistory
=
(
user
?
await
WorkspaceChats
.
forWorkspaceByUser
(
workspace
.
id
,
user
.
id
,
messageLimit
,
{
id
:
"
desc
"
}
)
:
await
WorkspaceChats
.
forWorkspace
(
workspace
.
id
,
messageLimit
,
{
id
:
"
desc
"
,
})
).
reverse
();
const
chatHistory
=
convertToPromptHistory
(
rawHistory
);
const
{
response
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment