Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
snake.lin committed May 26, 2024
1 parent 5616042 commit b1ef4cc
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 175 deletions.
151 changes: 34 additions & 117 deletions client/AI.Chat.Copilot/Controls/Chat/Chat.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,137 +18,54 @@
<UserControl.DataTemplates>
<dataTemplates:RoleChatTemplateSelector>
<DataTemplate x:Key="assistant" DataType="model:AppChatMessage">
<StackPanel HorizontalAlignment="Stretch" Margin="5" VerticalAlignment="Stretch">
<Grid ColumnDefinitions="30,*" >
<StackPanel Margin="5">
<Grid x:Name="chatGrid" ColumnDefinitions="30,*" >
<Border Grid.Column="0" Height="30" Width="30" CornerRadius="50" ClipToBounds="True" VerticalAlignment="Top">
<Image Source="/Assets/GPT.png"></Image>
</Border>
<sk:GlassCard Grid.Column="1" CornerRadius="12" Margin="10,0,0,0" HorizontalAlignment="Left" Padding="10" VerticalAlignment="Stretch">
<Grid RowDefinitions="*,*" MinWidth="100" ColumnDefinitions="*">
<Button Grid.Row="0" Command="{Binding ((vm:ChatViewModel)DataContext).CopyCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding Content}" Classes="Basic" HorizontalAlignment="Right" Margin="0,-10,-10,-5" Cursor="Hand">
<materialIcons:MaterialIcon Kind="ContentCopy" Foreground="{DynamicResource SukiText}"></materialIcons:MaterialIcon>
</Button>
<StackPanel Grid.Row="1">
<mdxaml:MarkdownScrollViewer SelectionEnabled="True" Markdown="{Binding Content, Converter={StaticResource MC}}" ScrollValue="" >
<!--<mdxaml:MarkdownScrollViewer.Styles>
<Style Selector=".Markdown_Avalonia_MarkdownViewer ctxt|CTextBlock">
<Style.Setters>
<Setter Property="SelectionBrush" Value="LightBlue"></Setter>
<Setter Property="FontSize" Value="16" />
<Setter Property="FontFamily" Value="{StaticResource QuicksandFont}"></Setter>
<Setter Property="Margin" Value="0,3" />
</Style.Setters>
</Style>
<Style Selector=".Markdown_Avalonia_MarkdownViewer TextBlock">
<Style.Setters>
<Setter Property="FontSize" Value="16" />
<Setter Property="FontFamily" Value="{StaticResource QuicksandFont}"></Setter>
</Style.Setters>
</Style>
<Style Selector="ctxt|CTextBlock.Heading1">
<Setter Property="Foreground" Value="{DynamicResource SukiText}"/>
<Setter Property="Margin" Value="0,8"></Setter>
</Style>
<Style Selector="ctxt|CTextBlock.Heading2">
<Setter Property="Foreground" Value="{DynamicResource SukiText}"/>
<Setter Property="Margin" Value="0,6"></Setter>
</Style>
<Style Selector="ctxt|CTextBlock.Heading3">
<Setter Property="Foreground" Value="{DynamicResource SukiText}"/>
<Setter Property="Margin" Value="0,4"></Setter>
</Style>
<Style Selector="ctxt|CTextBlock.Heading4">
<Setter Property="Foreground" Value="{DynamicResource SukiText}"/>
<Setter Property="Margin" Value="0,2"></Setter>
</Style>
<Style Selector="ctxt|CTextBlock.Heading5">
<Setter Property="Foreground" Value="{DynamicResource SukiText}"/>
</Style>
<Style Selector="ctxt|CTextBlock.Heading6">
<Setter Property="Foreground" Value="{DynamicResource SukiText}"/>
</Style>
<Style Selector="ctxt|CCode">
<Style.Setters>
<Setter Property="FontFamily" Value="{StaticResource QuicksandFont}"></Setter>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="CornerRadius" Value="7"/>
<Setter Property="Padding" Value="5,5,5,1"/>
<Setter Property="Margin" Value="1,0"></Setter>
</Style.Setters>
</Style>
<Style Selector=".Markdown_Avalonia_MarkdownViewer ctxt|CCode">
<Style.Setters>
<Setter Property="FontFamily" Value="{StaticResource QuicksandFont}"></Setter>
<Setter Property="FontWeight" Value="Normal"></Setter>
<Setter Property="Foreground" Value="LightBlue" />
<Setter Property="Background" Value="{DynamicResource SukiAccentColor5}" />
</Style.Setters>
</Style>
<Style Selector="Border.CodeBlock">
<Style.Setters>
<Setter Property="CornerRadius" Value="10" />
<Setter Property="BorderBrush" Value="{DynamicResource SukiAccentColor5}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="12"></Setter>
<Setter Property="Margin" Value="5,10"/>
<Setter Property="Background" Value="{DynamicResource SukiAccentColor5}"/>
</Style.Setters>
</Style>
<Style Selector="TextBlock.CodeBlock">
<Style.Setters>
<Setter Property="Foreground" Value="{DynamicResource SukiText}"/>
</Style.Setters>
</Style>
<Style Selector="AccessText">
<Style.Setters>
<Setter Property="Foreground" Value="{DynamicResource SukiText}"/>
<Setter Property="FontFamily" Value="{StaticResource QuicksandFont}"></Setter>
</Style.Setters>
</Style>
<Style Selector="TextBlock">
<Style.Setters>
<Setter Property="Foreground" Value="{DynamicResource SukiText}"/>
<Setter Property="FontFamily" Value="{StaticResource QuicksandFont}"></Setter>
</Style.Setters>
</Style>
</mdxaml:MarkdownScrollViewer.Styles>-->
</mdxaml:MarkdownScrollViewer>
<Panel IsVisible="{Binding IsWriting}" HorizontalAlignment="Center" Margin="5,25,5,0">
<Panel.Transitions>
<StackPanel Grid.Column="1">
<sk:GlassCard CornerRadius="12" Margin="10,0,0,0" HorizontalAlignment="Left" Padding="10" >
<SelectableTextBlock Text="{Binding Content}" Classes="chatTextBoxStyle"></SelectableTextBlock>
<!--<StackPanel>
<mdxaml:MarkdownScrollViewer SelectionEnabled="True" Markdown="{Binding Content, Converter={StaticResource MC}}" >
</mdxaml:MarkdownScrollViewer>
<Panel IsVisible="{Binding IsWriting}" HorizontalAlignment="Center" Margin="5,25,5,0">
--><!--<Panel.Transitions>
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.25"></DoubleTransition>
</Transitions>
</Panel.Transitions>

<Panel.Resources>
<Color x:Key="SukiPrimaryColor">#cf1322</Color>
</Panel.Resources>
<Button BorderThickness="0" Command="{Binding ((vm:ChatViewModel)DataContext).StopCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding}" Margin="0,0,0,0" Classes="Basic Rounded" Cursor="Hand" >
<materialIcons:MaterialIcon Kind="Stop" Foreground="{DynamicResource SukiText}"></materialIcons:MaterialIcon>
</Button>
</Panel>
</StackPanel>
</Grid>
</Panel.Transitions>--><!--
<Button BorderThickness="0" Command="{Binding ((vm:ChatViewModel)DataContext).StopCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding}" Classes="Basic Rounded" Cursor="Hand" >
<materialIcons:MaterialIcon Kind="Stop" Foreground="{DynamicResource SukiText}"></materialIcons:MaterialIcon>
</Button>
</Panel>
</StackPanel>-->
</sk:GlassCard>
<Button HorizontalAlignment="Left"
Command="{Binding ((vm:ChatViewModel)DataContext).CopyCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
CommandParameter="{Binding Content}" Classes="Basic" Cursor="Hand">
<materialIcons:MaterialIcon Kind="ContentCopy" Foreground="{DynamicResource SukiText}"></materialIcons:MaterialIcon>
</Button>
</StackPanel>
</Grid>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="user" DataType="model:AppChatMessage">
<StackPanel HorizontalAlignment="Stretch" Margin="5">
<Grid ColumnDefinitions="30,Auto,30">
<Border Grid.Column="0" Height="30" Width="30" CornerRadius="50" ClipToBounds="True" VerticalAlignment="Top">
<StackPanel Margin="5">
<Grid x:Name="chatGrid" ColumnDefinitions="30,*">
<Border Grid.Column="0" Height="30" Width="30" CornerRadius="50" ClipToBounds="True" VerticalAlignment="Top">
<Image Source="/Assets/default-user.png"></Image>
</Border>
<sk:GlassCard Grid.Column="1" CornerRadius="12" Margin="10,0,0,0" HorizontalAlignment="Left" Padding="10" >
<SelectableTextBlock Text="{Binding Content}" Classes="chatTextBoxStyle"></SelectableTextBlock>
</sk:GlassCard>
<Button Grid.Column="2" VerticalAlignment="Top"
Command="{Binding ((vm:ChatViewModel)DataContext).CopyCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
CommandParameter="{Binding Content}" Classes="Basic" Cursor="Hand">
<StackPanel Grid.Column="1">
<sk:GlassCard CornerRadius="12" Margin="10,0,0,0" HorizontalAlignment="Left" Padding="10" >
<SelectableTextBlock Text="{Binding Content}" Classes="chatTextBoxStyle"></SelectableTextBlock>
</sk:GlassCard>
<Button HorizontalAlignment="Left"
Command="{Binding ((vm:ChatViewModel)DataContext).CopyCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
CommandParameter="{Binding Content}" Classes="Basic" Cursor="Hand">
<materialIcons:MaterialIcon Kind="ContentCopy" Foreground="{DynamicResource SukiText}"></materialIcons:MaterialIcon>
</Button>
</Button>
</StackPanel>
</Grid>
</StackPanel>
</DataTemplate>
Expand Down
1 change: 1 addition & 0 deletions client/AI.Chat.Copilot/Controls/Chat/Chat.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity;
using Avalonia.LogicalTree;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
using AvaloniaEdit.Utils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Remove="AIChatService\AzureOpenAIChatService.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00016" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.13.0" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Core" Version="1.13.0-alpha" />
<PackageReference Include="SharpToken" Version="2.0.3" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using AI.Chat.Copilot.Domain.Models;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Plugins.Core;
using System;
Expand All @@ -16,10 +18,17 @@ public abstract class AIChatBaseService
protected Kernel CreateChatKernelByApp(AIApps app)
{
var builder = Kernel.CreateBuilder();
builder.Services.AddLogging(config =>
{
config.SetMinimumLevel(LogLevel.Trace);
config.AddConsole();
});
AddChatComplateService(app, builder);
#pragma warning disable SKEXP0050 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
builder.Plugins.AddFromType<ConversationSummaryPlugin>();
builder.Plugins.AddFromType<ConversationSummaryPlugin>()
.AddFromType<TimePlugin>();
#pragma warning restore SKEXP0050 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

return builder.Build();
}
protected abstract void AddChatComplateService(AIApps app,IKernelBuilder builder);
Expand Down
Loading

0 comments on commit b1ef4cc

Please sign in to comment.