From 979fbcfd7da9531217e2dcf52025eba3696dded5 Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Wed, 3 Oct 2018 06:58:34 -0500 Subject: [PATCH] seperate platfrom extension --- BotSharp.Core/BotSharp.Core.csproj | 2 +- BotSharp.RestApi/BotSharp.RestApi.csproj | 6 +- BotSharp.RestApi/BotSharp.RestApi.xml | 94 ------ BotSharp.WebHost/BotSharp.WebHost.csproj | 6 +- BotSharp.sln | 178 +---------- .../AgentImporterInDialogflow.cs | 293 ------------------ .../Controllers/AgentController.cs | 89 ------ .../Controllers/EntitiesController.cs | 25 -- .../Controllers/IntentsController.cs | 55 ---- .../Controllers/QueryController.cs | 105 ------- .../Controllers/TrainController.cs | 53 ---- Platform.Dialogflow/DialogflowAi.cs | 165 ---------- Platform.Dialogflow/Models/AIConfiguration.cs | 73 ----- Platform.Dialogflow/Models/AIContext.cs | 27 -- Platform.Dialogflow/Models/AIDataService.cs | 180 ----------- Platform.Dialogflow/Models/AIRequest.cs | 51 --- Platform.Dialogflow/Models/AIResponse.cs | 34 -- .../Models/AIResponseCustomPayload.cs | 13 - .../Models/AIResponseFulfillment.cs | 13 - .../Models/AIResponseMessageBase.cs | 12 - .../Models/AIResponseMetadata.cs | 12 - .../Models/AIResponseResult.cs | 150 --------- .../Models/AIResponseStatus.cs | 17 - .../Models/AIServiceException.cs | 48 --- Platform.Dialogflow/Models/AgentModel.cs | 52 ---- .../Models/DialogflowAgentImportModel.cs | 20 -- .../Models/DialogflowEntity.cs | 42 --- .../Models/DialogflowEntityEntry.cs | 33 -- .../Models/DialogflowIntent.cs | 24 -- .../Models/DialogflowIntentEvent.cs | 11 - .../Models/DialogflowIntentExpression.cs | 13 - .../Models/DialogflowIntentExpressionPart.cs | 15 - .../Models/DialogflowIntentResponse.cs | 24 -- .../Models/DialogflowIntentResponseMessage.cs | 12 - .../DialogflowIntentResponseParameter.cs | 23 -- ...DialogflowIntentResponseParameterPrompt.cs | 13 - Platform.Dialogflow/Models/EntityEntry.cs | 28 -- Platform.Dialogflow/Models/EntityModel.cs | 19 -- Platform.Dialogflow/Models/EntityType.cs | 45 --- Platform.Dialogflow/Models/EntrySynonym.cs | 25 -- Platform.Dialogflow/Models/OriginalRequest.cs | 17 - .../Models/QuestionMetadata.cs | 23 -- Platform.Dialogflow/Models/RequestExtras.cs | 62 ---- Platform.Dialogflow/MultipartHttpClient.cs | 95 ------ .../Platform.Dialogflow.csproj | 37 --- .../DialogflowAllEntityViewModel.cs | 17 - Platform.Dialogflow/ViewModels/QueryModel.cs | 49 --- README.rst | 4 - README_zh.rst | 4 - 49 files changed, 15 insertions(+), 2393 deletions(-) delete mode 100644 Platform.Dialogflow/AgentImporterInDialogflow.cs delete mode 100644 Platform.Dialogflow/Controllers/AgentController.cs delete mode 100644 Platform.Dialogflow/Controllers/EntitiesController.cs delete mode 100644 Platform.Dialogflow/Controllers/IntentsController.cs delete mode 100644 Platform.Dialogflow/Controllers/QueryController.cs delete mode 100644 Platform.Dialogflow/Controllers/TrainController.cs delete mode 100644 Platform.Dialogflow/DialogflowAi.cs delete mode 100644 Platform.Dialogflow/Models/AIConfiguration.cs delete mode 100644 Platform.Dialogflow/Models/AIContext.cs delete mode 100644 Platform.Dialogflow/Models/AIDataService.cs delete mode 100644 Platform.Dialogflow/Models/AIRequest.cs delete mode 100644 Platform.Dialogflow/Models/AIResponse.cs delete mode 100644 Platform.Dialogflow/Models/AIResponseCustomPayload.cs delete mode 100644 Platform.Dialogflow/Models/AIResponseFulfillment.cs delete mode 100644 Platform.Dialogflow/Models/AIResponseMessageBase.cs delete mode 100644 Platform.Dialogflow/Models/AIResponseMetadata.cs delete mode 100644 Platform.Dialogflow/Models/AIResponseResult.cs delete mode 100644 Platform.Dialogflow/Models/AIResponseStatus.cs delete mode 100644 Platform.Dialogflow/Models/AIServiceException.cs delete mode 100644 Platform.Dialogflow/Models/AgentModel.cs delete mode 100644 Platform.Dialogflow/Models/DialogflowAgentImportModel.cs delete mode 100644 Platform.Dialogflow/Models/DialogflowEntity.cs delete mode 100644 Platform.Dialogflow/Models/DialogflowEntityEntry.cs delete mode 100644 Platform.Dialogflow/Models/DialogflowIntent.cs delete mode 100644 Platform.Dialogflow/Models/DialogflowIntentEvent.cs delete mode 100644 Platform.Dialogflow/Models/DialogflowIntentExpression.cs delete mode 100644 Platform.Dialogflow/Models/DialogflowIntentExpressionPart.cs delete mode 100644 Platform.Dialogflow/Models/DialogflowIntentResponse.cs delete mode 100644 Platform.Dialogflow/Models/DialogflowIntentResponseMessage.cs delete mode 100644 Platform.Dialogflow/Models/DialogflowIntentResponseParameter.cs delete mode 100644 Platform.Dialogflow/Models/DialogflowIntentResponseParameterPrompt.cs delete mode 100644 Platform.Dialogflow/Models/EntityEntry.cs delete mode 100644 Platform.Dialogflow/Models/EntityModel.cs delete mode 100644 Platform.Dialogflow/Models/EntityType.cs delete mode 100644 Platform.Dialogflow/Models/EntrySynonym.cs delete mode 100644 Platform.Dialogflow/Models/OriginalRequest.cs delete mode 100644 Platform.Dialogflow/Models/QuestionMetadata.cs delete mode 100644 Platform.Dialogflow/Models/RequestExtras.cs delete mode 100644 Platform.Dialogflow/MultipartHttpClient.cs delete mode 100644 Platform.Dialogflow/Platform.Dialogflow.csproj delete mode 100644 Platform.Dialogflow/ViewModels/DialogflowAllEntityViewModel.cs delete mode 100644 Platform.Dialogflow/ViewModels/QueryModel.cs diff --git a/BotSharp.Core/BotSharp.Core.csproj b/BotSharp.Core/BotSharp.Core.csproj index 2dee05d0..3f86cd92 100644 --- a/BotSharp.Core/BotSharp.Core.csproj +++ b/BotSharp.Core/BotSharp.Core.csproj @@ -80,7 +80,7 @@ If you feel that this project is helpful to you, please Star on the project, we - + diff --git a/BotSharp.RestApi/BotSharp.RestApi.csproj b/BotSharp.RestApi/BotSharp.RestApi.csproj index 326872b8..5dff127a 100644 --- a/BotSharp.RestApi/BotSharp.RestApi.csproj +++ b/BotSharp.RestApi/BotSharp.RestApi.csproj @@ -20,7 +20,7 @@ - + C:\Users\haipi\Documents\Projects\BotSharp\BotSharp.RestApi\BotSharp.RestApi.xml TRACE;DEBUG @@ -85,13 +85,13 @@ - + + - diff --git a/BotSharp.RestApi/BotSharp.RestApi.xml b/BotSharp.RestApi/BotSharp.RestApi.xml index 64f1d4d7..ff7cfa9f 100644 --- a/BotSharp.RestApi/BotSharp.RestApi.xml +++ b/BotSharp.RestApi/BotSharp.RestApi.xml @@ -4,100 +4,6 @@ BotSharp.RestApi - - - Agent - - - - - Initialize dialog controller and get a platform instance - - - - - - Restore a agent from a uploaded zip file - - - - - - - Dump agent - - - - - - - The /entities endpoint is used to create, retrieve, update, and delete developer-defined entity objects. - - - - - Dialogflow mode query controller - - - - - Initialize dialog controller and get a platform instance - - - - - - The query endpoint is used to process natural language in the form of text. - The query requests return structured data in JSON format with an action and parameters for that action. - Both GET and POST methods return the same JSON response. - - - - - - - Array of additional context objects. Should be sent via a POST /query request. - Contexts sent in a query are activated before the query. - - - - - Object containing event name and additional data. - The "data" parameter can be submitted only in POST requests. - - - - - Language tag, e.g., en, es etc. - - - - - Natural language text to be processed. Query length should not exceed 256 characters. - - - - - A string token up to 36 symbols long, used to identify the client and to manage session parameters (including contexts) per client. - - - - - Time zone from IANA Time Zone Database Examples: America/New_York, Europe/Paris - - - - - You can post your training data to this endpoint to train a new model for a project. - This request will wait for the server answer: either the model was trained successfully or the training exited with an error. - - - - - Initialize dialog controller and get a platform instance - - - PAGE_ID diff --git a/BotSharp.WebHost/BotSharp.WebHost.csproj b/BotSharp.WebHost/BotSharp.WebHost.csproj index bf91e803..3a76b13b 100644 --- a/BotSharp.WebHost/BotSharp.WebHost.csproj +++ b/BotSharp.WebHost/BotSharp.WebHost.csproj @@ -65,13 +65,11 @@ - - - - + + diff --git a/BotSharp.sln b/BotSharp.sln index 767e8775..bc39fae6 100644 --- a/BotSharp.sln +++ b/BotSharp.sln @@ -29,264 +29,104 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Platform.Abstracti EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Platform.Models", "BotSharp.Platform.Models\BotSharp.Platform.Models.csproj", "{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Platform.Articulate", "Platform.Articulate\Platform.Articulate.csproj", "{2B279A6C-C829-4D29-9C1C-809C8A8E36B2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Platform.Dialogflow", "Platform.Dialogflow\Platform.Dialogflow.csproj", "{25503190-0B4B-4ECA-8C0C-D12A53A09583}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Platform.Dialogflow", "..\botsharp-dialogflow\BotSharp.Platform.Dialogflow\BotSharp.Platform.Dialogflow.csproj", "{B865F070-9693-47C6-B901-40121F659C6F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - ARTICULATE|Any CPU = ARTICULATE|Any CPU - ARTICULATE|x64 = ARTICULATE|x64 Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 - DIALOGFLOW|Any CPU = DIALOGFLOW|Any CPU - DIALOGFLOW|x64 = DIALOGFLOW|x64 - RASA|Any CPU = RASA|Any CPU - RASA|x64 = RASA|x64 Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {95780673-2A1A-4953-962F-C46CBFDD07FF}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU - {95780673-2A1A-4953-962F-C46CBFDD07FF}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU - {95780673-2A1A-4953-962F-C46CBFDD07FF}.ARTICULATE|x64.ActiveCfg = ARTICULATE|x64 - {95780673-2A1A-4953-962F-C46CBFDD07FF}.ARTICULATE|x64.Build.0 = ARTICULATE|x64 {95780673-2A1A-4953-962F-C46CBFDD07FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {95780673-2A1A-4953-962F-C46CBFDD07FF}.Debug|Any CPU.Build.0 = Debug|Any CPU {95780673-2A1A-4953-962F-C46CBFDD07FF}.Debug|x64.ActiveCfg = Debug|x64 {95780673-2A1A-4953-962F-C46CBFDD07FF}.Debug|x64.Build.0 = Debug|x64 - {95780673-2A1A-4953-962F-C46CBFDD07FF}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU - {95780673-2A1A-4953-962F-C46CBFDD07FF}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU - {95780673-2A1A-4953-962F-C46CBFDD07FF}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|x64 - {95780673-2A1A-4953-962F-C46CBFDD07FF}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|x64 - {95780673-2A1A-4953-962F-C46CBFDD07FF}.RASA|Any CPU.ActiveCfg = RASA|Any CPU - {95780673-2A1A-4953-962F-C46CBFDD07FF}.RASA|Any CPU.Build.0 = RASA|Any CPU - {95780673-2A1A-4953-962F-C46CBFDD07FF}.RASA|x64.ActiveCfg = RASA|x64 - {95780673-2A1A-4953-962F-C46CBFDD07FF}.RASA|x64.Build.0 = RASA|x64 {95780673-2A1A-4953-962F-C46CBFDD07FF}.Release|Any CPU.ActiveCfg = Release|Any CPU {95780673-2A1A-4953-962F-C46CBFDD07FF}.Release|Any CPU.Build.0 = Release|Any CPU {95780673-2A1A-4953-962F-C46CBFDD07FF}.Release|x64.ActiveCfg = Release|x64 {95780673-2A1A-4953-962F-C46CBFDD07FF}.Release|x64.Build.0 = Release|x64 - {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU - {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU - {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.ARTICULATE|x64.ActiveCfg = ARTICULATE|x64 - {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.ARTICULATE|x64.Build.0 = ARTICULATE|x64 {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Debug|Any CPU.Build.0 = Debug|Any CPU {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Debug|x64.ActiveCfg = Debug|x64 {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Debug|x64.Build.0 = Debug|x64 - {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU - {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU - {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|x64 - {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|x64 - {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.RASA|Any CPU.ActiveCfg = RASA|Any CPU - {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.RASA|Any CPU.Build.0 = RASA|Any CPU - {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.RASA|x64.ActiveCfg = RASA|x64 - {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.RASA|x64.Build.0 = RASA|x64 {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Release|Any CPU.ActiveCfg = Release|Any CPU {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Release|Any CPU.Build.0 = Release|Any CPU {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Release|x64.ActiveCfg = Release|x64 {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Release|x64.Build.0 = Release|x64 - {03DCA427-327A-4FC9-9A2F-57D17F16708C}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU - {03DCA427-327A-4FC9-9A2F-57D17F16708C}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU - {03DCA427-327A-4FC9-9A2F-57D17F16708C}.ARTICULATE|x64.ActiveCfg = ARTICULATE|x64 - {03DCA427-327A-4FC9-9A2F-57D17F16708C}.ARTICULATE|x64.Build.0 = ARTICULATE|x64 {03DCA427-327A-4FC9-9A2F-57D17F16708C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {03DCA427-327A-4FC9-9A2F-57D17F16708C}.Debug|Any CPU.Build.0 = Debug|Any CPU {03DCA427-327A-4FC9-9A2F-57D17F16708C}.Debug|x64.ActiveCfg = Debug|x64 {03DCA427-327A-4FC9-9A2F-57D17F16708C}.Debug|x64.Build.0 = Debug|x64 - {03DCA427-327A-4FC9-9A2F-57D17F16708C}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU - {03DCA427-327A-4FC9-9A2F-57D17F16708C}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU - {03DCA427-327A-4FC9-9A2F-57D17F16708C}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|x64 - {03DCA427-327A-4FC9-9A2F-57D17F16708C}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|x64 - {03DCA427-327A-4FC9-9A2F-57D17F16708C}.RASA|Any CPU.ActiveCfg = RASA|Any CPU - {03DCA427-327A-4FC9-9A2F-57D17F16708C}.RASA|Any CPU.Build.0 = RASA|Any CPU - {03DCA427-327A-4FC9-9A2F-57D17F16708C}.RASA|x64.ActiveCfg = RASA|x64 - {03DCA427-327A-4FC9-9A2F-57D17F16708C}.RASA|x64.Build.0 = RASA|x64 {03DCA427-327A-4FC9-9A2F-57D17F16708C}.Release|Any CPU.ActiveCfg = Release|Any CPU {03DCA427-327A-4FC9-9A2F-57D17F16708C}.Release|Any CPU.Build.0 = Release|Any CPU {03DCA427-327A-4FC9-9A2F-57D17F16708C}.Release|x64.ActiveCfg = Release|x64 {03DCA427-327A-4FC9-9A2F-57D17F16708C}.Release|x64.Build.0 = Release|x64 - {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU - {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU - {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.ARTICULATE|x64.ActiveCfg = ARTICULATE|x64 - {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.ARTICULATE|x64.Build.0 = ARTICULATE|x64 {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Debug|Any CPU.Build.0 = Debug|Any CPU {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Debug|x64.ActiveCfg = Debug|x64 {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Debug|x64.Build.0 = Debug|x64 - {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU - {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU - {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|x64 - {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|x64 - {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.RASA|Any CPU.ActiveCfg = RASA|Any CPU - {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.RASA|Any CPU.Build.0 = RASA|Any CPU - {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.RASA|x64.ActiveCfg = RASA|x64 - {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.RASA|x64.Build.0 = RASA|x64 {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Release|Any CPU.ActiveCfg = Release|Any CPU {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Release|Any CPU.Build.0 = Release|Any CPU {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Release|x64.ActiveCfg = Release|x64 {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Release|x64.Build.0 = Release|x64 - {184F8B93-68C2-4849-9625-4023C4360990}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU - {184F8B93-68C2-4849-9625-4023C4360990}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU - {184F8B93-68C2-4849-9625-4023C4360990}.ARTICULATE|x64.ActiveCfg = ARTICULATE|Any CPU - {184F8B93-68C2-4849-9625-4023C4360990}.ARTICULATE|x64.Build.0 = ARTICULATE|Any CPU {184F8B93-68C2-4849-9625-4023C4360990}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {184F8B93-68C2-4849-9625-4023C4360990}.Debug|Any CPU.Build.0 = Debug|Any CPU {184F8B93-68C2-4849-9625-4023C4360990}.Debug|x64.ActiveCfg = Debug|Any CPU {184F8B93-68C2-4849-9625-4023C4360990}.Debug|x64.Build.0 = Debug|Any CPU - {184F8B93-68C2-4849-9625-4023C4360990}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU - {184F8B93-68C2-4849-9625-4023C4360990}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU - {184F8B93-68C2-4849-9625-4023C4360990}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|Any CPU - {184F8B93-68C2-4849-9625-4023C4360990}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|Any CPU - {184F8B93-68C2-4849-9625-4023C4360990}.RASA|Any CPU.ActiveCfg = RASA|Any CPU - {184F8B93-68C2-4849-9625-4023C4360990}.RASA|Any CPU.Build.0 = RASA|Any CPU - {184F8B93-68C2-4849-9625-4023C4360990}.RASA|x64.ActiveCfg = RASA|Any CPU - {184F8B93-68C2-4849-9625-4023C4360990}.RASA|x64.Build.0 = RASA|Any CPU {184F8B93-68C2-4849-9625-4023C4360990}.Release|Any CPU.ActiveCfg = Release|Any CPU {184F8B93-68C2-4849-9625-4023C4360990}.Release|Any CPU.Build.0 = Release|Any CPU {184F8B93-68C2-4849-9625-4023C4360990}.Release|x64.ActiveCfg = Release|Any CPU {184F8B93-68C2-4849-9625-4023C4360990}.Release|x64.Build.0 = Release|Any CPU - {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU - {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU - {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.ARTICULATE|x64.ActiveCfg = ARTICULATE|Any CPU - {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.ARTICULATE|x64.Build.0 = ARTICULATE|Any CPU {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.Debug|Any CPU.Build.0 = Debug|Any CPU {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.Debug|x64.ActiveCfg = Debug|Any CPU {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.Debug|x64.Build.0 = Debug|Any CPU - {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU - {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU - {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU - {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU - {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.RASA|Any CPU.ActiveCfg = RASA|Any CPU - {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.RASA|Any CPU.Build.0 = RASA|Any CPU - {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.RASA|x64.ActiveCfg = Release|Any CPU - {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.RASA|x64.Build.0 = Release|Any CPU {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.Release|Any CPU.ActiveCfg = Release|Any CPU {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.Release|Any CPU.Build.0 = Release|Any CPU {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.Release|x64.ActiveCfg = Release|Any CPU {3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.Release|x64.Build.0 = Release|Any CPU - {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU - {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU - {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.ARTICULATE|x64.ActiveCfg = ARTICULATE|x64 - {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.ARTICULATE|x64.Build.0 = ARTICULATE|x64 {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Debug|Any CPU.Build.0 = Debug|Any CPU {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Debug|x64.ActiveCfg = Debug|x64 {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Debug|x64.Build.0 = Debug|x64 - {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU - {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU - {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|x64 - {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|x64 - {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.RASA|Any CPU.ActiveCfg = RASA|Any CPU - {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.RASA|Any CPU.Build.0 = RASA|Any CPU - {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.RASA|x64.ActiveCfg = RASA|x64 - {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.RASA|x64.Build.0 = RASA|x64 {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Release|Any CPU.ActiveCfg = Release|Any CPU {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Release|Any CPU.Build.0 = Release|Any CPU {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Release|x64.ActiveCfg = Release|x64 {8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Release|x64.Build.0 = Release|x64 - {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU - {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU - {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.ARTICULATE|x64.ActiveCfg = ARTICULATE|x64 - {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.ARTICULATE|x64.Build.0 = ARTICULATE|x64 {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Debug|Any CPU.Build.0 = Debug|Any CPU {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Debug|x64.ActiveCfg = Debug|x64 {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Debug|x64.Build.0 = Debug|x64 - {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU - {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU - {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|x64 - {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|x64 - {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.RASA|Any CPU.ActiveCfg = RASA|Any CPU - {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.RASA|Any CPU.Build.0 = RASA|Any CPU - {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.RASA|x64.ActiveCfg = RASA|x64 - {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.RASA|x64.Build.0 = RASA|x64 {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Release|Any CPU.ActiveCfg = Release|Any CPU {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Release|Any CPU.Build.0 = Release|Any CPU {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Release|x64.ActiveCfg = Release|x64 {30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Release|x64.Build.0 = Release|x64 - {62F08F9F-16C2-4754-90B0-B604DC18AE23}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU - {62F08F9F-16C2-4754-90B0-B604DC18AE23}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU - {62F08F9F-16C2-4754-90B0-B604DC18AE23}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU - {62F08F9F-16C2-4754-90B0-B604DC18AE23}.ARTICULATE|x64.Build.0 = Debug|Any CPU {62F08F9F-16C2-4754-90B0-B604DC18AE23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {62F08F9F-16C2-4754-90B0-B604DC18AE23}.Debug|Any CPU.Build.0 = Debug|Any CPU {62F08F9F-16C2-4754-90B0-B604DC18AE23}.Debug|x64.ActiveCfg = Debug|Any CPU {62F08F9F-16C2-4754-90B0-B604DC18AE23}.Debug|x64.Build.0 = Debug|Any CPU - {62F08F9F-16C2-4754-90B0-B604DC18AE23}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU - {62F08F9F-16C2-4754-90B0-B604DC18AE23}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU - {62F08F9F-16C2-4754-90B0-B604DC18AE23}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU - {62F08F9F-16C2-4754-90B0-B604DC18AE23}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU - {62F08F9F-16C2-4754-90B0-B604DC18AE23}.RASA|Any CPU.ActiveCfg = Release|Any CPU - {62F08F9F-16C2-4754-90B0-B604DC18AE23}.RASA|Any CPU.Build.0 = Release|Any CPU - {62F08F9F-16C2-4754-90B0-B604DC18AE23}.RASA|x64.ActiveCfg = Release|Any CPU - {62F08F9F-16C2-4754-90B0-B604DC18AE23}.RASA|x64.Build.0 = Release|Any CPU {62F08F9F-16C2-4754-90B0-B604DC18AE23}.Release|Any CPU.ActiveCfg = Release|Any CPU {62F08F9F-16C2-4754-90B0-B604DC18AE23}.Release|Any CPU.Build.0 = Release|Any CPU {62F08F9F-16C2-4754-90B0-B604DC18AE23}.Release|x64.ActiveCfg = Release|Any CPU {62F08F9F-16C2-4754-90B0-B604DC18AE23}.Release|x64.Build.0 = Release|Any CPU - {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU - {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU - {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU - {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.ARTICULATE|x64.Build.0 = Debug|Any CPU {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Debug|Any CPU.Build.0 = Debug|Any CPU {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Debug|x64.ActiveCfg = Debug|Any CPU {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Debug|x64.Build.0 = Debug|Any CPU - {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU - {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU - {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU - {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU - {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.RASA|Any CPU.ActiveCfg = Release|Any CPU - {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.RASA|Any CPU.Build.0 = Release|Any CPU - {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.RASA|x64.ActiveCfg = Release|Any CPU - {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.RASA|x64.Build.0 = Release|Any CPU {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Release|Any CPU.ActiveCfg = Release|Any CPU {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Release|Any CPU.Build.0 = Release|Any CPU {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Release|x64.ActiveCfg = Release|Any CPU {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Release|x64.Build.0 = Release|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.ARTICULATE|x64.Build.0 = Debug|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.Debug|x64.ActiveCfg = Debug|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.Debug|x64.Build.0 = Debug|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.RASA|Any CPU.ActiveCfg = RASA|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.RASA|Any CPU.Build.0 = RASA|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.RASA|x64.ActiveCfg = Release|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.RASA|x64.Build.0 = Release|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.Release|Any CPU.Build.0 = Release|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.Release|x64.ActiveCfg = Release|Any CPU - {2B279A6C-C829-4D29-9C1C-809C8A8E36B2}.Release|x64.Build.0 = Release|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.ARTICULATE|x64.Build.0 = Debug|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.Debug|Any CPU.Build.0 = Debug|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.Debug|x64.ActiveCfg = Debug|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.Debug|x64.Build.0 = Debug|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.RASA|Any CPU.ActiveCfg = RASA|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.RASA|Any CPU.Build.0 = RASA|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.RASA|x64.ActiveCfg = Release|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.RASA|x64.Build.0 = Release|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.Release|Any CPU.ActiveCfg = Release|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.Release|Any CPU.Build.0 = Release|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.Release|x64.ActiveCfg = Release|Any CPU - {25503190-0B4B-4ECA-8C0C-D12A53A09583}.Release|x64.Build.0 = Release|Any CPU + {B865F070-9693-47C6-B901-40121F659C6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B865F070-9693-47C6-B901-40121F659C6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B865F070-9693-47C6-B901-40121F659C6F}.Debug|x64.ActiveCfg = Debug|Any CPU + {B865F070-9693-47C6-B901-40121F659C6F}.Debug|x64.Build.0 = Debug|Any CPU + {B865F070-9693-47C6-B901-40121F659C6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B865F070-9693-47C6-B901-40121F659C6F}.Release|Any CPU.Build.0 = Release|Any CPU + {B865F070-9693-47C6-B901-40121F659C6F}.Release|x64.ActiveCfg = Release|Any CPU + {B865F070-9693-47C6-B901-40121F659C6F}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Platform.Dialogflow/AgentImporterInDialogflow.cs b/Platform.Dialogflow/AgentImporterInDialogflow.cs deleted file mode 100644 index b29673eb..00000000 --- a/Platform.Dialogflow/AgentImporterInDialogflow.cs +++ /dev/null @@ -1,293 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using BotSharp.Platform.Abstraction; -using BotSharp.Platform.Models; -using BotSharp.Platform.Models.AiResponse; -using BotSharp.Platform.Models.Intents; -using BotSharp.Platform.Models.MachineLearning; -using DotNetToolkit; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Platform.Dialogflow.Models; - -namespace Platform.Dialogflow -{ - /// - /// Import agent from Dialogflow - /// - public class AgentImporterInDialogflow : IAgentImporter where TAgent : AgentModel - { - public string AgentDir { get; set; } - - /// - /// Load agent meta - /// - /// - /// - /// - public TAgent LoadAgent(AgentImportHeader agentHeader) - { - // load agent profile - string data = File.ReadAllText(Path.Combine(AgentDir, "agent.json")); - var agent = JsonConvert.DeserializeObject(data); - agent.Name = agentHeader.Name; - agent.Id = agentHeader.Id; - - var result = agent.ToObject(); - result.ClientAccessToken = agentHeader.ClientAccessToken; - result.DeveloperAccessToken = agentHeader.DeveloperAccessToken; - - result.MlConfig = agent.ToObject(); - result.MlConfig.MinConfidence = agent.MlMinConfidence; - result.MlConfig.AgentId = agent.Id; - if(agentHeader.Integrations != null) - { - agentHeader.Integrations.ForEach(x => x.AgentId = agent.Id); - result.Integrations = agentHeader.Integrations; - } - - return result; - } - - public void LoadCustomEntities(TAgent agent) - { - agent.Entities = new List(); - string entityDir = Path.Combine(AgentDir, "entities"); - if (!Directory.Exists(entityDir)) return; - - Directory.EnumerateFiles(entityDir) - .ToList() - .ForEach(fileName => - { - string entityName = fileName.Split(Path.DirectorySeparatorChar).Last(); - if (!entityName.Contains("_")) - { - string entityJson = File.ReadAllText($"{fileName}"); - var entity = JsonConvert.DeserializeObject(entityJson); - - // load entries - string entriesFileName = fileName.Replace(entity.Name, $"{entity.Name}_entries_{agent.Language}"); - if (File.Exists(entriesFileName)) - { - string entriesJson = File.ReadAllText($"{entriesFileName}"); - entriesJson = entriesJson.Replace("\"synonyms\":", "\"rawSynonyms\":"); - entity.Entries = JsonConvert.DeserializeObject>(entriesJson); - entity.Entries.ForEach(x => x.Synonyms = x.RawSynonyms.Select(s => new EntrySynonym - { - Synonym = s - }).ToList()); - } - - var entityType = entity.ToObject(); - agent.Entities.Add(entityType); - } - }); - } - - public void LoadIntents(TAgent agent) - { - agent.Intents = new List(); - string intentDir = Path.Combine(AgentDir, "intents"); - if (!Directory.Exists(intentDir)) return; - - Directory.EnumerateFiles(intentDir) - .ToList() - .ForEach(fileName => - { - if (!fileName.Contains("_usersays_" + agent.Language) - || fileName.Contains("Default Fallback Intent")) - { - string intentJson = File.ReadAllText($"{fileName}"); - - // avoid confict data structure - intentJson = intentJson.Replace("\"contexts\":", "\"contextList\":"); - intentJson = intentJson.Replace("\"messages\":", "\"messageList\":"); - intentJson = intentJson.Replace("\"prompts\":", "\"promptList\":"); - - var intent = JsonConvert.DeserializeObject(intentJson); - var newIntent = ImportIntentUserSays(agent, intent, fileName); - agent.Intents.Add(newIntent); - } - }); - } - - private Intent ImportIntentUserSays(TAgent agent, DialogflowIntent intent, string fileName) - { - // void id confict - intent.Id = Guid.NewGuid().ToString(); - intent.Name = intent.Name.Replace("/", "_"); - // load user expressions - if (fileName.Contains("Default Fallback Intent")) - { - intent.UserSays = (intent.Responses[0].MessageList[0].Speech as JArray) - .Select(x => new DialogflowIntentExpression - { - Data = new List - { - new DialogflowIntentExpressionPart - { - Text = x.ToString() - } - } - }).ToList(); - } - else - { - string expressionFileName = fileName.Replace(intent.Name, $"{intent.Name}_usersays_{agent.Language}"); - if (File.Exists(expressionFileName)) - { - string expressionJson = File.ReadAllText($"{expressionFileName}"); - intent.UserSays = JsonConvert.DeserializeObject>(expressionJson); - - intent.UserSays.ForEach(say => - { - // remove @sys.ignore - say.Data.Where(x => x.Meta == "@sys.ignore").ToList().ForEach(x => x.Meta = null); - - // remove @sys. - say.Data.Where(x => x.Meta != null && x.Meta.StartsWith("@sys.")).ToList().ForEach(x => x.Meta = x.Meta.Substring(5)); - - // remove @ - say.Data.Where(x => x.Meta != null && x.Meta.StartsWith("@")).ToList().ForEach(x => x.Meta = x.Meta.Substring(1)); - - // calculate offset - for(int i = 1; i < say.Data.Count; i++) - { - say.Data[i].Start = String.Join("", say.Data.Select(x => x.Text).Take(i)).Length; - } - }); - } - } - - var newIntent = ImportIntentResponse(agent, intent); - - newIntent.Contexts = intent.ContextList.Select(x => new IntentInputContext { Name = x }).ToList(); - - return newIntent; - } - - private Intent ImportIntentResponse(TAgent agent, DialogflowIntent intent) - { - var newIntent = intent.ToObject(); - - intent.Responses.ForEach(res => - { - var newResponse = newIntent.Responses.First(x => x.Id == res.Id); - - newResponse.Contexts = res.AffectedContexts.Select(x => new IntentResponseContext - { - Name = x.Name, - Lifespan = x.Lifespan - }).ToList(); - - int millSeconds = 0; - - newResponse.Messages = res.MessageList.Where(x => x.Speech != null || x.Payload != null) - .Select(x => - { - if (x.Type == AIResponseMessageType.Custom) - { - return new IntentResponseMessage - { - Payload = JObject.FromObject(x.Payload), - PayloadJson = JsonConvert.SerializeObject(x.Payload), - Type = x.Type, - UpdatedTime = DateTime.UtcNow.AddMilliseconds(millSeconds++) - }; - } - else - { - var speech = JsonConvert.SerializeObject(x.Speech.GetType().Equals(typeof(String)) ? - new List { x.Speech.ToString() } : - (x.Speech as JArray).Select(s => s.Value()).ToList()); - - return new IntentResponseMessage - { - Speech = speech, - Type = x.Type, - UpdatedTime = DateTime.UtcNow.AddMilliseconds(millSeconds++) - }; - } - - }).ToList(); - - newResponse.Parameters = res.Parameters.Select(p => - { - var rp = p.ToObject(); - - // remove @sys. - if (rp.DataType.StartsWith("@sys.")) - { - rp.DataType = rp.DataType.Substring(5); - } - - if (rp.DataType.StartsWith("@")) - { - rp.DataType = rp.DataType.Substring(1); - } - - rp.Prompts = p.PromptList.Select(pl => new ResponseParameterPrompt { Prompt = pl.Value }).ToList(); - return rp; - }).ToList(); - }); - - return newIntent; - } - - public void LoadBuildinEntities(TAgent agent) - { - agent.Intents.ForEach(intent => - { - if (intent.UserSays != null) - { - intent.UserSays.ForEach(us => - { - us.Data.Where(data => data.Meta != null) - .ToList() - .ForEach(data => - { - LoadBuildinEntityTypePerUserSay(agent, data); - }); - }); - } - - }); - } - - private void LoadBuildinEntityTypePerUserSay(TAgent agent, IntentExpressionPart data) - { - var existedEntityType = agent.Entities.FirstOrDefault(x => x.Name == data.Meta); - - if (existedEntityType == null) - { - existedEntityType = new EntityType - { - Name = data.Meta, - Entries = new List(), - IsOverridable = true - }; - - agent.Entities.Add(existedEntityType); - } - - var entries = existedEntityType.Entries.Select(x => x.Value.ToLower()).ToList(); - if (!entries.Contains(data.Text.ToLower())) - { - existedEntityType.Entries.Add(new EntityEntry - { - Value = data.Text, - Synonyms = new List - { - new EntrySynonym - { - Synonym = data.Text - } - } - }); - } - } - } -} diff --git a/Platform.Dialogflow/Controllers/AgentController.cs b/Platform.Dialogflow/Controllers/AgentController.cs deleted file mode 100644 index 38a64fa9..00000000 --- a/Platform.Dialogflow/Controllers/AgentController.cs +++ /dev/null @@ -1,89 +0,0 @@ -using BotSharp.Core.Engines; -using DotNetToolkit; -using EntityFrameworkCore.BootKit; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Configuration; -using Newtonsoft.Json; -using Platform.Dialogflow.Models; -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Platform.Dialogflow.Controllers -{ -#if DIALOGFLOW - /// - /// Agent - /// - [Route("v1/[controller]")] - public class AgentController : ControllerBase - { - private DialogflowAi builder; - - /// - /// Initialize dialog controller and get a platform instance - /// - /// - public AgentController(IConfiguration configuration) - { - builder = new DialogflowAi(); - builder.PlatformConfig = configuration.GetSection("DialogflowAi"); - } - - /// - /// Import a agent from a uploaded zip file - /// - /// - /// - [HttpPost("import")] - public async Task Import(IFormFile uploadedFile) - { - if (uploadedFile == null || uploadedFile.Length == 0) - { - return BadRequest(); - } - - var filePath = Path.GetTempFileName(); - Console.WriteLine($"Temp file saved to {filePath}"); - - using (var stream = new FileStream(filePath, FileMode.Create)) - { - await uploadedFile.CopyToAsync(stream); - } - - string dest = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects", uploadedFile.FileName.Split('.').First(), "tmp"); - if (Directory.Exists(dest)) - { - System.IO.Directory.Delete(dest, true); - } - - Console.WriteLine($"Extract zip file to {dest}"); - ZipFile.ExtractToDirectory(filePath, dest); - - System.IO.File.Delete(filePath); - - Console.WriteLine($"Loading agent from folder {dest}"); - var agent = builder.LoadAgentFromFile>(dest); - builder.SaveAgent(agent); - - return Ok(agent.Id); - } - - /// - /// Dump agent - /// - /// - /// - [HttpGet("{agentId}")] - public ActionResult Dump([FromRoute] String agentId) - { - return Ok(); - } - } -#endif -} diff --git a/Platform.Dialogflow/Controllers/EntitiesController.cs b/Platform.Dialogflow/Controllers/EntitiesController.cs deleted file mode 100644 index 206e49fe..00000000 --- a/Platform.Dialogflow/Controllers/EntitiesController.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Platform.Dialogflow.ViewModels; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Controllers -{ -#if DIALOGFLOW - /// - /// The /entities endpoint is used to create, retrieve, update, and delete developer-defined entity objects. - /// - [Authorize] - [Route("v1/[controller]")] - public class EntitiesController : ControllerBase - { - [HttpGet] - public IEnumerable All() - { - return new List(); - } - } -#endif -} diff --git a/Platform.Dialogflow/Controllers/IntentsController.cs b/Platform.Dialogflow/Controllers/IntentsController.cs deleted file mode 100644 index 68c4fa35..00000000 --- a/Platform.Dialogflow/Controllers/IntentsController.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Platform.Dialogflow.Models; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Controllers -{ -#if DIALOGFLOW - /// - /// The /intents endpoint is used to create, retrieve, update, and delete intent objects. - /// - [Authorize] - [Route("v1/[controller]")] - public class IntentsController : ControllerBase - { - /// - /// Retrieves a list of all intents for the agent. - /// - /// - [HttpGet] - public IEnumerable GetIntents() - { - return new List(); - } - - /// - /// The POST request creates a new intent. When a new intent is created via the API, the agent is trained with the new data. - /// - /// - [HttpPost] - public string PostIntent([FromBody] DialogflowIntent intent) - { - return ""; - } - - /// - /// Retrieves the specified intent. {id} is the ID of the intent to retrieve. - /// - /// - [HttpGet("{id}")] - public DialogflowIntent GetIntent() - { - return new DialogflowIntent(); - } - - [HttpPut("{id}")] - public bool PutIntent([FromBody] DialogflowIntent intent) - { - return true; - } - } -#endif -} diff --git a/Platform.Dialogflow/Controllers/QueryController.cs b/Platform.Dialogflow/Controllers/QueryController.cs deleted file mode 100644 index 4fb7bafc..00000000 --- a/Platform.Dialogflow/Controllers/QueryController.cs +++ /dev/null @@ -1,105 +0,0 @@ -using BotSharp.Core.Engines; -using BotSharp.NLP; -using BotSharp.Platform.Models; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Newtonsoft.Json; -using Platform.Dialogflow.Models; -using Platform.Dialogflow.ViewModels; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Security.Claims; -using System.Text; - -namespace Platform.Dialogflow.Controllers -{ -#if DIALOGFLOW - /// - /// Dialogflow mode query controller - /// - [Authorize] - [Route("v1/[controller]")] - public class QueryController : ControllerBase - { - private readonly IBotPlatform _platform; - - /// - /// Initialize dialog controller and get a platform instance - /// - /// - public QueryController(IBotPlatform platform) - { - _platform = platform; - } - - /// - /// The query endpoint is used to process natural language in the form of text. - /// The query requests return structured data in JSON format with an action and parameters for that action. - /// Both GET and POST methods return the same JSON response. - /// - /// - /// - [HttpGet, HttpPost] - public ActionResult Query(QueryModel request) - { - String clientAccessToken = (User.Identity as ClaimsIdentity).Claims.FirstOrDefault(x => x.Type == "UserId")?.Value; - //_platform.AiConfig = new AIConfiguration(clientAccessToken, SupportedLanguage.English); - //_platform.AiConfig.SessionId = request.SessionId; - - // find a model according to clientAccessToken - string projectPath = String.Empty; - string projectsPath = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects"); - - string[] d1 = Directory.GetDirectories(projectsPath); - for (int i = 0; i < d1.Length; i++) - { - string[] d2 = Directory.GetDirectories(d1[i]); - for (int j = 0; j < d2.Length; j++) - { - string metaJson = System.IO.File.ReadAllText(Path.Combine(d2[j], "meta.json")); - - var meta = JsonConvert.DeserializeObject(metaJson); - - if (meta.ClientAccessToken == clientAccessToken) - { - projectPath = d1[i]; - break; - } - }; - - if (!String.IsNullOrEmpty(projectPath)) - { - break; - } - }; - - // Load agent - string model = Directory.GetDirectories(projectPath).Where(x => x.Contains("model_")).Last().Split(Path.DirectorySeparatorChar).Last(); - string dataDir = Path.Combine(projectPath, model); - - if(!System.IO.File.Exists(Path.Combine(dataDir, "model-meta.json"))) - { - return BadRequest("The agent hasn't been trained. Please train the agent before querying."); - } - - Console.WriteLine($"LoadAgentFromFile {dataDir}"); - - //_platform.LoadAgentFromFile(dataDir); - - /*var aIResponse = _platform.TextRequest(new AIRequest - { - Timezone = request.Timezone, - Contexts = request?.Contexts?.Select(x => new AIContext { Name = x })?.ToList(), - Language = request.Lang, - Query = new String[] { request.Query }, - AgentDir = projectPath, - Model = model - });*/ - - return null; - } - } -#endif -} diff --git a/Platform.Dialogflow/Controllers/TrainController.cs b/Platform.Dialogflow/Controllers/TrainController.cs deleted file mode 100644 index 0978a705..00000000 --- a/Platform.Dialogflow/Controllers/TrainController.cs +++ /dev/null @@ -1,53 +0,0 @@ -using BotSharp.Core.Engines; -using BotSharp.Platform.Models; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Configuration; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Serialization; -using Platform.Dialogflow.Models; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; - -namespace Platform.Dialogflow.Controllers -{ -#if DIALOGFLOW - /// - /// You can post your training data to this endpoint to train a new model for a project. - /// This request will wait for the server answer: either the model was trained successfully or the training exited with an error. - /// - [Route("v1/[controller]")] - public class TrainController : ControllerBase - { - private DialogflowAi builder; - - public TrainController(IConfiguration configuration) - { - builder = new DialogflowAi(); - builder.PlatformConfig = configuration.GetSection("DialogflowAi"); - } - - [HttpPost] - public async Task> Train([FromQuery] string agentId) - { - var agent = builder.GetAgentById(agentId); - - if(agent == null) - { - agent = builder.GetAgentByName(agentId); - } - - var corpus = builder.ExtractorCorpus(agent); - - await builder.Train(agent, corpus); - - return agent; - } - } -#endif -} diff --git a/Platform.Dialogflow/DialogflowAi.cs b/Platform.Dialogflow/DialogflowAi.cs deleted file mode 100644 index 3a81d890..00000000 --- a/Platform.Dialogflow/DialogflowAi.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using BotSharp.Core; -using BotSharp.Core.Engines; -using BotSharp.NLP; -using BotSharp.Platform.Abstraction; -using BotSharp.Platform.Models; -using BotSharp.Platform.Models.AiRequest; -using BotSharp.Platform.Models.AiResponse; -using DotNetToolkit; -using Platform.Dialogflow.Models; - -namespace Platform.Dialogflow -{ - public class DialogflowAi : - PlatformBuilderBase, - IPlatformBuilder - where TAgent : AgentModel - { - public TrainingCorpus ExtractorCorpus(TAgent agent) - { - var corpus = new TrainingCorpus - { - Entities = new List(), - UserSays = new List>() - }; - - agent.Entities.ForEach(entity => - { - corpus.Entities.Add(new TrainingEntity - { - Entity = entity.Name, - Values = entity.Entries.Select(x => new TrainingEntitySynonym - { - Value = x.Value, - Synonyms = x.Synonyms.Select(y => y.Synonym).ToList() - }).ToList() - }); - }); - - agent.Intents.ForEach(intent => - { - intent.UserSays.ForEach(say => { - corpus.UserSays.Add(new TrainingIntentExpression - { - Intent = intent.Name, - Text = String.Join("", say.Data.Select(x => x.Text)), - Entities = say.Data.Where(x => !String.IsNullOrEmpty(x.Meta)) - .Select(x => new TrainingIntentExpressionPart - { - Value = x.Text, - Entity = x.Meta, - Start = x.Start - }) - .ToList() - }); - }); - }); - - return corpus; - } - - public AiResponse TextRequest(AiRequest request) - { - var dataService = new AIDataService(new AIConfiguration("TOKEN", SupportedLanguage.English) - { - AgentId = request.AgentId, - Language = SupportedLanguage.English, - SessionId = request.SessionId - }); - - var response = dataService.Request(new AIRequest - { - SessionId = request.SessionId, - Query = new string[] { request.Text } - }); - - return response.ToObject(); - } - - public async Task Train(TAgent agent, TrainingCorpus corpus) - { - var trainer = new BotTrainer(); - - var trainOptions = new BotTrainOptions - { - //AgentDir = projectPath, - //Model = model - }; - - var info = await trainer.Train(agent, trainOptions); - - return true; - } - - protected float[] TrimSilence(float[] samples) - { - if (samples == null) - { - return null; - } - - const float min = 0.000001f; - - var startIndex = 0; - var endIndex = samples.Length; - - for (var i = 0; i < samples.Length; i++) - { - - if (Math.Abs(samples[i]) > min) - { - startIndex = i; - break; - } - } - - for (var i = samples.Length - 1; i > 0; i--) - { - if (Math.Abs(samples[i]) > min) - { - endIndex = i; - break; - } - } - - if (endIndex <= startIndex) - { - return null; - } - - var result = new float[endIndex - startIndex]; - Array.Copy(samples, startIndex, result, 0, endIndex - startIndex); - return result; - - } - - protected static byte[] ConvertArrayShortToBytes(short[] array) - { - var numArray = new byte[array.Length * 2]; - Buffer.BlockCopy(array, 0, numArray, 0, numArray.Length); - return numArray; - } - - protected static short[] ConvertIeeeToPcm16(float[] source) - { - var resultBuffer = new short[source.Length]; - for (var i = 0; i < source.Length; i++) - { - var f = source[i] * 32768f; - - if (f > (double)short.MaxValue) - f = short.MaxValue; - else if (f < (double)short.MinValue) - f = short.MinValue; - resultBuffer[i] = Convert.ToInt16(f); - } - - return resultBuffer; - } - } -} diff --git a/Platform.Dialogflow/Models/AIConfiguration.cs b/Platform.Dialogflow/Models/AIConfiguration.cs deleted file mode 100644 index dc0d0656..00000000 --- a/Platform.Dialogflow/Models/AIConfiguration.cs +++ /dev/null @@ -1,73 +0,0 @@ -using BotSharp.NLP; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class AIConfiguration - { - private const string SERVICE_PROD_URL = "https://api.api.ai/v1/"; - private const string SERVICE_DEV_URL = "https://dev.api.ai/api/"; - - private const string CURRENT_PROTOCOL_VERSION = "20150910"; - - public string ClientAccessToken { get; private set; } - - public string AgentId { get; set; } - - public SupportedLanguage Language { get; set; } - - public bool VoiceActivityDetectionEnabled { get; set; } - - public string SessionId { get; set; } - - /// - /// If true, will be used Testing API.AI server instead of Production server. This option for TESTING PURPOSES ONLY. - /// - public bool DevMode { get; set; } - - /// - /// If true, all request and response content will be printed to the console. Use this option only FOR DEVELOPMENT. - /// - public bool DebugLog { get; set; } - - string protocolVersion; - public string ProtocolVersion - { - get - { - return protocolVersion; - } - set - { - if (string.IsNullOrEmpty(value)) - { - throw new ArgumentNullException("value"); - } - protocolVersion = value; - } - } - - public AIConfiguration(string clientAccessToken, SupportedLanguage language) - { - this.ClientAccessToken = clientAccessToken; - this.Language = language; - - DevMode = false; - DebugLog = false; - VoiceActivityDetectionEnabled = true; - - ProtocolVersion = CURRENT_PROTOCOL_VERSION; - } - - public string RequestUrl - { - get - { - var baseUrl = DevMode ? SERVICE_DEV_URL : SERVICE_PROD_URL; - return string.Format("{0}{1}?v={2}", baseUrl, "query", ProtocolVersion); - } - } - } -} diff --git a/Platform.Dialogflow/Models/AIContext.cs b/Platform.Dialogflow/Models/AIContext.cs deleted file mode 100644 index a42c7bff..00000000 --- a/Platform.Dialogflow/Models/AIContext.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - [JsonObject] - public class AIContext - { - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("parameters")] - public Dictionary Parameters { get; set; } - - /// - /// Lifespan of the context measured in requests```` - /// - [JsonProperty("lifespan")] - public int Lifespan { get; set; } - - public AIContext() - { - } - } -} diff --git a/Platform.Dialogflow/Models/AIDataService.cs b/Platform.Dialogflow/Models/AIDataService.cs deleted file mode 100644 index 1b26895d..00000000 --- a/Platform.Dialogflow/Models/AIDataService.cs +++ /dev/null @@ -1,180 +0,0 @@ -using BotSharp.Core.Engines.Dialogflow; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Net; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class AIDataService - { - private readonly AIConfiguration config; - - public string SessionId { get; } - - public AIDataService(AIConfiguration config) - { - this.config = config; - - if (string.IsNullOrEmpty(config.SessionId)) - { - SessionId = Guid.NewGuid().ToString(); - } - else - { - SessionId = config.SessionId; - } - } - - public AIResponse Request(AIRequest request) - { - request.Language = config.Language.code; - request.Timezone = TimeZone.CurrentTimeZone.StandardName; - request.SessionId = SessionId; - - try - { - var httpRequest = (HttpWebRequest)WebRequest.Create(config.RequestUrl); - httpRequest.Method = "POST"; - httpRequest.ContentType = "application/json; charset=utf-8"; - httpRequest.Accept = "application/json"; - - httpRequest.Headers.Add("Authorization", "Bearer " + config.ClientAccessToken); - - var jsonSettings = new JsonSerializerSettings - { - NullValueHandling = NullValueHandling.Ignore, - ContractResolver = new CamelCasePropertyNamesContractResolver() - }; - - var jsonRequest = JsonConvert.SerializeObject(request, Formatting.None, jsonSettings); - - if (config.DebugLog) - { - Debug.WriteLine("Request: " + jsonRequest); - } - - using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream())) - { - streamWriter.Write(jsonRequest); - streamWriter.Close(); - } - - var httpResponse = httpRequest.GetResponse() as HttpWebResponse; - using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) - { - var result = streamReader.ReadToEnd(); - - if (config.DebugLog) - { - Debug.WriteLine("Response: " + result); - } - - var aiResponse = JsonConvert.DeserializeObject(result); - - CheckForErrors(aiResponse); - - return aiResponse; - } - - } - catch (Exception e) - { - throw new AIServiceException(e); - } - } - - public AIResponse VoiceRequest(Stream voiceStream, RequestExtras requestExtras = null) - { - var request = new AIRequest(); - request.Language = config.Language.code; - request.Timezone = TimeZone.CurrentTimeZone.StandardName; - request.SessionId = SessionId; - - if (requestExtras != null) - { - requestExtras.CopyTo(request); - } - - try - { - var httpRequest = (HttpWebRequest)WebRequest.Create(config.RequestUrl); - httpRequest.Method = "POST"; - httpRequest.Accept = "application/json"; - - httpRequest.Headers.Add("Authorization", "Bearer " + config.ClientAccessToken); - - var jsonSettings = new JsonSerializerSettings - { - NullValueHandling = NullValueHandling.Ignore - }; - - var jsonRequest = JsonConvert.SerializeObject(request, Formatting.None, jsonSettings); - - if (config.DebugLog) - { - Debug.WriteLine("Request: " + jsonRequest); - } - - var multipartClient = new MultipartHttpClient(httpRequest); - multipartClient.connect(); - - multipartClient.addStringPart("request", jsonRequest); - multipartClient.addFilePart("voiceData", "voice.wav", voiceStream); - - multipartClient.finish(); - - var responseJsonString = multipartClient.getResponse(); - - if (config.DebugLog) - { - Debug.WriteLine("Response: " + responseJsonString); - } - - var aiResponse = JsonConvert.DeserializeObject(responseJsonString); - - CheckForErrors(aiResponse); - - return aiResponse; - - } - catch (Exception e) - { - throw new AIServiceException(e); - } - } - - public bool ResetContexts() - { - var cleanRequest = new AIRequest("empty_query_for_resetting_contexts"); - cleanRequest.ResetContexts = true; - try - { - var response = Request(cleanRequest); - return !response.IsError; - } - catch (AIServiceException e) - { - Debug.WriteLine("Exception while contexts clean." + e); - return false; - } - } - - static void CheckForErrors(AIResponse aiResponse) - { - if (aiResponse == null) - { - throw new AIServiceException("API.AI response parsed as null. Check debug log for details."); - } - - if (aiResponse.IsError) - { - throw new AIServiceException(aiResponse); - } - } - } -} diff --git a/Platform.Dialogflow/Models/AIRequest.cs b/Platform.Dialogflow/Models/AIRequest.cs deleted file mode 100644 index 29171e5a..00000000 --- a/Platform.Dialogflow/Models/AIRequest.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class AIRequest : QuestionMetadata - { - public string[] Query { get; set; } - - public float[] Confidence { get; set; } - - public List Contexts { get; set; } - - public bool? ResetContexts { get; set; } - - public OriginalRequest OriginalRequest { get; set; } - - /// - /// Agent directory - /// - public string AgentDir { get; set; } - - /// - /// What model is used to predict. - /// - public string Model { get; set; } - - public AIRequest() - { - Contexts = new List(); - } - - public AIRequest(string text) - { - Query = new string[] { text }; - Confidence = new float[] { 1.0f }; - Contexts = new List(); - } - - public AIRequest(string text, RequestExtras requestExtras) : this(text) - { - if (requestExtras != null) - { - requestExtras.CopyTo(this); - } - } - - } -} diff --git a/Platform.Dialogflow/Models/AIResponse.cs b/Platform.Dialogflow/Models/AIResponse.cs deleted file mode 100644 index 781ae203..00000000 --- a/Platform.Dialogflow/Models/AIResponse.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class AIResponse - { - public string Id { get; set; } - - public DateTime Timestamp { get; set; } - - public string Lang { get; set; } - - public AIResponseResult Result { get; set; } - - public AIResponseStatus Status { get; set; } - - public string SessionId { get; set; } - - public bool IsError - { - get - { - if (Status != null && Status.Code >= 400) - { - return true; - } - - return false; - } - } - } -} diff --git a/Platform.Dialogflow/Models/AIResponseCustomPayload.cs b/Platform.Dialogflow/Models/AIResponseCustomPayload.cs deleted file mode 100644 index 6f3a36fa..00000000 --- a/Platform.Dialogflow/Models/AIResponseCustomPayload.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class AIResponseCustomPayload : AIResponseMessageBase - { - public string Task { get; set; } - - public List Parameters { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/AIResponseFulfillment.cs b/Platform.Dialogflow/Models/AIResponseFulfillment.cs deleted file mode 100644 index 03e4a4a0..00000000 --- a/Platform.Dialogflow/Models/AIResponseFulfillment.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class AIResponseFulfillment - { - public string Speech { get; set; } - - public List Messages { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/AIResponseMessageBase.cs b/Platform.Dialogflow/Models/AIResponseMessageBase.cs deleted file mode 100644 index 4596b753..00000000 --- a/Platform.Dialogflow/Models/AIResponseMessageBase.cs +++ /dev/null @@ -1,12 +0,0 @@ -using BotSharp.Platform.Models; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class AIResponseMessageBase - { - public AIResponseMessageType Type { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/AIResponseMetadata.cs b/Platform.Dialogflow/Models/AIResponseMetadata.cs deleted file mode 100644 index 0a5c6d08..00000000 --- a/Platform.Dialogflow/Models/AIResponseMetadata.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class AIResponseMetadata - { - public string IntentId { get; set; } - public string IntentName { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/AIResponseResult.cs b/Platform.Dialogflow/Models/AIResponseResult.cs deleted file mode 100644 index e17811c7..00000000 --- a/Platform.Dialogflow/Models/AIResponseResult.cs +++ /dev/null @@ -1,150 +0,0 @@ -using BotSharp.Models.NLP; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class AIResponseResult - { - String action; - - public Boolean ActionIncomplete { get; set; } - - public String Action - { - get - { - if (string.IsNullOrEmpty(action)) - { - return string.Empty; - } - return action; - } - set - { - action = value; - } - } - - public Dictionary Parameters { get; set; } - - public List Entities { get; set; } - - public AIContext[] Contexts { get; set; } - - public AIResponseMetadata Metadata { get; set; } - - public String ResolvedQuery { get; set; } - - public AIResponseFulfillment Fulfillment { get; set; } - - public string Source { get; set; } - - public decimal Score { get; set; } - - [JsonIgnore] - public bool HasParameters - { - get - { - return Parameters != null && Parameters.Count > 0; - } - } - - public string GetStringParameter(string name, string defaultValue = "") - { - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentNullException("name"); - } - - if (Parameters.ContainsKey(name)) - { - return Parameters[name].ToString(); - } - - return defaultValue; - } - - public int GetIntParameter(string name, int defaultValue = 0) - { - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentNullException("name"); - } - - if (Parameters.ContainsKey(name)) - { - var parameterValue = Parameters[name].ToString(); - int result; - if (int.TryParse(parameterValue, NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) - { - return result; - } - - float floatResult; - if (float.TryParse(parameterValue, NumberStyles.Float, CultureInfo.InvariantCulture, out floatResult)) - { - result = Convert.ToInt32(floatResult); - return result; - } - } - - return defaultValue; - } - - public float GetFloatParameter(string name, float defaultValue = 0) - { - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentNullException("name"); - } - - if (Parameters.ContainsKey(name)) - { - var parameterValue = Parameters[name].ToString(); - float result; - if (float.TryParse(parameterValue, NumberStyles.Float, CultureInfo.InvariantCulture, out result)) - { - return result; - } - } - - return defaultValue; - } - - public JObject GetJsonParameter(string name, JObject defaultValue = null) - { - if (string.IsNullOrEmpty("name")) - { - throw new ArgumentNullException(nameof(name)); - } - - if (Parameters.ContainsKey(name)) - { - var parameter = Parameters[name].ToString(); - if (parameter != null) - { - return JObject.FromObject(parameter); - } - } - - return defaultValue; - } - - public AIContext GetContext(string name) - { - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentException("Name must be not empty", nameof(name)); - } - - return Contexts?.FirstOrDefault(c => string.Equals(c.Name, name, StringComparison.CurrentCultureIgnoreCase)); - } - } -} diff --git a/Platform.Dialogflow/Models/AIResponseStatus.cs b/Platform.Dialogflow/Models/AIResponseStatus.cs deleted file mode 100644 index 5eb5382e..00000000 --- a/Platform.Dialogflow/Models/AIResponseStatus.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class AIResponseStatus - { - public int Code { get; set; } - - public string ErrorType { get; set; } - - public string ErrorDetails { get; set; } - - public string ErrorID { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/AIServiceException.cs b/Platform.Dialogflow/Models/AIServiceException.cs deleted file mode 100644 index 36eecc98..00000000 --- a/Platform.Dialogflow/Models/AIServiceException.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class AIServiceException : Exception - { - public AIResponse Response { get; set; } - - public AIServiceException() - { - } - - public AIServiceException(string message) : base(message) - { - } - - public AIServiceException(string message, Exception innerException) : base(message, innerException) - { - } - - public AIServiceException(Exception e) : base(e.Message, e) - { - } - - public AIServiceException(AIResponse response) - { - Response = response; - } - - public override string Message - { - get - { - if (Response != null && Response.IsError) - { - if (!string.IsNullOrEmpty(Response.Status.ErrorDetails)) - { - return Response.Status.ErrorDetails; - } - } - - return base.Message; - } - } - } -} diff --git a/Platform.Dialogflow/Models/AgentModel.cs b/Platform.Dialogflow/Models/AgentModel.cs deleted file mode 100644 index 312f3e07..00000000 --- a/Platform.Dialogflow/Models/AgentModel.cs +++ /dev/null @@ -1,52 +0,0 @@ -using BotSharp.Platform.Models; -using BotSharp.Platform.Models.Intents; -using BotSharp.Platform.Models.MachineLearning; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class AgentModel : AgentBase - { - public AgentModel() - { - - } - - public Boolean Published { get; set; } - - /// - /// Only access text/ audio rquest - /// - [StringLength(32)] - public String ClientAccessToken { get; set; } - - /// - /// Developer can access more APIs - /// - [StringLength(32)] - public String DeveloperAccessToken { get; set; } - - public List Intents { get; set; } - - [JsonProperty("entity_types")] - public List Entities { get; set; } - - public String Birthday - { - get - { - return CreatedDate.ToShortDateString(); - } - } - - public Boolean IsSkillSet { get; set; } - - public AgentMlConfig MlConfig { get; set; } - - public List Integrations { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/DialogflowAgentImportModel.cs b/Platform.Dialogflow/Models/DialogflowAgentImportModel.cs deleted file mode 100644 index 166c0f64..00000000 --- a/Platform.Dialogflow/Models/DialogflowAgentImportModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class DialogflowAgentImportModel - { - public String Id { get; set; } - public String Name { get; set; } - public String Description { get; set; } - public Boolean Published { get; set; } - - public String DefaultTimezone { get; set; } - public String Language { get; set; } - - public decimal MlMinConfidence { get; set; } - public string CustomClassifierMode { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/DialogflowEntity.cs b/Platform.Dialogflow/Models/DialogflowEntity.cs deleted file mode 100644 index e62974e6..00000000 --- a/Platform.Dialogflow/Models/DialogflowEntity.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - [JsonObject] - public class DialogflowEntity - { - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("entries")] - public List Entries { get; set; } - - public DialogflowEntity() - { - } - - public DialogflowEntity(string name) - { - this.Name = name; - } - - public DialogflowEntity(string name, List entries) - { - this.Name = name; - this.Entries = entries; - } - - public void AddEntry(DialogflowEntityEntry entry) - { - if (Entries == null) - { - Entries = new List(); - } - - Entries.Add(entry); - } - } -} diff --git a/Platform.Dialogflow/Models/DialogflowEntityEntry.cs b/Platform.Dialogflow/Models/DialogflowEntityEntry.cs deleted file mode 100644 index 40918375..00000000 --- a/Platform.Dialogflow/Models/DialogflowEntityEntry.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - [JsonObject] - public class DialogflowEntityEntry - { - [JsonProperty("value")] - public string Value { get; set; } - - public List RawSynonyms { get; set; } - - public List Synonyms { get; set; } - - public DialogflowEntityEntry() - { - } - - public DialogflowEntityEntry(string value, List synonyms) - { - this.Value = value; - this.RawSynonyms = synonyms; - } - - public DialogflowEntityEntry(string value, string[] synonyms) : this(value, new List(synonyms)) - { - - } - } -} diff --git a/Platform.Dialogflow/Models/DialogflowIntent.cs b/Platform.Dialogflow/Models/DialogflowIntent.cs deleted file mode 100644 index 239e0d31..00000000 --- a/Platform.Dialogflow/Models/DialogflowIntent.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class DialogflowIntent - { - public string Id { get; set; } - public string Name { get; set; } - public bool Auto { get; set; } - /// - /// Input Contexts - /// - public List ContextList { get; set; } - - public List UserSays { get; set; } - public List Responses { get; set; } - public int Priority { get; set; } - public bool WebhookUsed { get; set; } - public bool FallbackIntent { get; set; } - public List Events { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/DialogflowIntentEvent.cs b/Platform.Dialogflow/Models/DialogflowIntentEvent.cs deleted file mode 100644 index f7f9ad8f..00000000 --- a/Platform.Dialogflow/Models/DialogflowIntentEvent.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class DialogflowIntentEvent - { - public string Name { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/DialogflowIntentExpression.cs b/Platform.Dialogflow/Models/DialogflowIntentExpression.cs deleted file mode 100644 index cd486a95..00000000 --- a/Platform.Dialogflow/Models/DialogflowIntentExpression.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class DialogflowIntentExpression - { - public String Id { get; set; } - public List Data { get; set; } - public Boolean IsTemplate { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/DialogflowIntentExpressionPart.cs b/Platform.Dialogflow/Models/DialogflowIntentExpressionPart.cs deleted file mode 100644 index 7013b976..00000000 --- a/Platform.Dialogflow/Models/DialogflowIntentExpressionPart.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class DialogflowIntentExpressionPart - { - public String Text { get; set; } - public String Alias { get; set; } - public String Meta { get; set; } - public int Start { get; set; } - public Boolean UserDefined { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/DialogflowIntentResponse.cs b/Platform.Dialogflow/Models/DialogflowIntentResponse.cs deleted file mode 100644 index 50bb5f94..00000000 --- a/Platform.Dialogflow/Models/DialogflowIntentResponse.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class DialogflowIntentResponse - { - public string Id { get; set; } - public bool ResetContexts { get; set; } - public string Action { get; set; } - - public List AffectedContexts { get; set; } - - public List Parameters { get; set; } - - public List MessageList { get; set; } - - public DialogflowIntentResponse() - { - Id = Guid.NewGuid().ToString(); - } - } -} diff --git a/Platform.Dialogflow/Models/DialogflowIntentResponseMessage.cs b/Platform.Dialogflow/Models/DialogflowIntentResponseMessage.cs deleted file mode 100644 index c34c0a7e..00000000 --- a/Platform.Dialogflow/Models/DialogflowIntentResponseMessage.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class DialogflowIntentResponseMessage : AIResponseMessageBase - { - public Object Speech { get; set; } - public Object Payload { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/DialogflowIntentResponseParameter.cs b/Platform.Dialogflow/Models/DialogflowIntentResponseParameter.cs deleted file mode 100644 index 86a2e3f8..00000000 --- a/Platform.Dialogflow/Models/DialogflowIntentResponseParameter.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class DialogflowIntentResponseParameter - { - public DialogflowIntentResponseParameter() - { - PromptList = new List(); - } - public string Id { get; set; } - public bool Required { get; set; } - public string DataType { get; set; } - public string DefaultValue { get; set; } - public string Name { get; set; } - public string Value { get; set; } - public bool IsList { get; set; } - - public List PromptList { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/DialogflowIntentResponseParameterPrompt.cs b/Platform.Dialogflow/Models/DialogflowIntentResponseParameterPrompt.cs deleted file mode 100644 index 78e518a9..00000000 --- a/Platform.Dialogflow/Models/DialogflowIntentResponseParameterPrompt.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class DialogflowIntentResponseParameterPrompt - { - public string Lang { get; set; } - - public string Value { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/EntityEntry.cs b/Platform.Dialogflow/Models/EntityEntry.cs deleted file mode 100644 index 428e08a0..00000000 --- a/Platform.Dialogflow/Models/EntityEntry.cs +++ /dev/null @@ -1,28 +0,0 @@ -using EntityFrameworkCore.BootKit; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class EntityEntry - { - /// - /// Guid - /// - [StringLength(36)] - public String Id { get; set; } - - [Required] - [StringLength(36)] - public String EntityId { get; set; } - - [MaxLength(64)] - public String Value { get; set; } - - [ForeignKey("EntityEntryId")] - public List Synonyms { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/EntityModel.cs b/Platform.Dialogflow/Models/EntityModel.cs deleted file mode 100644 index aed1538b..00000000 --- a/Platform.Dialogflow/Models/EntityModel.cs +++ /dev/null @@ -1,19 +0,0 @@ -using BotSharp.Platform.Abstraction; -using BotSharp.Platform.Models; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class EntityModel : EntityBase - { - public string Agent { get; set; } - - public string EntityName { get; set; } - - public string Type { get; set; } - - public string UiColor { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/EntityType.cs b/Platform.Dialogflow/Models/EntityType.cs deleted file mode 100644 index e62c4ce5..00000000 --- a/Platform.Dialogflow/Models/EntityType.cs +++ /dev/null @@ -1,45 +0,0 @@ -using EntityFrameworkCore.BootKit; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class EntityType - { - /// - /// Guid - /// - [StringLength(36)] - public String Id { get; set; } - - [Required] - [StringLength(36)] - public String AgentId { get; set; } - - [Required] - [MaxLength(64)] - public String Name { get; set; } - - [MaxLength(256)] - public String Description { get; set; } - - [ForeignKey("EntityId")] - public List Entries { get; set; } - - public bool IsOverridable { get; set; } - - public bool IsEnum { get; set; } - - [StringLength(6)] - public string Color { get; set; } - - /// - /// Entries count - /// - [NotMapped] - public int Count { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/EntrySynonym.cs b/Platform.Dialogflow/Models/EntrySynonym.cs deleted file mode 100644 index 4b132ba6..00000000 --- a/Platform.Dialogflow/Models/EntrySynonym.cs +++ /dev/null @@ -1,25 +0,0 @@ -using EntityFrameworkCore.BootKit; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class EntrySynonym - { - /// - /// Guid - /// - [StringLength(36)] - public String Id { get; set; } - - [Required] - [StringLength(36)] - public String EntityEntryId { get; set; } - - [MaxLength(128)] - public String Synonym { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/OriginalRequest.cs b/Platform.Dialogflow/Models/OriginalRequest.cs deleted file mode 100644 index c6be4334..00000000 --- a/Platform.Dialogflow/Models/OriginalRequest.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - [JsonObject] - public class OriginalRequest - { - [JsonProperty("source")] - public string Source { get; set; } - - [JsonProperty("data")] - public object Data { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/QuestionMetadata.cs b/Platform.Dialogflow/Models/QuestionMetadata.cs deleted file mode 100644 index a53df5e4..00000000 --- a/Platform.Dialogflow/Models/QuestionMetadata.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - [JsonObject] - public class QuestionMetadata - { - [JsonProperty("timezone")] - public string Timezone { get; set; } - - [JsonProperty("lang")] - public string Language { get; set; } - - [JsonProperty("sessionId")] - internal string SessionId { get; set; } - - [JsonProperty("entities")] - public List Entities { get; set; } - } -} diff --git a/Platform.Dialogflow/Models/RequestExtras.cs b/Platform.Dialogflow/Models/RequestExtras.cs deleted file mode 100644 index c5ad344b..00000000 --- a/Platform.Dialogflow/Models/RequestExtras.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.Models -{ - public class RequestExtras - { - public List Contexts { get; set; } - - public List Entities { get; set; } - - public bool HasContexts - { - get - { - if (Contexts != null && Contexts.Count > 0) - { - return true; - } - return false; - } - } - - public bool HasEntities - { - get - { - if (Entities != null && Entities.Count > 0) - { - return true; - } - return false; - } - } - - - public RequestExtras() - { - } - - public RequestExtras(List contexts, List entities) - { - this.Contexts = contexts; - this.Entities = entities; - } - - public void CopyTo(AIRequest request) - { - if (HasContexts) - { - request.Contexts = Contexts; - } - - if (HasEntities) - { - request.Entities = Entities; - } - } - - } -} diff --git a/Platform.Dialogflow/MultipartHttpClient.cs b/Platform.Dialogflow/MultipartHttpClient.cs deleted file mode 100644 index d7351612..00000000 --- a/Platform.Dialogflow/MultipartHttpClient.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Text; - -namespace BotSharp.Core.Engines.Dialogflow -{ - public class MultipartHttpClient - { - private const string delimiter = "--"; - private string boundary = "SwA" + DateTime.UtcNow.Ticks.ToString("x") + "SwA"; - private HttpWebRequest request; - private BinaryWriter os; - - public MultipartHttpClient(HttpWebRequest request) - { - this.request = request; - } - - public void connect() - { - request.ContentType = "multipart/form-data; boundary=" + boundary; - request.SendChunked = true; - request.KeepAlive = true; - - os = new BinaryWriter(request.GetRequestStream(), Encoding.UTF8); - } - - public void addStringPart(string paramName, string data) - { - WriteString(delimiter + boundary + "\r\n"); - WriteString("Content-Type: application/json\r\n"); - WriteString("Content-Disposition: form-data; name=\"" + paramName + "\"\r\n"); - WriteString("\r\n" + data + "\r\n"); - } - - public void addFilePart(string paramName, string fileName, Stream data) - { - WriteString(delimiter + boundary + "\r\n"); - WriteString("Content-Disposition: form-data; name=\"" + paramName + "\"; filename=\"" + fileName + "\"\r\n"); - WriteString("Content-Type: audio/wav\r\n"); - - WriteString("\r\n"); - - int bufferSize = 4096; - byte[] buffer = new byte[bufferSize]; - - int bytesActuallyRead; - - bytesActuallyRead = data.Read(buffer, 0, bufferSize); - while (bytesActuallyRead > 0) - { - os.Write(buffer, 0, bytesActuallyRead); - bytesActuallyRead = data.Read(buffer, 0, bufferSize); - } - - WriteString("\r\n"); - } - - public void finish() - { - WriteString(delimiter + boundary + delimiter + "\r\n"); - os.Close(); - } - - private void WriteString(string str) - { - os.Write(Encoding.UTF8.GetBytes(str)); - } - - public string getResponse() - { - try - { - var httpResponse = request.GetResponse() as HttpWebResponse; - using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) - { - var result = streamReader.ReadToEnd(); - return result; - } - } - catch (WebException we) - { - using (var stream = we.Response.GetResponseStream()) - { - using (var reader = new StreamReader(stream)) - { - return reader.ReadToEnd(); - } - } - } - } - } -} diff --git a/Platform.Dialogflow/Platform.Dialogflow.csproj b/Platform.Dialogflow/Platform.Dialogflow.csproj deleted file mode 100644 index 4001aeaa..00000000 --- a/Platform.Dialogflow/Platform.Dialogflow.csproj +++ /dev/null @@ -1,37 +0,0 @@ - - - - netstandard2.0 - Debug;Release;RASA;ARTICULATE - - - - TRACE;DEBUG - bin\RASA - false - - - - DEBUG;TRACE;DIALOGFLOW;NETSTANDARD;NETSTANDARD2_0 - false - - - - TRACE;DEBUG - false - - - - TRACE;DEBUG;DIALOGFLOW - bin\DIALOGFLOW - - - - - - - - - - - diff --git a/Platform.Dialogflow/ViewModels/DialogflowAllEntityViewModel.cs b/Platform.Dialogflow/ViewModels/DialogflowAllEntityViewModel.cs deleted file mode 100644 index e66f3b42..00000000 --- a/Platform.Dialogflow/ViewModels/DialogflowAllEntityViewModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Platform.Dialogflow.ViewModels -{ - public class DialogflowAllEntityViewModel - { - public int Count { get; set; } - - public string Id { get; set; } - - public string Name { get; set; } - - public string Preview { get; set; } - } -} diff --git a/Platform.Dialogflow/ViewModels/QueryModel.cs b/Platform.Dialogflow/ViewModels/QueryModel.cs deleted file mode 100644 index 9d4f7891..00000000 --- a/Platform.Dialogflow/ViewModels/QueryModel.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Text; - -namespace Platform.Dialogflow.ViewModels -{ - public class QueryModel - { - public QueryModel() - { - Contexts = new List(); - } - - /// - /// Array of additional context objects. Should be sent via a POST /query request. - /// Contexts sent in a query are activated before the query. - /// - public List Contexts { get; set; } - - /// - /// Object containing event name and additional data. - /// The "data" parameter can be submitted only in POST requests. - /// - public String Event { get;set; } - - /// - /// Language tag, e.g., en, es etc. - /// - public String Lang { get; set; } - - /// - /// Natural language text to be processed. Query length should not exceed 256 characters. - /// - [Required] - public String Query { get; set; } - - /// - /// A string token up to 36 symbols long, used to identify the client and to manage session parameters (including contexts) per client. - /// - [Required] - public String SessionId { get; set; } - - /// - /// Time zone from IANA Time Zone Database Examples: America/New_York, Europe/Paris - /// - public String Timezone { get; set; } - } -} diff --git a/README.rst b/README.rst index 5f5bc28e..3b7d68e7 100644 --- a/README.rst +++ b/README.rst @@ -16,10 +16,6 @@ The Open Source AI Bot Platform Builder :alt: NuGet -.. raw:: html - - - This project is for learning purposes only, please do not use it in a production environment. ********************************************************************************************** diff --git a/README_zh.rst b/README_zh.rst index fca2a8ed..cb4bda67 100644 --- a/README_zh.rst +++ b/README_zh.rst @@ -1,7 +1,3 @@ -.. raw:: html - - - 开源人工智能聊天机器人平台构建框架 ===============================