Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/BootstrapBlazor.Server/Components/Pages/Chats.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@

<h4>@Localizer["ChatsDescription"]</h4>

<HeadContent>
<style>
.bb-ad {
display: none;
}
</style>
</HeadContent>

<DemoBlock Title="@Localizer["ChatNormalTitle"]" Introduction="@Localizer["ChatNormalIntro"]" Name="Normal" ShowCode="false">
<div class="chat-title">@Localizer["ChatUserTitle"]</div>
<div class="chat-body">
Expand Down Expand Up @@ -47,7 +55,7 @@
}
</div>
<div class="chat-footer">
<label class="chat-info">@((MarkupString)Localizer["ChatInfo", _currentCount, _totalCount].Value)</label>
<label class="chat-info">@((MarkupString)Localizer["ChatInfo", _currentCount, TotalCount].Value)</label>
<div class="d-flex">
<Textarea Id="@Id" class="chat-footer-tx" rows="3" @bind-Value="@Context" PlaceHolder="Type user query here. (Shift + Enter for new line)"></Textarea>
<div class="chat-buttons">
Expand Down
12 changes: 4 additions & 8 deletions src/BootstrapBlazor.Server/Components/Pages/Chats.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@ public partial class Chats
.AddClass("msg-stack-assistant", role == ChatRole.Assistant)
.Build();

private static readonly ConcurrentDictionary<string, int> _cache = new();

private const int TotalCount = 50;
private static readonly ConcurrentDictionary<string, int> Cache = new();
private string? _code;

private readonly int _totalCount = 50;

private int _currentCount;

private bool _isDisabled;

/// <summary>
Expand All @@ -51,7 +47,7 @@ protected override async Task OnInitializedAsync()
await base.OnInitializedAsync();

_code = await GetFingerCodeAsync();
_currentCount = _cache.GetOrAdd(_code, key => _totalCount);
_currentCount = Cache.GetOrAdd(_code, key => TotalCount);
_isDisabled = _currentCount < 1;
}

Expand Down Expand Up @@ -112,7 +108,7 @@ private async Task GetCompletionsAsync()
await Task.Delay(100);
if (!string.IsNullOrEmpty(_code))
{
_currentCount = _cache.AddOrUpdate(_code, key => _totalCount, (key, number) => number - 1);
_currentCount = Cache.AddOrUpdate(_code, key => TotalCount, (key, number) => number - 1);
_isDisabled = _currentCount < 1;
}
else
Expand Down
13 changes: 12 additions & 1 deletion src/BootstrapBlazor.Server/Components/Pages/Chats.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.chat-body {
min-height: 210px;
max-height: 786px;
max-height: calc(100vh - 441px);
overflow-y: auto;
background-color: #faf9f8;
}
Expand Down Expand Up @@ -53,6 +53,17 @@
flex: 1;
}

::deep div:has(pre) {
overflow: hidden;
}

::deep pre {
margin-bottom: 1rem;
border: 1px solid #ddd;
border-radius: var(--bs-border-radius);
padding: 4px 10px;
}

.chat-auth {
margin-top: .5rem;
}
Expand Down