Skip to content

Commit

Permalink
system/default prompt to front
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcb committed Dec 5, 2024
1 parent 4b1a522 commit e4c1190
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/BE/Controllers/Chats/Prompts/PromptsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public async Task<ActionResult<PromptDto[]>> GetPrompts(CancellationToken cancel
{
PromptDto[] prompts = await db.Prompts
.Where(x => x.CreateUserId == currentUser.Id || currentUser.IsAdmin && x.IsSystem)
.OrderBy(x => x.UpdatedAt)
.OrderBy(x => x.IsSystem)
.ThenBy(x => x.IsDefault)
.ThenBy(x => x.UpdatedAt)
.Select(x => new PromptDto()
{
Content = x.Content,
Expand All @@ -36,7 +38,9 @@ public async Task<ActionResult<BriefPromptDto[]>> GetBriefPrompts(CancellationTo
{
BriefPromptDto[] prompts = await db.Prompts
.Where(x => x.CreateUserId == currentUser.Id || currentUser.IsAdmin && x.IsSystem)
.OrderBy(x => x.UpdatedAt)
.OrderBy(x => x.IsSystem)
.ThenBy(x => x.IsDefault)
.ThenBy(x => x.UpdatedAt)
.Select(x => new BriefPromptDto()
{
Id = x.Id,
Expand Down Expand Up @@ -78,7 +82,7 @@ public async Task<ActionResult<PromptDto>> GetDefaultPrompt(CancellationToken ca
.FirstOrDefaultAsync(cancellationToken);
Prompt? systemDefault = await db.Prompts
.OrderByDescending(x => x.UpdatedAt)
.Where(x => x.IsDefault && x.IsSystem)
.Where(x => x.IsSystem)
.FirstOrDefaultAsync(cancellationToken);
Prompt? consolidated = userDefault ?? systemDefault;

Expand Down
9 changes: 8 additions & 1 deletion src/scripts/20241129-file.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1350,4 +1350,11 @@ FROM [dbo].[MessageContent]
WHERE ContentTypeId = 2;

ALTER TABLE [dbo].[MessageContent]
DROP COLUMN [Content];
DROP COLUMN [Content];


-- 20241205
EXECUTE sp_rename N'dbo.MessageContentUTF16', N'MessageContentText', 'OBJECT';
INSERT INTO MessageContentText(Id, Content)
SELECT Id, Content FROM MessageContentUTF8;
DROP TABLE MessageContentUTF8;

0 comments on commit e4c1190

Please sign in to comment.