fix: 机器人对接成功
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
				
			|||||||
@page "/"
 | 
					@page "/"
 | 
				
			||||||
@using Frontend.Models
 | 
					@using Frontend.Models
 | 
				
			||||||
@using Katheryne.Abstractions
 | 
					@using Katheryne.Services
 | 
				
			||||||
@inject IServiceProvider ServiceProvider
 | 
					@inject KatheryneChatRobotFactory ChatRobotFactory
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<Layout>
 | 
					<Layout>
 | 
				
			||||||
@@ -51,8 +51,24 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    protected override void OnInitialized()
 | 
					    protected override void OnInitialized()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Chat chat = GetInitChat();
 | 
					        ChatRobotFactory.SetGrammar(@"
 | 
				
			||||||
 | 
					                                    robotName: 凯瑟琳
 | 
				
			||||||
 | 
					                                    stages:
 | 
				
			||||||
 | 
					                                      - name: start
 | 
				
			||||||
 | 
					                                        answer: 向着星辰和深渊!欢迎来到冒险家协会。
 | 
				
			||||||
 | 
					                                        transformers:
 | 
				
			||||||
 | 
					                                          - pattern: .*?
 | 
				
			||||||
 | 
					                                            nextStageName: running
 | 
				
			||||||
                                        
 | 
					                                        
 | 
				
			||||||
 | 
					                                      - name: running
 | 
				
			||||||
 | 
					                                        answer: 对不起,做不到。
 | 
				
			||||||
 | 
					                                        transformers:
 | 
				
			||||||
 | 
					                                          - pattern: .*?
 | 
				
			||||||
 | 
					                                            nextStageName: running
 | 
				
			||||||
 | 
					                                    beginStageName: start
 | 
				
			||||||
 | 
					                                    ");
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        Chat chat = GetInitChat();
 | 
				
			||||||
        _chatDictionary.Add(chat.Guid, chat);
 | 
					        _chatDictionary.Add(chat.Guid, chat);
 | 
				
			||||||
        _currentGuid = chat.Guid;
 | 
					        _currentGuid = chat.Guid;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -79,7 +95,7 @@
 | 
				
			|||||||
        var chat = new Chat
 | 
					        var chat = new Chat
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Title = $"对话:{_chatDictionary.Count + 1}",
 | 
					            Title = $"对话:{_chatDictionary.Count + 1}",
 | 
				
			||||||
            Robot = ServiceProvider.GetRequiredService<IChatRobot>()
 | 
					            Robot = ChatRobotFactory.GetRobot()
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach (string answer in chat.Robot.OnChatStart())
 | 
					        foreach (string answer in chat.Robot.OnChatStart())
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,12 +1,11 @@
 | 
				
			|||||||
using Katheryne;
 | 
					using Katheryne;
 | 
				
			||||||
using Katheryne.Abstractions;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
 | 
					WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
 | 
				
			||||||
builder.Services.AddRazorPages();
 | 
					builder.Services.AddRazorPages();
 | 
				
			||||||
builder.Services.AddServerSideBlazor();
 | 
					builder.Services.AddServerSideBlazor();
 | 
				
			||||||
builder.Services.AddAntDesign();
 | 
					builder.Services.AddAntDesign();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
builder.Services.AddTransient<IChatRobot, DefaultChatRobot>();
 | 
					builder.Services.AddKatheryne();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebApplication app = builder.Build();
 | 
					WebApplication app = builder.Build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,8 @@
 | 
				
			|||||||
  "Logging": {
 | 
					  "Logging": {
 | 
				
			||||||
    "LogLevel": {
 | 
					    "LogLevel": {
 | 
				
			||||||
      "Default": "Information",
 | 
					      "Default": "Information",
 | 
				
			||||||
      "Microsoft.AspNetCore": "Warning"
 | 
					      "Microsoft.AspNetCore": "Warning",
 | 
				
			||||||
 | 
					      "Katheryne": "Debug"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,7 @@ namespace Katheryne;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public static class ServiceCollectionExtensions
 | 
					public static class ServiceCollectionExtensions
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public static void AddYamlDeserializerFactory(this IServiceCollection collection)
 | 
					    public static void AddKatheryne(this IServiceCollection collection)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        collection.AddSingleton<YamlDeserializerFactory>();
 | 
					        collection.AddSingleton<YamlDeserializerFactory>();
 | 
				
			||||||
        collection.AddSingleton<DefaultChatRobot>();
 | 
					        collection.AddSingleton<DefaultChatRobot>();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user