clean project.
This commit is contained in:
parent
1535edd1a0
commit
70523e4ad5
|
|
@ -4,8 +4,79 @@
|
|||
indent_style = space
|
||||
charset = utf-8
|
||||
# prevent linux/windows problem
|
||||
end_of_line = lf
|
||||
end_of_line = lf
|
||||
csharp_using_directive_placement = outside_namespace:silent
|
||||
csharp_prefer_simple_using_statement = true:suggestion
|
||||
csharp_prefer_braces = true:silent
|
||||
csharp_style_namespace_declarations = block_scoped:silent
|
||||
csharp_style_prefer_method_group_conversion = true:silent
|
||||
csharp_style_prefer_top_level_statements = true:silent
|
||||
csharp_style_expression_bodied_methods = false:silent
|
||||
csharp_style_expression_bodied_constructors = false:silent
|
||||
csharp_style_expression_bodied_operators = false:silent
|
||||
csharp_style_expression_bodied_properties = true:silent
|
||||
csharp_style_expression_bodied_indexers = true:silent
|
||||
csharp_style_expression_bodied_accessors = true:silent
|
||||
csharp_style_expression_bodied_lambdas = true:silent
|
||||
csharp_style_expression_bodied_local_functions = false:silent
|
||||
csharp_indent_labels = one_less_than_current
|
||||
|
||||
# Xml files
|
||||
[*.{xml,csproj}]
|
||||
indent_size = 2
|
||||
|
||||
[*.{cs,vb}]
|
||||
#### Naming styles ####
|
||||
|
||||
# Naming rules
|
||||
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
|
||||
|
||||
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
|
||||
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
|
||||
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
|
||||
|
||||
# Symbol specifications
|
||||
|
||||
dotnet_naming_symbols.interface.applicable_kinds = interface
|
||||
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.interface.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
|
||||
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.types.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
|
||||
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.non_field_members.required_modifiers =
|
||||
|
||||
# Naming styles
|
||||
|
||||
dotnet_naming_style.begins_with_i.required_prefix = I
|
||||
dotnet_naming_style.begins_with_i.required_suffix =
|
||||
dotnet_naming_style.begins_with_i.word_separator =
|
||||
dotnet_naming_style.begins_with_i.capitalization = pascal_case
|
||||
|
||||
dotnet_naming_style.pascal_case.required_prefix =
|
||||
dotnet_naming_style.pascal_case.required_suffix =
|
||||
dotnet_naming_style.pascal_case.word_separator =
|
||||
dotnet_naming_style.pascal_case.capitalization = pascal_case
|
||||
|
||||
dotnet_naming_style.pascal_case.required_prefix =
|
||||
dotnet_naming_style.pascal_case.required_suffix =
|
||||
dotnet_naming_style.pascal_case.word_separator =
|
||||
dotnet_naming_style.pascal_case.capitalization = pascal_case
|
||||
dotnet_style_coalesce_expression = true:suggestion
|
||||
dotnet_style_null_propagation = true:suggestion
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
|
||||
dotnet_style_prefer_auto_properties = true:silent
|
||||
dotnet_style_object_initializer = true:suggestion
|
||||
dotnet_style_operator_placement_when_wrapping = beginning_of_line
|
||||
tab_width = 4
|
||||
indent_size = 4
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
|
@ -1,18 +0,0 @@
|
|||
# Unigram
|
||||
U01:%x[-1,0]
|
||||
U02:%x[0,0]
|
||||
U03:%x[1,0]
|
||||
U05:%x[-1,0]/%x[0,0]
|
||||
U06:%x[0,0]/%x[1,0]
|
||||
|
||||
U11:%x[-1,1]
|
||||
U12:%x[0,1]
|
||||
U13:%x[1,1]
|
||||
U16:%x[-1,1]/%x[0,1]
|
||||
U17:%x[0,1]/%x[1,1]
|
||||
|
||||
U20:%x[-1,0]/%x[0,0]/%x[1,0]
|
||||
U21:%x[-1,1]/%x[0,1]/%x[1,1]
|
||||
|
||||
# Bigram
|
||||
B
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
conll2000_chunking is downloaded from https://www.clips.uantwerpen.be/conll2000/chunking/
|
||||
The train and test data consist of three columns separated by spaces. Each word has been put on a separate line and there is an empty line after each sentence. The first column contains the current word, the second its part-of-speech tag as derived by the Brill tagger and the third its chunk tag as derived from the WSJ corpus.
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,258 +0,0 @@
|
|||
{
|
||||
"E-e": -3.14e+100,
|
||||
"E-d": -3.14e+100,
|
||||
"E-g": -3.14e+100,
|
||||
"E-f": -3.14e+100,
|
||||
"E-a": -3.14e+100,
|
||||
"E-c": -3.14e+100,
|
||||
"E-b": -3.14e+100,
|
||||
"E-m": -3.14e+100,
|
||||
"S-rg": -10.275268591948773,
|
||||
"E-o": -3.14e+100,
|
||||
"E-n": -3.14e+100,
|
||||
"E-i": -3.14e+100,
|
||||
"E-h": -3.14e+100,
|
||||
"E-k": -3.14e+100,
|
||||
"E-j": -3.14e+100,
|
||||
"E-u": -3.14e+100,
|
||||
"E-t": -3.14e+100,
|
||||
"E-w": -3.14e+100,
|
||||
"E-v": -3.14e+100,
|
||||
"E-q": -3.14e+100,
|
||||
"E-p": -3.14e+100,
|
||||
"E-s": -3.14e+100,
|
||||
"M-bg": -3.14e+100,
|
||||
"M-uj": -3.14e+100,
|
||||
"E-y": -3.14e+100,
|
||||
"E-x": -3.14e+100,
|
||||
"E-z": -3.14e+100,
|
||||
"B-uz": -3.14e+100,
|
||||
"S-d": -3.903919764181873,
|
||||
"M-rg": -3.14e+100,
|
||||
"E-nt": -3.14e+100,
|
||||
"B-d": -3.9750475297585357,
|
||||
"B-uv": -3.14e+100,
|
||||
"E-vi": -3.14e+100,
|
||||
"B-mq": -6.78695300139688,
|
||||
"M-rr": -3.14e+100,
|
||||
"S-ag": -6.954113917960154,
|
||||
"M-jn": -3.14e+100,
|
||||
"E-l": -3.14e+100,
|
||||
"M-rz": -3.14e+100,
|
||||
"B-ud": -3.14e+100,
|
||||
"S-an": -12.84021794941031,
|
||||
"B-qg": -3.14e+100,
|
||||
"B-ug": -3.14e+100,
|
||||
"M-y": -3.14e+100,
|
||||
"S-qg": -3.14e+100,
|
||||
"S-z": -3.14e+100,
|
||||
"S-y": -6.1970794699489575,
|
||||
"S-x": -8.427419656069674,
|
||||
"S-w": -3.14e+100,
|
||||
"S-v": -3.053292303412302,
|
||||
"S-u": -6.940320595827818,
|
||||
"S-t": -3.14e+100,
|
||||
"B-nrt": -4.985642733519195,
|
||||
"S-r": -2.7635336784127853,
|
||||
"S-q": -4.888658618255058,
|
||||
"M-zg": -3.14e+100,
|
||||
"S-o": -8.464460927750023,
|
||||
"S-n": -3.8551483897645107,
|
||||
"B-zg": -3.14e+100,
|
||||
"S-l": -3.14e+100,
|
||||
"S-k": -6.940320595827818,
|
||||
"S-in": -3.14e+100,
|
||||
"S-i": -3.14e+100,
|
||||
"S-h": -8.650563207383884,
|
||||
"S-g": -6.507826815331734,
|
||||
"B-f": -5.491630418482717,
|
||||
"S-e": -5.942513006281674,
|
||||
"M-en": -3.14e+100,
|
||||
"S-c": -4.786966795861212,
|
||||
"S-b": -6.472888763970454,
|
||||
"S-a": -3.9025396831295227,
|
||||
"B-g": -3.14e+100,
|
||||
"B-b": -5.018374362109218,
|
||||
"B-c": -3.423880184954888,
|
||||
"M-ug": -3.14e+100,
|
||||
"B-a": -4.762305214596967,
|
||||
"E-qe": -3.14e+100,
|
||||
"M-x": -3.14e+100,
|
||||
"E-nz": -3.14e+100,
|
||||
"M-z": -3.14e+100,
|
||||
"M-u": -3.14e+100,
|
||||
"B-k": -3.14e+100,
|
||||
"M-w": -3.14e+100,
|
||||
"B-jn": -3.14e+100,
|
||||
"S-yg": -13.533365129970255,
|
||||
"B-o": -8.433498702146057,
|
||||
"B-l": -4.905883584659895,
|
||||
"B-m": -3.6524299819046386,
|
||||
"M-m": -3.14e+100,
|
||||
"M-l": -3.14e+100,
|
||||
"M-o": -3.14e+100,
|
||||
"M-n": -3.14e+100,
|
||||
"M-i": -3.14e+100,
|
||||
"M-h": -3.14e+100,
|
||||
"B-t": -3.3647479094528574,
|
||||
"M-ul": -3.14e+100,
|
||||
"B-z": -7.045681111485645,
|
||||
"M-d": -3.14e+100,
|
||||
"M-mg": -3.14e+100,
|
||||
"B-y": -9.844485675856319,
|
||||
"M-a": -3.14e+100,
|
||||
"S-nrt": -3.14e+100,
|
||||
"M-c": -3.14e+100,
|
||||
"M-uz": -3.14e+100,
|
||||
"E-mg": -3.14e+100,
|
||||
"B-i": -6.1157847275557105,
|
||||
"M-b": -3.14e+100,
|
||||
"E-uz": -3.14e+100,
|
||||
"B-n": -1.6966257797548328,
|
||||
"E-uv": -3.14e+100,
|
||||
"M-ud": -3.14e+100,
|
||||
"M-p": -3.14e+100,
|
||||
"E-ul": -3.14e+100,
|
||||
"E-mq": -3.14e+100,
|
||||
"M-s": -3.14e+100,
|
||||
"M-yg": -3.14e+100,
|
||||
"E-uj": -3.14e+100,
|
||||
"E-ud": -3.14e+100,
|
||||
"S-ln": -3.14e+100,
|
||||
"M-r": -3.14e+100,
|
||||
"E-ng": -3.14e+100,
|
||||
"B-r": -3.4098187790818413,
|
||||
"E-en": -3.14e+100,
|
||||
"M-qg": -3.14e+100,
|
||||
"B-s": -5.522673590839954,
|
||||
"S-rr": -3.14e+100,
|
||||
"B-p": -4.200984132085048,
|
||||
"B-dg": -3.14e+100,
|
||||
"M-uv": -3.14e+100,
|
||||
"S-zg": -3.14e+100,
|
||||
"B-v": -2.6740584874265685,
|
||||
"S-tg": -6.272842531880403,
|
||||
"B-w": -3.14e+100,
|
||||
"B-e": -8.563551830394255,
|
||||
"M-k": -3.14e+100,
|
||||
"M-j": -3.14e+100,
|
||||
"B-df": -8.888974230828882,
|
||||
"M-e": -3.14e+100,
|
||||
"E-tg": -3.14e+100,
|
||||
"M-t": -3.14e+100,
|
||||
"E-nr": -3.14e+100,
|
||||
"M-nrfg": -3.14e+100,
|
||||
"B-nr": -2.2310495913769506,
|
||||
"E-df": -3.14e+100,
|
||||
"E-dg": -3.14e+100,
|
||||
"S-jn": -3.14e+100,
|
||||
"M-q": -3.14e+100,
|
||||
"B-mg": -3.14e+100,
|
||||
"B-ln": -3.14e+100,
|
||||
"M-f": -3.14e+100,
|
||||
"E-ln": -3.14e+100,
|
||||
"E-yg": -3.14e+100,
|
||||
"S-bg": -3.14e+100,
|
||||
"E-ns": -3.14e+100,
|
||||
"B-tg": -3.14e+100,
|
||||
"E-qg": -3.14e+100,
|
||||
"S-nr": -4.483663103956885,
|
||||
"S-ns": -3.14e+100,
|
||||
"M-vn": -3.14e+100,
|
||||
"S-nt": -12.147070768850364,
|
||||
"S-nz": -3.14e+100,
|
||||
"S-ad": -11.048458480182255,
|
||||
"B-yg": -3.14e+100,
|
||||
"M-v": -3.14e+100,
|
||||
"E-vn": -3.14e+100,
|
||||
"S-ng": -4.913434861102905,
|
||||
"M-g": -3.14e+100,
|
||||
"M-nt": -3.14e+100,
|
||||
"S-en": -3.14e+100,
|
||||
"M-nr": -3.14e+100,
|
||||
"M-ns": -3.14e+100,
|
||||
"S-vq": -3.14e+100,
|
||||
"B-uj": -3.14e+100,
|
||||
"M-nz": -3.14e+100,
|
||||
"B-qe": -3.14e+100,
|
||||
"M-in": -3.14e+100,
|
||||
"M-ng": -3.14e+100,
|
||||
"S-vn": -11.453923588290419,
|
||||
"E-zg": -3.14e+100,
|
||||
"S-vi": -3.14e+100,
|
||||
"S-vg": -5.9430181843676895,
|
||||
"S-vd": -3.14e+100,
|
||||
"B-ad": -6.680066036784177,
|
||||
"E-rz": -3.14e+100,
|
||||
"B-ag": -3.14e+100,
|
||||
"B-vd": -9.044728760238115,
|
||||
"S-mq": -3.14e+100,
|
||||
"B-vi": -12.434752841302146,
|
||||
"E-rr": -3.14e+100,
|
||||
"B-rr": -12.434752841302146,
|
||||
"M-vq": -3.14e+100,
|
||||
"E-jn": -3.14e+100,
|
||||
"B-vn": -4.3315610890163585,
|
||||
"S-mg": -10.825314928868044,
|
||||
"B-in": -3.14e+100,
|
||||
"M-vi": -3.14e+100,
|
||||
"M-an": -3.14e+100,
|
||||
"M-vd": -3.14e+100,
|
||||
"B-rg": -3.14e+100,
|
||||
"M-vg": -3.14e+100,
|
||||
"M-ad": -3.14e+100,
|
||||
"M-ag": -3.14e+100,
|
||||
"E-rg": -3.14e+100,
|
||||
"S-uz": -9.299258625372996,
|
||||
"B-en": -3.14e+100,
|
||||
"S-uv": -8.15808672228609,
|
||||
"S-df": -3.14e+100,
|
||||
"S-dg": -8.948397651299683,
|
||||
"M-qe": -3.14e+100,
|
||||
"B-ng": -3.14e+100,
|
||||
"E-bg": -3.14e+100,
|
||||
"S-ul": -8.4153713175535,
|
||||
"S-uj": -6.85251045118004,
|
||||
"S-ug": -7.5394037026636855,
|
||||
"B-ns": -2.8228438314969213,
|
||||
"S-ud": -7.728230161053767,
|
||||
"B-nt": -4.846091668182416,
|
||||
"B-ul": -3.14e+100,
|
||||
"E-in": -3.14e+100,
|
||||
"B-bg": -3.14e+100,
|
||||
"M-df": -3.14e+100,
|
||||
"M-dg": -3.14e+100,
|
||||
"M-nrt": -3.14e+100,
|
||||
"B-j": -5.0576191284681915,
|
||||
"E-ug": -3.14e+100,
|
||||
"E-vq": -3.14e+100,
|
||||
"B-vg": -3.14e+100,
|
||||
"B-nz": -3.94698846057672,
|
||||
"S-qe": -3.14e+100,
|
||||
"B-rz": -7.946116471570005,
|
||||
"B-nrfg": -5.873722175405573,
|
||||
"E-ad": -3.14e+100,
|
||||
"E-ag": -3.14e+100,
|
||||
"B-u": -9.163917277503234,
|
||||
"M-ln": -3.14e+100,
|
||||
"B-an": -8.697083223018778,
|
||||
"M-mq": -3.14e+100,
|
||||
"E-an": -3.14e+100,
|
||||
"S-s": -3.14e+100,
|
||||
"B-q": -6.998123858956596,
|
||||
"E-nrt": -3.14e+100,
|
||||
"B-h": -13.533365129970255,
|
||||
"E-r": -3.14e+100,
|
||||
"S-p": -2.9868401813596317,
|
||||
"M-tg": -3.14e+100,
|
||||
"S-rz": -3.14e+100,
|
||||
"S-nrfg": -3.14e+100,
|
||||
"B-vq": -12.147070768850364,
|
||||
"B-x": -3.14e+100,
|
||||
"E-vd": -3.14e+100,
|
||||
"E-nrfg": -3.14e+100,
|
||||
"S-m": -3.269200652116097,
|
||||
"E-vg": -3.14e+100,
|
||||
"S-f": -5.194820249981676,
|
||||
"S-j": -4.911992119644354
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"M": {
|
||||
"M": -1.2603623820268226,
|
||||
"E": -0.33344856811948514
|
||||
},
|
||||
"S": {
|
||||
"S": -0.6658631448798212,
|
||||
"B": -0.7211965654669841
|
||||
},
|
||||
"B": {
|
||||
"M": -0.916290731874155,
|
||||
"E": -0.51082562376599
|
||||
},
|
||||
"E": {
|
||||
"S": -0.8085250474669937,
|
||||
"B": -0.5897149736854513
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
创新办 3 i
|
||||
云计算 5
|
||||
凱特琳 nz
|
||||
机器学习 3
|
||||
深度学习 8
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<Configurations>Debug;Release;</Configurations>
|
||||
<UserSecretsId>4ee89154-9131-4e6b-8fd5-d4f04a8d77c4</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RASA|AnyCPU'">
|
||||
<DefineConstants>$(DefineConstants);RASA</DefineConstants>
|
||||
<OutputPath>bin\RASA</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DIALOGFLOW|AnyCPU'">
|
||||
<Optimize>false</Optimize>
|
||||
<DefineConstants>$(DefineConstants);</DefineConstants>
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ARTICULATE|AnyCPU'">
|
||||
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="App_Data\AgentArchive\**" />
|
||||
<Compile Remove="App_Data\AgentStorage\**" />
|
||||
<Compile Remove="App_Data\Corpus\**" />
|
||||
<Compile Remove="App_Data\Projects\**" />
|
||||
<Compile Remove="App_Data\SessionStorage\**" />
|
||||
<Compile Remove="PublishOutput\**" />
|
||||
<Compile Remove="publish\**" />
|
||||
<Content Remove="App_Data\AgentArchive\**" />
|
||||
<Content Remove="App_Data\AgentStorage\**" />
|
||||
<Content Remove="App_Data\Corpus\**" />
|
||||
<Content Remove="App_Data\DbInitializer\**" />
|
||||
<Content Remove="App_Data\Projects\**" />
|
||||
<Content Remove="App_Data\SessionStorage\**" />
|
||||
<Content Remove="App_Data\TrainingFiles\**" />
|
||||
<Content Remove="PublishOutput\**" />
|
||||
<Content Remove="publish\**" />
|
||||
<EmbeddedResource Remove="App_Data\AgentArchive\**" />
|
||||
<EmbeddedResource Remove="App_Data\AgentStorage\**" />
|
||||
<EmbeddedResource Remove="App_Data\Corpus\**" />
|
||||
<EmbeddedResource Remove="App_Data\Projects\**" />
|
||||
<EmbeddedResource Remove="App_Data\SessionStorage\**" />
|
||||
<EmbeddedResource Remove="PublishOutput\**" />
|
||||
<EmbeddedResource Remove="publish\**" />
|
||||
<None Remove="App_Data\AgentArchive\**" />
|
||||
<None Remove="App_Data\AgentStorage\**" />
|
||||
<None Remove="App_Data\Corpus\**" />
|
||||
<None Remove="App_Data\DbInitializer\**" />
|
||||
<None Remove="App_Data\Projects\**" />
|
||||
<None Remove="App_Data\SessionStorage\**" />
|
||||
<None Remove="PublishOutput\**" />
|
||||
<None Remove="publish\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="App_Data\BotSharp.db" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="App_Data\Corpus\CoNLL\conll2000_chunking_train.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DotNetToolkit" Version="1.7.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.16" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Channels\BotSharp.Channel.FacebookMessenger\BotSharp.Channel.FacebookMessenger.csproj" />
|
||||
<ProjectReference Include="..\Channels\BotSharp.Channel.Weixin\BotSharp.Channel.Weixin.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="Settings\app.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="Settings\BotSharpNLU_zh-cn.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="Settings\channels.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="Settings\DialogflowAi.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="Settings\auth.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="Settings\BotSharpNLU_en.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="Settings\db.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="Settings\logging.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="Settings\swagger.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="App_Data\CRFLite\template.en">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="App_Data\Resources\dict.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="App_Data\userdict.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ActiveDebugProfile>BotSharp.WebHost</ActiveDebugProfile>
|
||||
<NameOfLastUsedPublishProfile>Docker</NameOfLastUsedPublishProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RASA|AnyCPU'">
|
||||
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DIALOGFLOW|AnyCPU'">
|
||||
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace BotSharp.WebHost
|
||||
{
|
||||
public class InitializationLoader
|
||||
{
|
||||
public IHostingEnvironment Env { get; set; }
|
||||
public IConfiguration Config { get; set; }
|
||||
public void Load()
|
||||
{
|
||||
/*var assemblies = (string[])AppDomain.CurrentDomain.GetData("Assemblies");
|
||||
var appsLoaders1 = TypeHelper.GetInstanceWithInterface<IInitializationLoader>(assemblies);
|
||||
appsLoaders1.ForEach(loader =>
|
||||
{
|
||||
loader.Initialize(Config, Env);
|
||||
});*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace BotSharp.WebHost
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args)
|
||||
{
|
||||
return Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webHost =>
|
||||
{
|
||||
webHost
|
||||
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||
{
|
||||
var env = hostingContext.HostingEnvironment;
|
||||
string dir = Path.GetFullPath(env.ContentRootPath);
|
||||
string settingsFolder = Path.Combine(dir, "Settings");
|
||||
|
||||
// locate setting folder
|
||||
if (!Directory.Exists(settingsFolder))
|
||||
{
|
||||
dir = Path.GetFullPath(env.ContentRootPath + "/..");
|
||||
}
|
||||
|
||||
settingsFolder = Path.Combine(dir, "Settings");
|
||||
|
||||
if (!Directory.Exists(settingsFolder))
|
||||
{
|
||||
dir = Path.GetFullPath(env.ContentRootPath + "/bin");
|
||||
}
|
||||
|
||||
settingsFolder = Path.Combine(dir, "Settings");
|
||||
|
||||
Console.WriteLine($"Read settings from {settingsFolder}");
|
||||
|
||||
var settings = Directory.GetFiles(settingsFolder, "*.json");
|
||||
settings.ToList().ForEach(setting =>
|
||||
{
|
||||
config.AddJsonFile(setting, optional: false, reloadOnChange: true);
|
||||
});
|
||||
})
|
||||
.UseUrls("http://0.0.0.0:3112")
|
||||
.UseStartup<Startup>();
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
|
||||
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
||||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
||||
<ProjectGuid>03dca427-327a-4fc9-9a2f-57d17f16708c</ProjectGuid>
|
||||
<publishUrl>publish\</publishUrl>
|
||||
<DeleteExistingFiles>True</DeleteExistingFiles>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<SelfContained>false</SelfContained>
|
||||
<_IsPortable>true</_IsPortable>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
|
||||
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<TimeStampOfAssociatedLegacyPublishXmlFile />
|
||||
<_PublishTargetUrl>D:\Projects\BotSharp\BotSharp.WebHost\publish\</_PublishTargetUrl>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:3112/",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"BotSharp.WebHost": {
|
||||
"commandName": "Project",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:3112/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"botSharpNLU_en": {
|
||||
"provider": "BotSharpProvider",
|
||||
|
||||
"botSharpProvider": {
|
||||
},
|
||||
|
||||
"pipe": "BotSharpTokenizer, BotSharpTagger, BotSharpNER, BotSharpIntentClassifier",
|
||||
|
||||
"botSharpTokenizer": {
|
||||
"tokenizer": "TreebankTokenizer"
|
||||
},
|
||||
|
||||
"botSharpIntentClassifier": {
|
||||
"classifer": "NaiveBayesClassifier",
|
||||
"wordvecModel": "|App_Data|wordvec_enu.bin"
|
||||
},
|
||||
|
||||
"botSharpTagger": {
|
||||
"tagger": "NGramTagger"
|
||||
},
|
||||
|
||||
"botSharpNER": {
|
||||
"template": "|App_Data|CRFLite/template.en"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"botSharpNLU_zh-cn": {
|
||||
"provider": "BotSharpProvider",
|
||||
|
||||
"botSharpProvider": {
|
||||
},
|
||||
|
||||
"pipe": "BotSharpTokenizer, BotSharpTagger, BotSharpNER, BotSharpIntentClassifier",
|
||||
|
||||
"botSharpTokenizer": {
|
||||
"tokenizer": "JiebaTokenizer"
|
||||
},
|
||||
|
||||
"botSharpIntentClassifier": {
|
||||
"classifer": "NaiveBayesClassifier",
|
||||
"wordvecModel": "|App_Data|wordvec_enu.bin"
|
||||
},
|
||||
|
||||
"botSharpTagger": {
|
||||
"tagger": "JiebaTagger"
|
||||
},
|
||||
|
||||
"botSharpNER": {
|
||||
"template": "|App_Data|CRFLite/template.en"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"version": "0.5.0",
|
||||
"assemblies": "BotSharp.Core",
|
||||
|
||||
"platformModuleName": "DialogflowAi",
|
||||
"overrideFallback": true,
|
||||
|
||||
"modules": [
|
||||
{
|
||||
"Name": "DialogflowAi",
|
||||
"Type": "BotSharp.Platform.Dialogflow"
|
||||
},
|
||||
{
|
||||
"Name": "RasaAi",
|
||||
"Type": "BotSharp.Platform.Rasa"
|
||||
},
|
||||
{
|
||||
"Name": "WeixinChannel",
|
||||
"Type": "BotSharp.Channel.Weixin"
|
||||
},
|
||||
{
|
||||
"Name": "FacebookMessengerChannel",
|
||||
"Type": "BotSharp.Channel.FacebookMessenger"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"TokenAuthentication": {
|
||||
"SecretKey": "lfo54FYneUCJNL2EjP9ZxQ==",
|
||||
"Issuer": "BotSharp",
|
||||
"Audience": "BotSharp",
|
||||
"CookieName": "token",
|
||||
"Subject": "BotSharp"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"weixinChannel": {
|
||||
"token": "botsharp",
|
||||
"encodingAESKey": "",
|
||||
"appId": "",
|
||||
"agentId": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"Database": {
|
||||
"Default": "File",
|
||||
"ConnectionStrings": {
|
||||
"InMemory": "DataSource=:memory:",
|
||||
"Redis": "127.0.0.1:6379,defaultDatabase=BotSharp,poolsize=50,ssl=false,writeBuffer=10240,prefix=agent_",
|
||||
"Sqlite": "Data Source=|DataDirectory|BotSharp.db;",
|
||||
"SqlServer": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=BotSharp;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
|
||||
"File": "|DataDirectory|"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"Logging": {
|
||||
//"IncludeScopes": false,
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}//,
|
||||
//"Debug": {
|
||||
// "LogLevel": {
|
||||
// "Default": "Warning"
|
||||
// }
|
||||
//},
|
||||
//"Console": {
|
||||
// "LogLevel": {
|
||||
// "Default": "Warning"
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
// if you want to override platform setting, please set corresponding value,
|
||||
// otherwise you don't need this section.
|
||||
"dialogflowAi": {
|
||||
"botEngine": "BotSharpNLU",
|
||||
"agentStorage": "AgentStorageInFile",
|
||||
"contextStorage": "ContextStorageInFile"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
// if you want to override platform setting, please set corresponding value,
|
||||
// otherwise you don't need this section.
|
||||
"rasaAi": {
|
||||
"botEngine": "BotSharpNLU",
|
||||
"agentStorage": "AgentStorageInFile",
|
||||
"contextStorage": "ContextStorageInFile"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
{
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"Swagger": {
|
||||
"Contact": {
|
||||
"Email": "botsharp2018@gmail.com",
|
||||
"Name": "BotSharp AI",
|
||||
"Url": "https://github.com/Oceania2018"
|
||||
},
|
||||
"Description": "BotSharp is a chatbot platform builder running in .NET Core",
|
||||
"Endpoint": "/swagger/v1/swagger.json",
|
||||
"License": {
|
||||
"Name": "Apache License 2.0",
|
||||
"Url": "https://github.com/Oceania2018/BotSharp/blob/master/LICENSE"
|
||||
},
|
||||
"TermsOfService": "http://www.apache.org/licenses/",
|
||||
"Title": "BotSharp API",
|
||||
"Version": "v1",
|
||||
"Stylesheet": "/swagger.css"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,167 +0,0 @@
|
|||
using BotSharp.Core.Modules;
|
||||
using DotNetToolkit.JwtHelper;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace BotSharp.WebHost
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
this.modulesStartup = new ModulesStartup(configuration);
|
||||
}
|
||||
|
||||
private readonly ModulesStartup modulesStartup;
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowAllHeaders", builder =>
|
||||
{
|
||||
builder.WithOrigins("http://localhost:3110")
|
||||
.AllowCredentials()
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod();
|
||||
});
|
||||
});
|
||||
services.AddJwtAuth(Configuration);
|
||||
|
||||
services.AddMvc(options =>
|
||||
{
|
||||
options.RespectBrowserAcceptHeader = true;
|
||||
})
|
||||
.AddNewtonsoftJson(options =>
|
||||
{
|
||||
options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
|
||||
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
});
|
||||
|
||||
//PlatformModuleAssembyLoader.LoadAssemblies(Configuration, assembly => mvcBuilder.AddApplicationPart(assembly));
|
||||
|
||||
this.modulesStartup.ConfigureServices(services);
|
||||
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
|
||||
{
|
||||
In = ParameterLocation.Header,
|
||||
Description = "Please insert JWT with Bearer schema. Example: \"Authorization: Bearer {token}\"",
|
||||
Name = "Authorization",
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
Scheme = "Bearer"
|
||||
});
|
||||
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{ new OpenApiSecurityScheme(){
|
||||
Reference = new OpenApiReference{Type = ReferenceType.SecurityScheme ,Id = "Bearer"}
|
||||
}, new List<string>(0) }
|
||||
});
|
||||
|
||||
var info = Configuration.GetSection("Swagger").Get<OpenApiInfo>();
|
||||
c.SwaggerDoc(info.Version, info);
|
||||
|
||||
var filePath = Path.Combine(AppContext.BaseDirectory, "BotSharp.RestApi.xml");
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
c.IncludeXmlComments(filePath);
|
||||
}
|
||||
|
||||
var xmlPath = Path.Combine(AppContext.BaseDirectory, "BotSharp.Platform.Dialogflow.xml");
|
||||
if (File.Exists(xmlPath))
|
||||
{
|
||||
c.IncludeXmlComments(xmlPath);
|
||||
}
|
||||
|
||||
c.OperationFilter<SwaggerFileUploadOperation>();
|
||||
}).AddSwaggerGenNewtonsoftSupport();
|
||||
|
||||
// register platform dependency
|
||||
/*services.AddTransient<IBotEngine>((provider) =>
|
||||
{
|
||||
return instance;
|
||||
});*/
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseCors("AllowAllHeaders");
|
||||
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
var info = Configuration.GetSection("Swagger").Get<OpenApiInfo>();
|
||||
|
||||
c.SupportedSubmitMethods(SubmitMethod.Get, SubmitMethod.Post, SubmitMethod.Put, SubmitMethod.Patch, SubmitMethod.Delete);
|
||||
c.ShowExtensions();
|
||||
c.SwaggerEndpoint(Configuration.GetValue<String>("Swagger:Endpoint"), info.Title);
|
||||
c.RoutePrefix = String.Empty;
|
||||
c.DocumentTitle = info.Title;
|
||||
c.InjectStylesheet(Configuration.GetValue<String>("Swagger:Stylesheet"));
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"{info.Title} [{info.Version}] {info.License.Name}");
|
||||
Console.WriteLine($"{info.Description}");
|
||||
Console.WriteLine($"{info.Contact.Name}, {DateTime.UtcNow.ToString()}");
|
||||
Console.WriteLine();
|
||||
});
|
||||
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
string token = context.Request.Headers["Authorization"];
|
||||
if (!string.IsNullOrWhiteSpace(token) && (token = token.Split(' ').Last()).Length == 32)
|
||||
{
|
||||
var config = (IConfiguration)AppDomain.CurrentDomain.GetData("Configuration");
|
||||
context.Request.Headers["Authorization"] = token;
|
||||
|
||||
context.Request.Headers["Authorization"] = "Bearer " + JwtToken.GenerateToken(config, token);
|
||||
}
|
||||
|
||||
await next.Invoke();
|
||||
});
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.UseEndpoints(routes=>
|
||||
{
|
||||
routes.MapControllers();
|
||||
});
|
||||
|
||||
this.modulesStartup.Configure(app, env);
|
||||
|
||||
AppDomain.CurrentDomain.SetData("DataPath", Path.Combine(env.ContentRootPath, "App_Data"));
|
||||
AppDomain.CurrentDomain.SetData("Configuration", Configuration);
|
||||
AppDomain.CurrentDomain.SetData("ContentRootPath", env.ContentRootPath);
|
||||
AppDomain.CurrentDomain.SetData("Assemblies", Configuration.GetValue<String>("Assemblies").Split(','));
|
||||
|
||||
/*InitializationLoader loader = new InitializationLoader();
|
||||
loader.Env = env;
|
||||
loader.Config = Configuration;
|
||||
loader.Load();*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.WebHost
|
||||
{
|
||||
public class SwaggerFileUploadOperation : IOperationFilter
|
||||
{
|
||||
|
||||
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||
{
|
||||
if(context.MethodInfo.Name == "Import")
|
||||
{
|
||||
if(operation.RequestBody.Content.FirstOrDefault().Value?.Schema?.Properties.ContainsKey("uploadedFile") == true)
|
||||
{
|
||||
var p = operation.RequestBody.Content.FirstOrDefault();
|
||||
p.Value.Schema.Properties["uploadedFile"].Description = "Upload Zip File, meta.json is the extra data for customized function.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.5 KiB |
|
|
@ -1,3 +0,0 @@
|
|||
.topbar-wrapper a span {
|
||||
visibility: hidden;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
327
BotSharp.sln
327
BotSharp.sln
|
|
@ -3,37 +3,25 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.6.33712.159
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.WebHost", "BotSharp.WebHost\BotSharp.WebHost.csproj", "{03DCA427-327A-4FC9-9A2F-57D17F16708C}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution items", "{44D9C8BF-FA7B-4FA1-AF2D-93BC223D11B6}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
Directory.Build.props = Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Channels", "Channels", "{FC2A12DB-AC88-41E4-A58C-9EEC6DAD91E1}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platforms", "Platforms", "{FFA662D3-B67B-478D-92FC-76DC5EB64412}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{E29DC6C4-5E57-48C5-BCB0-6B8F84782749}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Platform.Dialogflow", "Platforms\BotSharp.Platform.Dialogflow\BotSharp.Platform.Dialogflow.csproj", "{ED603A1B-F820-4E32-B0DA-6FB172A59427}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Platform.Rasa", "Platforms\BotSharp.Platform.Rasa\BotSharp.Platform.Rasa.csproj", "{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Platform.OpenAi", "Platforms\BotSharp.Platform.OpenAi\BotSharp.Platform.OpenAi.csproj", "{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Channel.FacebookMessenger", "Channels\BotSharp.Channel.FacebookMessenger\BotSharp.Channel.FacebookMessenger.csproj", "{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Channel.Weixin", "Channels\BotSharp.Channel.Weixin\BotSharp.Channel.Weixin.csproj", "{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Core", "Infrastructure\BotSharp.Core\BotSharp.Core.csproj", "{EAE30548-2631-4CF5-8EBC-DBF061E169B7}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.WebApi", "Infrastructure\BotSharp.WebApi\BotSharp.WebApi.csproj", "{89D4AE72-81BE-4A48-A868-E344D91CDCB9}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{BD64C6FD-1A31-4169-B334-E184D7438214}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Abstraction", "Infrastructure\BotSharp.Abstraction\BotSharp.Abstraction.csproj", "{DDBFBB8C-106C-497F-8158-E50560814B07}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Core.UnitTest", "Tests\BotSharp.Core.UnitTest\BotSharp.Core.UnitTest.csproj", "{F28DD606-43C6-4CCF-B8FF-41229F0C652E}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Platform.OpenAi", "Platforms\BotSharp.Platform.OpenAi\BotSharp.Platform.OpenAi.csproj", "{73258881-906C-4014-9453-614A98852733}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Channel.FacebookMessenger", "Channels\BotSharp.Channel.FacebookMessenger\BotSharp.Channel.FacebookMessenger.csproj", "{250B37D3-381E-4A08-9161-55A27FA9075F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Channel.Weixin", "Channels\BotSharp.Channel.Weixin\BotSharp.Channel.Weixin.csproj", "{281F2794-AB51-4CF9-9214-43A5F23D0F4F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Platform.Dialogflow", "Platforms\BotSharp.Platform.Dialogflow\BotSharp.Platform.Dialogflow.csproj", "{4F8100FF-431D-4AD2-8095-56350C36DD08}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -51,150 +39,6 @@ Global
|
|||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.ARTICULATE|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.ARTICULATE|Any CPU.Build.0 = Release|Any CPU
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.ARTICULATE|x64.ActiveCfg = Release|x64
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.ARTICULATE|x64.Build.0 = Release|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 = Debug|Any CPU
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.DIALOGFLOW|x64.ActiveCfg = Debug|x64
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.DIALOGFLOW|x64.Build.0 = Debug|x64
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.RASA NLU|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.RASA NLU|Any CPU.Build.0 = Release|Any CPU
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.RASA NLU|x64.ActiveCfg = Release|x64
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.RASA NLU|x64.Build.0 = Release|x64
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.RASA|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.RASA|Any CPU.Build.0 = Release|Any CPU
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.RASA|x64.ActiveCfg = Release|x64
|
||||
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.RASA|x64.Build.0 = Release|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
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.ARTICULATE|x64.Build.0 = Debug|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.RASA NLU|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.RASA NLU|Any CPU.Build.0 = Release|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.RASA NLU|x64.ActiveCfg = Release|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.RASA NLU|x64.Build.0 = Release|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.RASA|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.RASA|Any CPU.Build.0 = Release|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.RASA|x64.ActiveCfg = Release|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.RASA|x64.Build.0 = Release|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427}.Release|x64.Build.0 = Release|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.ARTICULATE|x64.Build.0 = Debug|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.RASA NLU|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.RASA NLU|Any CPU.Build.0 = Release|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.RASA NLU|x64.ActiveCfg = Release|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.RASA NLU|x64.Build.0 = Release|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.RASA|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.RASA|Any CPU.Build.0 = Release|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.RASA|x64.ActiveCfg = Release|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.RASA|x64.Build.0 = Release|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3}.Release|x64.Build.0 = Release|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.ARTICULATE|x64.Build.0 = Debug|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.RASA NLU|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.RASA NLU|Any CPU.Build.0 = Release|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.RASA NLU|x64.ActiveCfg = Release|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.RASA NLU|x64.Build.0 = Release|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.RASA|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.RASA|Any CPU.Build.0 = Release|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.RASA|x64.ActiveCfg = Release|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.RASA|x64.Build.0 = Release|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052}.Release|x64.Build.0 = Release|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.ARTICULATE|x64.Build.0 = Debug|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.RASA NLU|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.RASA NLU|Any CPU.Build.0 = Release|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.RASA NLU|x64.ActiveCfg = Release|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.RASA NLU|x64.Build.0 = Release|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.RASA|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.RASA|Any CPU.Build.0 = Release|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.RASA|x64.ActiveCfg = Release|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.RASA|x64.Build.0 = Release|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.ARTICULATE|x64.Build.0 = Debug|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.RASA NLU|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.RASA NLU|Any CPU.Build.0 = Release|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.RASA NLU|x64.ActiveCfg = Release|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.RASA NLU|x64.Build.0 = Release|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.RASA|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.RASA|Any CPU.Build.0 = Release|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.RASA|x64.ActiveCfg = Release|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.RASA|x64.Build.0 = Release|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C}.Release|x64.Build.0 = Release|Any CPU
|
||||
{EAE30548-2631-4CF5-8EBC-DBF061E169B7}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EAE30548-2631-4CF5-8EBC-DBF061E169B7}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EAE30548-2631-4CF5-8EBC-DBF061E169B7}.ARTICULATE|x64.ActiveCfg = Debug|x64
|
||||
|
|
@ -243,43 +87,138 @@ Global
|
|||
{89D4AE72-81BE-4A48-A868-E344D91CDCB9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{89D4AE72-81BE-4A48-A868-E344D91CDCB9}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{89D4AE72-81BE-4A48-A868-E344D91CDCB9}.Release|x64.Build.0 = Release|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.ARTICULATE|x64.ActiveCfg = ARTICULATE|x64
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.ARTICULATE|x64.Build.0 = ARTICULATE|x64
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.Debug|x64.Build.0 = Debug|x64
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|x64
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|x64
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.RASA NLU|Any CPU.ActiveCfg = RASA NLU|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.RASA NLU|Any CPU.Build.0 = RASA NLU|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.RASA NLU|x64.ActiveCfg = RASA NLU|x64
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.RASA NLU|x64.Build.0 = RASA NLU|x64
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.RASA|Any CPU.ActiveCfg = RASA|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.RASA|Any CPU.Build.0 = RASA|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.RASA|x64.ActiveCfg = RASA|x64
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.RASA|x64.Build.0 = RASA|x64
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.Release|x64.ActiveCfg = Release|x64
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E}.Release|x64.Build.0 = Release|x64
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.ARTICULATE|x64.Build.0 = Debug|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.RASA NLU|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.RASA NLU|Any CPU.Build.0 = Release|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.RASA NLU|x64.ActiveCfg = Release|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.RASA NLU|x64.Build.0 = Release|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.RASA|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.RASA|Any CPU.Build.0 = Release|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.RASA|x64.ActiveCfg = Release|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.RASA|x64.Build.0 = Release|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07}.Release|x64.Build.0 = Release|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.ARTICULATE|x64.Build.0 = Debug|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.RASA NLU|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.RASA NLU|Any CPU.Build.0 = Release|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.RASA NLU|x64.ActiveCfg = Release|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.RASA NLU|x64.Build.0 = Release|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.RASA|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.RASA|Any CPU.Build.0 = Release|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.RASA|x64.ActiveCfg = Release|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.RASA|x64.Build.0 = Release|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{73258881-906C-4014-9453-614A98852733}.Release|x64.Build.0 = Release|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.ARTICULATE|x64.Build.0 = Debug|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.RASA NLU|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.RASA NLU|Any CPU.Build.0 = Release|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.RASA NLU|x64.ActiveCfg = Release|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.RASA NLU|x64.Build.0 = Release|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.RASA|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.RASA|Any CPU.Build.0 = Release|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.RASA|x64.ActiveCfg = Release|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.RASA|x64.Build.0 = Release|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F}.Release|x64.Build.0 = Release|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.ARTICULATE|x64.Build.0 = Debug|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.RASA NLU|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.RASA NLU|Any CPU.Build.0 = Release|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.RASA NLU|x64.ActiveCfg = Release|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.RASA NLU|x64.Build.0 = Release|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.RASA|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.RASA|Any CPU.Build.0 = Release|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.RASA|x64.ActiveCfg = Release|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.RASA|x64.Build.0 = Release|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F}.Release|x64.Build.0 = Release|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.ARTICULATE|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.ARTICULATE|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.ARTICULATE|x64.ActiveCfg = Debug|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.ARTICULATE|x64.Build.0 = Debug|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.RASA NLU|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.RASA NLU|Any CPU.Build.0 = Release|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.RASA NLU|x64.ActiveCfg = Release|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.RASA NLU|x64.Build.0 = Release|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.RASA|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.RASA|Any CPU.Build.0 = Release|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.RASA|x64.ActiveCfg = Release|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.RASA|x64.Build.0 = Release|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{ED603A1B-F820-4E32-B0DA-6FB172A59427} = {FFA662D3-B67B-478D-92FC-76DC5EB64412}
|
||||
{DEB73945-8F81-45A7-B9FF-7D0828F7FAF3} = {FFA662D3-B67B-478D-92FC-76DC5EB64412}
|
||||
{A3DC5AE7-DE92-4D5D-A7F8-348A17AD1052} = {FFA662D3-B67B-478D-92FC-76DC5EB64412}
|
||||
{79E19C8F-9F3D-4692-B7B1-D171EEB7210B} = {FC2A12DB-AC88-41E4-A58C-9EEC6DAD91E1}
|
||||
{C4605FB3-9C38-4671-BD8D-F03B83FAF16C} = {FC2A12DB-AC88-41E4-A58C-9EEC6DAD91E1}
|
||||
{EAE30548-2631-4CF5-8EBC-DBF061E169B7} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
|
||||
{89D4AE72-81BE-4A48-A868-E344D91CDCB9} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
|
||||
{F28DD606-43C6-4CCF-B8FF-41229F0C652E} = {BD64C6FD-1A31-4169-B334-E184D7438214}
|
||||
{DDBFBB8C-106C-497F-8158-E50560814B07} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
|
||||
{73258881-906C-4014-9453-614A98852733} = {FFA662D3-B67B-478D-92FC-76DC5EB64412}
|
||||
{250B37D3-381E-4A08-9161-55A27FA9075F} = {FC2A12DB-AC88-41E4-A58C-9EEC6DAD91E1}
|
||||
{281F2794-AB51-4CF9-9214-43A5F23D0F4F} = {FC2A12DB-AC88-41E4-A58C-9EEC6DAD91E1}
|
||||
{4F8100FF-431D-4AD2-8095-56350C36DD08} = {FFA662D3-B67B-478D-92FC-76DC5EB64412}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A9969D89-C98B-40A5-A12B-FC87E55B3A19}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="ViewModels\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="RestSharp" Version="110.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Infrastructure\BotSharp.Core\BotSharp.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,112 +0,0 @@
|
|||
using BotSharp.Channel.FacebookMessenger.Models;
|
||||
using BotSharp.Platform.Models;
|
||||
using EntityFrameworkCore.BootKit;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Channel.FacebookMessenger.Controllers
|
||||
{
|
||||
[Route("v1/[controller]")]
|
||||
public class FacebookMessengerController : ControllerBase
|
||||
{
|
||||
[HttpGet("{agentId}")]
|
||||
public ActionResult Verify([FromRoute] string agentId)
|
||||
{
|
||||
var mode = Request.Query.ContainsKey("hub.mode") ? Request.Query["hub.mode"].ToString() : String.Empty;
|
||||
var token = Request.Query.ContainsKey("hub.verify_token") ? Request.Query["hub.verify_token"].ToString() : String.Empty;
|
||||
var challenge = Request.Query.ContainsKey("hub.challenge") ? Request.Query["hub.challenge"].ToString() : String.Empty;
|
||||
|
||||
if (mode == "subscribe")
|
||||
{
|
||||
var dc = new DefaultDataContextLoader().GetDefaultDc();
|
||||
var config = dc.Table<AgentIntegration>().FirstOrDefault(x => x.AgentId == agentId && x.Platform == "Facebook Messenger");
|
||||
|
||||
return config.VerifyToken == token ? Ok(challenge) : Ok(agentId);
|
||||
}
|
||||
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
[HttpPost("{agentId}")]
|
||||
public async Task<ActionResult> CallbackAsync([FromRoute] string agentId)
|
||||
{
|
||||
WebhookEvent body;
|
||||
IWebhookMessageBody response = null;
|
||||
|
||||
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
|
||||
{
|
||||
var json = await reader.ReadToEndAsync();
|
||||
body = JsonConvert.DeserializeObject<WebhookEvent>(json);
|
||||
}
|
||||
|
||||
body.Entry.ForEach(entry =>
|
||||
{
|
||||
entry.Messaging.ForEach(msg =>
|
||||
{
|
||||
// received text message
|
||||
if (msg.Message.ContainsKey("text"))
|
||||
{
|
||||
OnTextMessaged(agentId, new WebhookMessage<WebhookTextMessage>
|
||||
{
|
||||
Sender = msg.Sender,
|
||||
Recipient = msg.Recipient,
|
||||
Timestamp = msg.Timestamp,
|
||||
Message = msg.Message.ToObject<WebhookTextMessage>()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
private void OnTextMessaged(string agentId, WebhookMessage<WebhookTextMessage> message)
|
||||
{
|
||||
Console.WriteLine($"OnTextMessaged: {message.Message.Text}");
|
||||
|
||||
/*var ai = new ApiAi();
|
||||
var agent = ai.LoadAgent(agentId);
|
||||
ai.AiConfig = new AIConfiguration(agent.ClientAccessToken, SupportedLanguage.English) { AgentId = agentId };
|
||||
ai.AiConfig.SessionId = message.Sender.Id;
|
||||
var aiResponse = ai.TextRequest(new AIRequest { Query = new String[] { message.Message.Text } });
|
||||
|
||||
var dc = new DefaultDataContextLoader().GetDefaultDc();
|
||||
var config = dc.Table<AgentIntegration>().FirstOrDefault(x => x.AgentId == agentId && x.Platform == "Facebook Messenger");
|
||||
|
||||
SendTextMessage(config.AccessToken, new WebhookMessage<WebhookTextMessage>
|
||||
{
|
||||
Recipient = message.Sender.ToObject<WebhookMessageRecipient>(),
|
||||
Message = new WebhookTextMessage
|
||||
{
|
||||
Text = String.IsNullOrEmpty(aiResponse.Result.Fulfillment.Speech) ? aiResponse.Result.Action : aiResponse.Result.Fulfillment.Speech
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
private void SendTextMessage(string accessToken, WebhookMessage<WebhookTextMessage> body)
|
||||
{
|
||||
var client = new RestClient("https://graph.facebook.com");
|
||||
|
||||
var rest = new RestRequest("v2.6/me/messages", Method.Post);
|
||||
string json = JsonConvert.SerializeObject(body,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
|
||||
rest.AddParameter("application/json", json, ParameterType.RequestBody);
|
||||
rest.AddQueryParameter("access_token", accessToken);
|
||||
|
||||
var response = client.Execute(rest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Channel.FacebookMessenger
|
||||
{
|
||||
public interface IWebhookMessageBody
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Channel.FacebookMessenger.Models
|
||||
{
|
||||
public class WebhookEvent
|
||||
{
|
||||
public string Object { get; set; }
|
||||
public List<WebhookEventEntry> Entry { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Channel.FacebookMessenger.Models
|
||||
{
|
||||
public class WebhookEventEntry
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public long Time { get; set; }
|
||||
public List<WebhookMessage> Messaging { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Channel.FacebookMessenger.Models
|
||||
{
|
||||
public class WebhookMessage
|
||||
{
|
||||
public WebhookMessageSender Sender { get; set; }
|
||||
|
||||
public WebhookMessageRecipient Recipient { get; set; }
|
||||
|
||||
public long Timestamp { get; set; }
|
||||
|
||||
public JObject Message { get; set; }
|
||||
}
|
||||
|
||||
public class WebhookMessage<TWebhookMessage> where TWebhookMessage : IWebhookMessageBody
|
||||
{
|
||||
public WebhookMessageSender Sender { get; set; }
|
||||
|
||||
public WebhookMessageRecipient Recipient { get; set; }
|
||||
|
||||
public long Timestamp { get; set; }
|
||||
|
||||
public TWebhookMessage Message { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Channel.FacebookMessenger.Models
|
||||
{
|
||||
public class WebhookMessageQuickReply
|
||||
{
|
||||
public String Payload { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Channel.FacebookMessenger.Models
|
||||
{
|
||||
public class WebhookMessageRecipient
|
||||
{
|
||||
/// <summary>
|
||||
/// PAGE_ID
|
||||
/// </summary>
|
||||
public String Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Channel.FacebookMessenger.Models
|
||||
{
|
||||
public class WebhookMessageSender
|
||||
{
|
||||
/// <summary>
|
||||
/// PSID
|
||||
/// </summary>
|
||||
public String Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Channel.FacebookMessenger.Models
|
||||
{
|
||||
public class WebhookTextMessage : IWebhookMessageBody
|
||||
{
|
||||
public string Mid { get; set; }
|
||||
public String Text { get; set; }
|
||||
[JsonProperty("quick_reply")]
|
||||
public WebhookMessageQuickReply QuickReply { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
using BotSharp.Core.Modules;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace BotSharp.Channel.FacebookMessenger
|
||||
{
|
||||
public class ModuleInjector : IModule
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services, IConfiguration config)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env/*, IOptions<SenparcSetting> senparcSetting, IOptions<SenparcWeixinSetting> senparcWeixinSetting*/)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
@ -20,13 +20,11 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Senparc.Weixin.MP.MVC" Version="7.12.5.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Infrastructure\BotSharp.Core\BotSharp.Core.csproj" />
|
||||
<ProjectReference Include="..\..\Platforms\BotSharp.Platform.Dialogflow\BotSharp.Platform.Dialogflow.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,139 +0,0 @@
|
|||
using BotSharp.Channel.Weixin.Models;
|
||||
using BotSharp.Platform.Abstractions;
|
||||
using BotSharp.Platform.Dialogflow.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Senparc.CO2NET.AspNet.HttpUtility;
|
||||
using Senparc.CO2NET.HttpUtility;
|
||||
using Senparc.Weixin.AspNet.MvcExtension;
|
||||
using Senparc.Weixin.MP;
|
||||
using Senparc.Weixin.MP.Entities.Request;
|
||||
using Senparc.Weixin.MP.MvcExtension;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Channel.Weixin.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 此Controller为异步Controller(Action),使用异步线程处理并发请求。
|
||||
/// 为了方便演示,此Controller中没有加入多余的日志记录等示例,保持了最简单的Controller写法。日志等其他操作可以参考WeixinController.cs。
|
||||
/// 提示:异步Controller并不是在任何情况下都能提升效率(响应时间),当请求量非常小的时候反而会增加一定的开销。
|
||||
/// </summary>
|
||||
[Route("weixin")]
|
||||
public class WeixinAsyncController : ControllerBase
|
||||
{
|
||||
readonly Func<string> _getRandomFileName = () => DateTime.Now.ToString("yyyyMMdd-HHmmss") + "_Async_" + Guid.NewGuid().ToString("n").Substring(0, 6);
|
||||
|
||||
readonly IConfiguration config;
|
||||
private IPlatformBuilder<AgentModel> builder;
|
||||
|
||||
public WeixinAsyncController(IPlatformBuilder<AgentModel> platform, IConfiguration configuration)
|
||||
{
|
||||
config = configuration;
|
||||
builder = platform;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Task<ActionResult> Get(string signature, string timestamp, string nonce, string echostr)
|
||||
{
|
||||
var token = config.GetValue<string>("weixinChannel:token");
|
||||
return Task.Factory.StartNew(() =>
|
||||
{
|
||||
if (CheckSignature.Check(signature, timestamp, nonce, token))
|
||||
{
|
||||
return echostr; //返回随机字符串则表示验证通过
|
||||
}
|
||||
else
|
||||
{
|
||||
return "failed:" + signature + "," + Senparc.Weixin.MP.CheckSignature.GetSignature(timestamp, nonce, token) + "。" +
|
||||
"如果你在浏览器中看到这句话,说明此地址可以被作为微信公众账号后台的Url,请注意保持Token一致。";
|
||||
}
|
||||
}).ContinueWith<ActionResult>(task => Content(task.Result));
|
||||
}
|
||||
|
||||
public CustomMessageHandler MessageHandler = null;//开放出MessageHandler是为了做单元测试,实际使用过程中不需要
|
||||
|
||||
/// <summary>
|
||||
/// 最简化的处理流程
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> Post(PostModel postModel)
|
||||
{
|
||||
var token = config.GetValue<string>("weixinChannel:token");
|
||||
|
||||
if (!CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, token))
|
||||
{
|
||||
return new WeixinResult("参数错误!");
|
||||
}
|
||||
|
||||
postModel.Token = token;
|
||||
postModel.EncodingAESKey = config.GetValue<string>("weixinChannel:encodingAESKey");
|
||||
postModel.AppId = config.GetValue<string>("weixinChannel:appId");
|
||||
|
||||
var messageHandler = new CustomMessageHandler(builder, config, Request.GetRequestMemoryStream(), postModel, 10);
|
||||
|
||||
messageHandler.DefaultMessageHandlerAsyncEvent = Senparc.NeuChar.MessageHandlers.DefaultMessageHandlerAsyncEvent.SelfSynicMethod;//没有重写的异步方法将默认尝试调用同步方法中的代码(为了偷懒)
|
||||
|
||||
#region 设置消息去重
|
||||
|
||||
/* 如果需要添加消息去重功能,只需打开OmitRepeatedMessage功能,SDK会自动处理。
|
||||
* 收到重复消息通常是因为微信服务器没有及时收到响应,会持续发送2-5条不等的相同内容的RequestMessage*/
|
||||
messageHandler.OmitRepeatedMessage = true;//默认已经开启,此处仅作为演示,也可以设置为false在本次请求中停用此功能
|
||||
|
||||
#endregion
|
||||
|
||||
#region 记录 Request 日志
|
||||
|
||||
var logPath = Server.GetMapPath(string.Format("~/App_Data/MP/{0}/", DateTime.Now.ToString("yyyy-MM-dd")));
|
||||
if (!Directory.Exists(logPath))
|
||||
{
|
||||
Directory.CreateDirectory(logPath);
|
||||
}
|
||||
|
||||
//测试时可开启此记录,帮助跟踪数据,使用前请确保App_Data文件夹存在,且有读写权限。
|
||||
messageHandler.RequestDocument.Save(Path.Combine(logPath, string.Format("{0}_Request_{1}_{2}.txt", _getRandomFileName(),
|
||||
messageHandler.RequestMessage.FromUserName,
|
||||
messageHandler.RequestMessage.MsgType)));
|
||||
if (messageHandler.UsingEncryptMessage)
|
||||
{
|
||||
messageHandler.EcryptRequestDocument.Save(Path.Combine(logPath, string.Format("{0}_Request_Ecrypt_{1}_{2}.txt", _getRandomFileName(),
|
||||
messageHandler.RequestMessage.FromUserName,
|
||||
messageHandler.RequestMessage.MsgType)));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
await messageHandler.ExecuteAsync(new System.Threading.CancellationToken()); //执行微信处理过程
|
||||
|
||||
#region 记录 Response 日志
|
||||
|
||||
//测试时可开启,帮助跟踪数据
|
||||
|
||||
//if (messageHandler.ResponseDocument == null)
|
||||
//{
|
||||
// throw new Exception(messageHandler.RequestDocument.ToString());
|
||||
//}
|
||||
if (messageHandler.ResponseDocument != null)
|
||||
{
|
||||
messageHandler.ResponseDocument.Save(Path.Combine(logPath, string.Format("{0}_Response_{1}_{2}.txt", _getRandomFileName(),
|
||||
messageHandler.ResponseMessage.ToUserName,
|
||||
messageHandler.ResponseMessage.MsgType)));
|
||||
}
|
||||
|
||||
if (messageHandler.UsingEncryptMessage && messageHandler.FinalResponseDocument != null)
|
||||
{
|
||||
//记录加密后的响应信息
|
||||
messageHandler.FinalResponseDocument.Save(Path.Combine(logPath, string.Format("{0}_Response_Final_{1}_{2}.txt", _getRandomFileName(),
|
||||
messageHandler.ResponseMessage.ToUserName,
|
||||
messageHandler.ResponseMessage.MsgType)));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
MessageHandler = messageHandler;//开放出MessageHandler是为了做单元测试,实际使用过程中不需要
|
||||
|
||||
return new FixWeixinBugWeixinResult(messageHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
/*----------------------------------------------------------------
|
||||
Copyright (C) 2018 Senparc
|
||||
|
||||
文件名:LocationService.cs
|
||||
文件功能描述:地理位置信息处理
|
||||
|
||||
|
||||
创建标识:Senparc - 20150312
|
||||
----------------------------------------------------------------*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Senparc.Weixin.MP.Entities;
|
||||
using Senparc.CO2NET.Helpers.BaiduMap;
|
||||
using Senparc.CO2NET.Helpers.GoogleMap;
|
||||
using Senparc.Weixin.MP.Helpers;
|
||||
using Senparc.CO2NET.Helpers;
|
||||
using Senparc.NeuChar.Entities;
|
||||
|
||||
namespace BotSharp.Channel.Weixin
|
||||
{
|
||||
public class LocationService
|
||||
{
|
||||
public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage)
|
||||
{
|
||||
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageNews>(requestMessage);
|
||||
|
||||
#region 百度地图
|
||||
|
||||
{
|
||||
var markersList = new List<BaiduMarkers>();
|
||||
markersList.Add(new BaiduMarkers()
|
||||
{
|
||||
Longitude = requestMessage.Location_X,
|
||||
Latitude = requestMessage.Location_Y,
|
||||
Color = "red",
|
||||
Label = "S",
|
||||
Size = BaiduMarkerSize.m
|
||||
});
|
||||
|
||||
var mapUrl = BaiduMapHelper.GetBaiduStaticMap(requestMessage.Location_X, requestMessage.Location_Y, 1, 6, markersList);
|
||||
responseMessage.Articles.Add(new Article()
|
||||
{
|
||||
Description = string.Format("【来自百度地图】您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
|
||||
requestMessage.Location_X, requestMessage.Location_Y,
|
||||
requestMessage.Scale, requestMessage.Label),
|
||||
PicUrl = mapUrl,
|
||||
Title = "定位地点周边地图",
|
||||
Url = mapUrl
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GoogleMap
|
||||
|
||||
{
|
||||
var markersList = new List<GoogleMapMarkers>();
|
||||
markersList.Add(new GoogleMapMarkers()
|
||||
{
|
||||
X = requestMessage.Location_X,
|
||||
Y = requestMessage.Location_Y,
|
||||
Color = "red",
|
||||
Label = "S",
|
||||
Size = GoogleMapMarkerSize.Default,
|
||||
});
|
||||
var mapSize = "480x600";
|
||||
var mapUrl = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/,
|
||||
markersList, mapSize);
|
||||
responseMessage.Articles.Add(new Article()
|
||||
{
|
||||
Description = string.Format("【来自GoogleMap】您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
|
||||
requestMessage.Location_X, requestMessage.Location_Y,
|
||||
requestMessage.Scale, requestMessage.Label),
|
||||
PicUrl = mapUrl,
|
||||
Title = "定位地点周边地图",
|
||||
Url = mapUrl
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
responseMessage.Articles.Add(new Article()
|
||||
{
|
||||
Title = "微信公众平台SDK 官网链接",
|
||||
Description = "Senparc.Weixin.MK SDK地址",
|
||||
PicUrl = "http://sdk.weixin.senparc.com/images/logo.jpg",
|
||||
Url = "http://sdk.weixin.senparc.com"
|
||||
});
|
||||
|
||||
return responseMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
/*----------------------------------------------------------------
|
||||
Copyright (C) 2018 Senparc
|
||||
|
||||
文件名:CustomMessageContext.cs
|
||||
文件功能描述:微信消息上下文
|
||||
|
||||
|
||||
创建标识:Senparc - 20150312
|
||||
----------------------------------------------------------------*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using Senparc.NeuChar;
|
||||
using Senparc.NeuChar.Context;
|
||||
using Senparc.NeuChar.Entities;
|
||||
using Senparc.Weixin.MP.MessageContexts;
|
||||
|
||||
namespace BotSharp.Channel.Weixin.Models
|
||||
{
|
||||
public class CustomMessageContext : DefaultMpMessageContext
|
||||
{
|
||||
public CustomMessageContext()
|
||||
{
|
||||
base.MessageContextRemoved += CustomMessageContext_MessageContextRemoved;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当上下文过期,被移除时触发的时间
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void CustomMessageContext_MessageContextRemoved(object sender, Senparc.NeuChar.Context.WeixinContextRemovedEventArgs<IRequestMessageBase, IResponseMessageBase> e)
|
||||
{
|
||||
/* 注意,这个事件不是实时触发的(当然你也可以专门写一个线程监控)
|
||||
* 为了提高效率,根据WeixinContext中的算法,这里的过期消息会在过期后下一条请求执行之前被清除
|
||||
*/
|
||||
|
||||
var messageContext = e.MessageContext as CustomMessageContext;
|
||||
if (messageContext == null)
|
||||
{
|
||||
return;//如果是正常的调用,messageContext不会为null
|
||||
}
|
||||
|
||||
//TODO:这里根据需要执行消息过期时候的逻辑,下面的代码仅供参考
|
||||
|
||||
//Log.InfoFormat("{0}的消息上下文已过期",e.OpenId);
|
||||
//api.SendMessage(e.OpenId, "由于长时间未搭理客服,您的客服状态已退出!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,375 +0,0 @@
|
|||
/*----------------------------------------------------------------
|
||||
Copyright (C) 2018 Senparc
|
||||
|
||||
文件名:CustomMessageHandler.cs
|
||||
文件功能描述:微信公众号自定义MessageHandler
|
||||
|
||||
|
||||
创建标识:Senparc - 20150312
|
||||
|
||||
修改标识:Senparc - 20171027
|
||||
修改描述:v14.8.3 添加OnUnknownTypeRequest()方法Demo
|
||||
|
||||
----------------------------------------------------------------*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
using Senparc.Weixin.MP.Entities;
|
||||
using Senparc.Weixin.MP.Entities.Request;
|
||||
using Senparc.Weixin.MP.MessageHandlers;
|
||||
using Senparc.Weixin.MP.AdvancedAPIs;
|
||||
using System.Threading.Tasks;
|
||||
using Senparc.NeuChar.Entities.Request;
|
||||
using Senparc.NeuChar.Helpers;
|
||||
using Senparc.NeuChar.Entities;
|
||||
using Senparc.Weixin;
|
||||
using Senparc.Weixin.MP;
|
||||
using BotSharp.Platform.Models.AiRequest;
|
||||
using BotSharp.Platform.Abstractions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using BotSharp.Platform.Dialogflow.Models;
|
||||
|
||||
#if NET45
|
||||
using System.Web;
|
||||
using System.Configuration;
|
||||
using System.Web.Configuration;
|
||||
using Senparc.Weixin.MP.Sample.CommonService.Utilities;
|
||||
#else
|
||||
using Microsoft.AspNetCore.Http;
|
||||
#endif
|
||||
|
||||
namespace BotSharp.Channel.Weixin.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义MessageHandler
|
||||
/// 把MessageHandler作为基类,重写对应请求的处理方法
|
||||
/// </summary>
|
||||
public partial class CustomMessageHandler : MessageHandler<CustomMessageContext>
|
||||
{
|
||||
/*
|
||||
* 重要提示:v1.5起,MessageHandler提供了一个DefaultResponseMessage的抽象方法,
|
||||
* DefaultResponseMessage必须在子类中重写,用于返回没有处理过的消息类型(也可以用于默认消息,如帮助信息等);
|
||||
* 其中所有原OnXX的抽象方法已经都改为虚方法,可以不必每个都重写。若不重写,默认返回DefaultResponseMessage方法中的结果。
|
||||
*/
|
||||
|
||||
|
||||
#if !DEBUG || NETSTANDARD1_6 || NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1
|
||||
string agentUrl = "http://localhost:12222/App/Weixin/4";
|
||||
string agentToken = "27C455F496044A87";
|
||||
string wiweihiKey = "CNadjJuWzyX5bz5Gn+/XoyqiqMa5DjXQ";
|
||||
#else
|
||||
//下面的Url和Token可以用其他平台的消息,或者到www.weiweihi.com注册微信用户,将自动在“微信营销工具”下得到
|
||||
private string agentUrl = Config.SenparcWeixinSetting.AgentUrl;//这里使用了www.weiweihi.com微信自动托管平台
|
||||
private string agentToken = Config.SenparcWeixinSetting.AgentToken;//Token
|
||||
private string wiweihiKey = Config.SenparcWeixinSetting.SenparcWechatAgentKey;//WeiweihiKey专门用于对接www.Weiweihi.com平台,获取方式见:http://www.weiweihi.com/ApiDocuments/Item/25#51
|
||||
#endif
|
||||
|
||||
#if NET45
|
||||
private string appId = Config.SenparcWeixinSetting.WeixinAppId;
|
||||
private string appSecret = Config.SenparcWeixinSetting.WeixinAppSecret;
|
||||
#else
|
||||
private string appId = "appId";
|
||||
private string appSecret = "appSecret";
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 模板消息集合(Key:checkCode,Value:OpenId)
|
||||
/// </summary>
|
||||
public static Dictionary<string, string> TemplateMessageCollection = new Dictionary<string, string>();
|
||||
|
||||
private IPlatformBuilder<AgentModel> nluPlatform = null;
|
||||
private readonly IConfiguration config;
|
||||
|
||||
public CustomMessageHandler(IPlatformBuilder<AgentModel> nluPlatform, IConfiguration configuration, Stream inputStream, PostModel postModel, int maxRecordCount = 0)
|
||||
: base(inputStream, postModel, maxRecordCount)
|
||||
{
|
||||
this.nluPlatform = nluPlatform;
|
||||
this.config = configuration;
|
||||
|
||||
//这里设置仅用于测试,实际开发可以在外部更全局的地方设置,
|
||||
//比如MessageHandler<MessageContext>.GlobalGlobalMessageContext.ExpireMinutes = 3。
|
||||
GlobalMessageContext.ExpireMinutes = 3;
|
||||
|
||||
if (!string.IsNullOrEmpty(postModel.AppId))
|
||||
{
|
||||
appId = postModel.AppId;//通过第三方开放平台发送过来的请求
|
||||
}
|
||||
|
||||
//在指定条件下,不使用消息去重
|
||||
base.OmitRepeatedMessageFunc = requestMessage =>
|
||||
{
|
||||
var textRequestMessage = requestMessage as RequestMessageText;
|
||||
if (textRequestMessage != null && textRequestMessage.Content == "容错")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
public override async Task OnExecutingAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var CurrentMessageContext = await GetCurrentMessageContext();
|
||||
//测试MessageContext.StorageData
|
||||
if (CurrentMessageContext.StorageData == null)
|
||||
{
|
||||
CurrentMessageContext.StorageData = 0;
|
||||
}
|
||||
await base.OnExecutingAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public override async Task OnExecutedAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var CurrentMessageContext = await GetCurrentMessageContext();
|
||||
CurrentMessageContext.StorageData = ((int)CurrentMessageContext.StorageData) + 1;
|
||||
await base.OnExecutedAsync(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理文字请求
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override IResponseMessageBase OnTextRequest(RequestMessageText requestMessage)
|
||||
{
|
||||
var defaultResponseMessage = base.CreateResponseMessage<ResponseMessageText>();
|
||||
|
||||
var requestHandler =
|
||||
requestMessage.StartHandler()
|
||||
.Keyword("BotSharp",() =>
|
||||
{
|
||||
var result = new StringBuilder();
|
||||
result.AppendFormat("{0}", "你好!欢迎使用BotSharp NLU服务,BotSharp通过强大的自然语言理解技术让你更轻松的处理智能回复。");
|
||||
defaultResponseMessage.Content = result.ToString();
|
||||
return defaultResponseMessage;
|
||||
})
|
||||
.Keyword("再见", () =>
|
||||
{
|
||||
var result = new StringBuilder();
|
||||
result.AppendFormat("{0}", "谢谢使用,再见!");
|
||||
defaultResponseMessage.Content = result.ToString();
|
||||
return defaultResponseMessage;
|
||||
})
|
||||
.Default(() =>
|
||||
{
|
||||
var result = new StringBuilder();
|
||||
|
||||
// send text to BotSharp platform emulator
|
||||
var aIResponse = nluPlatform.TextRequest<AIResponseResult>(new AiRequest
|
||||
{
|
||||
Text = requestMessage.Content,
|
||||
AgentId = config.GetValue<string>("weixinChannel:agentId"),
|
||||
SessionId = requestMessage.FromUserName
|
||||
});
|
||||
|
||||
result.AppendFormat("{0}", aIResponse.Result.Fulfillment.Speech);
|
||||
|
||||
defaultResponseMessage.Content = result.ToString();
|
||||
return defaultResponseMessage;
|
||||
});
|
||||
|
||||
return requestHandler.GetResponseMessage() as IResponseMessageBase;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理位置请求
|
||||
/// </summary>
|
||||
/// <param name="requestMessage"></param>
|
||||
/// <returns></returns>
|
||||
public override IResponseMessageBase OnLocationRequest(RequestMessageLocation requestMessage)
|
||||
{
|
||||
var locationService = new LocationService();
|
||||
var responseMessage = locationService.GetResponseMessage(requestMessage as RequestMessageLocation);
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
public override IResponseMessageBase OnShortVideoRequest(RequestMessageShortVideo requestMessage)
|
||||
{
|
||||
var responseMessage = this.CreateResponseMessage<ResponseMessageText>();
|
||||
responseMessage.Content = "您刚才发送的是小视频";
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理图片请求
|
||||
/// </summary>
|
||||
/// <param name="requestMessage"></param>
|
||||
/// <returns></returns>
|
||||
public override IResponseMessageBase OnImageRequest(RequestMessageImage requestMessage)
|
||||
{
|
||||
//一隔一返回News或Image格式
|
||||
if (base.GlobalMessageContext.GetMessageContext(requestMessage).RequestMessages.Count() % 2 == 0)
|
||||
{
|
||||
var responseMessage = CreateResponseMessage<ResponseMessageNews>();
|
||||
|
||||
responseMessage.Articles.Add(new Article()
|
||||
{
|
||||
Title = "您刚才发送了图片信息",
|
||||
Description = "您发送的图片将会显示在边上",
|
||||
PicUrl = requestMessage.PicUrl,
|
||||
Url = "http://sdk.weixin.senparc.com"
|
||||
});
|
||||
responseMessage.Articles.Add(new Article()
|
||||
{
|
||||
Title = "第二条",
|
||||
Description = "第二条带连接的内容",
|
||||
PicUrl = requestMessage.PicUrl,
|
||||
Url = "http://sdk.weixin.senparc.com"
|
||||
});
|
||||
|
||||
return responseMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
var responseMessage = CreateResponseMessage<ResponseMessageImage>();
|
||||
responseMessage.Image.MediaId = requestMessage.MediaId;
|
||||
return responseMessage;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理语音请求
|
||||
/// </summary>
|
||||
/// <param name="requestMessage"></param>
|
||||
/// <returns></returns>
|
||||
public override IResponseMessageBase OnVoiceRequest(RequestMessageVoice requestMessage)
|
||||
{
|
||||
var responseMessage = CreateResponseMessage<ResponseMessageMusic>();
|
||||
//上传缩略图
|
||||
//var accessToken = Containers.AccessTokenContainer.TryGetAccessToken(appId, appSecret);
|
||||
var uploadResult = Senparc.Weixin.MP.AdvancedAPIs.MediaApi.UploadTemporaryMedia(appId, UploadMediaFileType.image,
|
||||
Server.GetMapPath("~/Images/Logo.jpg"));
|
||||
|
||||
//设置音乐信息
|
||||
responseMessage.Music.Title = "天籁之音";
|
||||
responseMessage.Music.Description = "播放您上传的语音";
|
||||
responseMessage.Music.MusicUrl = "http://sdk.weixin.senparc.com/Media/GetVoice?mediaId=" + requestMessage.MediaId;
|
||||
responseMessage.Music.HQMusicUrl = "http://sdk.weixin.senparc.com/Media/GetVoice?mediaId=" + requestMessage.MediaId;
|
||||
responseMessage.Music.ThumbMediaId = uploadResult.media_id;
|
||||
|
||||
//推送一条客服消息
|
||||
try
|
||||
{
|
||||
CustomApi.SendText(appId, WeixinOpenId, "本次上传的音频MediaId:" + requestMessage.MediaId);
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return responseMessage;
|
||||
}
|
||||
/// <summary>
|
||||
/// 处理视频请求
|
||||
/// </summary>
|
||||
/// <param name="requestMessage"></param>
|
||||
/// <returns></returns>
|
||||
public override IResponseMessageBase OnVideoRequest(RequestMessageVideo requestMessage)
|
||||
{
|
||||
var responseMessage = CreateResponseMessage<ResponseMessageText>();
|
||||
responseMessage.Content = "您发送了一条视频信息,ID:" + requestMessage.MediaId;
|
||||
|
||||
#region 上传素材并推送到客户端
|
||||
|
||||
Task.Factory.StartNew(async () =>
|
||||
{
|
||||
//上传素材
|
||||
var dir = Server.GetMapPath("~/App_Data/TempVideo/");
|
||||
var file = await MediaApi.GetAsync(appId, requestMessage.MediaId, dir);
|
||||
var uploadResult = await MediaApi.UploadTemporaryMediaAsync(appId, UploadMediaFileType.video, file, 50000);
|
||||
await CustomApi.SendVideoAsync(appId, base.WeixinOpenId, uploadResult.media_id, "这是您刚才发送的视频", "这是一条视频消息");
|
||||
}).ContinueWith(async task =>
|
||||
{
|
||||
if (task.Exception != null)
|
||||
{
|
||||
WeixinTrace.Log("OnVideoRequest()储存Video过程发生错误:", task.Exception.Message);
|
||||
|
||||
var msg = string.Format("上传素材出错:{0}\r\n{1}",
|
||||
task.Exception.Message,
|
||||
task.Exception.InnerException != null
|
||||
? task.Exception.InnerException.Message
|
||||
: null);
|
||||
await CustomApi.SendTextAsync(appId, base.WeixinOpenId, msg);
|
||||
}
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 处理链接消息请求
|
||||
/// </summary>
|
||||
/// <param name="requestMessage"></param>
|
||||
/// <returns></returns>
|
||||
public override IResponseMessageBase OnLinkRequest(RequestMessageLink requestMessage)
|
||||
{
|
||||
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageText>(requestMessage);
|
||||
responseMessage.Content = string.Format(@"您发送了一条连接信息:
|
||||
Title:{0}
|
||||
Description:{1}
|
||||
Url:{2}", requestMessage.Title, requestMessage.Description, requestMessage.Url);
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
public override IResponseMessageBase OnFileRequest(RequestMessageFile requestMessage)
|
||||
{
|
||||
var responseMessage = requestMessage.CreateResponseMessage<ResponseMessageText>();
|
||||
responseMessage.Content = string.Format(@"您发送了一个文件:
|
||||
文件名:{0}
|
||||
说明:{1}
|
||||
大小:{2}
|
||||
MD5:{3}", requestMessage.Title, requestMessage.Description, requestMessage.FileTotalLen, requestMessage.FileMd5);
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理事件请求(这个方法一般不用重写,这里仅作为示例出现。除非需要在判断具体Event类型以外对Event信息进行统一操作
|
||||
/// </summary>
|
||||
/// <param name="requestMessage"></param>
|
||||
/// <returns></returns>
|
||||
public override IResponseMessageBase OnEventRequest(IRequestMessageEventBase requestMessage)
|
||||
{
|
||||
var eventResponseMessage = base.OnEventRequest(requestMessage);//对于Event下属分类的重写方法,见:CustomerMessageHandler_Events.cs
|
||||
//TODO: 对Event信息进行统一操作
|
||||
return eventResponseMessage;
|
||||
}
|
||||
|
||||
public override IResponseMessageBase DefaultResponseMessage(IRequestMessageBase requestMessage)
|
||||
{
|
||||
/* 所有没有被处理的消息会默认返回这里的结果,
|
||||
* 因此,如果想把整个微信请求委托出去(例如需要使用分布式或从其他服务器获取请求),
|
||||
* 只需要在这里统一发出委托请求,如:
|
||||
* var responseMessage = MessageAgent.RequestResponseMessage(agentUrl, agentToken, RequestDocument.ToString());
|
||||
* return responseMessage;
|
||||
*/
|
||||
|
||||
var responseMessage = this.CreateResponseMessage<ResponseMessageText>();
|
||||
responseMessage.Content = "这条消息来自DefaultResponseMessage。";
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
|
||||
public override IResponseMessageBase OnUnknownTypeRequest(RequestMessageUnknownType requestMessage)
|
||||
{
|
||||
/*
|
||||
* 此方法用于应急处理SDK没有提供的消息类型,
|
||||
* 原始XML可以通过requestMessage.RequestDocument(或this.RequestDocument)获取到。
|
||||
* 如果不重写此方法,遇到未知的请求类型将会抛出异常(v14.8.3 之前的版本就是这么做的)
|
||||
*/
|
||||
var msgType = Senparc.NeuChar.Helpers.MsgTypeHelper.GetRequestMsgTypeString(requestMessage.RequestDocument);
|
||||
var responseMessage = this.CreateResponseMessage<ResponseMessageText>();
|
||||
responseMessage.Content = "未知消息类型:" + msgType;
|
||||
|
||||
WeixinTrace.SendCustomLog("未知请求消息类型", requestMessage.RequestDocument.ToString());//记录到日志中
|
||||
|
||||
return responseMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
using BotSharp.Core.Modules;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Senparc.CO2NET.RegisterServices;
|
||||
using Senparc.Weixin.RegisterServices;
|
||||
|
||||
namespace BotSharp.Channel.Weixin
|
||||
{
|
||||
public class ModuleInjector : IModule
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services, IConfiguration config)
|
||||
{
|
||||
// Senparc.CO2NET, Senparc.Weixin
|
||||
services.AddSenparcGlobalServices(config)
|
||||
.AddSenparcWeixinServices(config);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env/*, IOptions<SenparcSetting> senparcSetting, IOptions<SenparcWeixinSetting> senparcWeixinSetting*/)
|
||||
{
|
||||
|
||||
//https://github.com/Senparc/Senparc.CO2NET/blob/master/Sample/Senparc.CO2NET.Sample.netcore/Startup.cs
|
||||
/* IRegisterService register = RegisterService.Start(env, senparcSetting.Value)
|
||||
.UseSenparcGlobal();*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
#if NET45
|
||||
using System.Web;
|
||||
#else
|
||||
using Microsoft.AspNetCore.Http;
|
||||
#endif
|
||||
|
||||
namespace BotSharp.Channel.Weixin
|
||||
{
|
||||
public static class Server
|
||||
{
|
||||
private static string _appDomainAppPath;
|
||||
public static string AppDomainAppPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_appDomainAppPath == null)
|
||||
{
|
||||
#if NET45
|
||||
_appDomainAppPath = HttpRuntime.AppDomainAppPath;
|
||||
#else
|
||||
_appDomainAppPath = AppContext.BaseDirectory; //dll所在目录:;
|
||||
#endif
|
||||
}
|
||||
return _appDomainAppPath;
|
||||
}
|
||||
set
|
||||
{
|
||||
_appDomainAppPath = value;
|
||||
#if NETSTANDARD1_6 || NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1
|
||||
if (!_appDomainAppPath.EndsWith("/"))
|
||||
{
|
||||
_appDomainAppPath += "/";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private static string _webRootPath;
|
||||
/// <summary>
|
||||
/// wwwroot文件夹目录(专供ASP.NET Core MVC使用)
|
||||
/// </summary>
|
||||
public static string WebRootPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_webRootPath == null)
|
||||
{
|
||||
#if NET45
|
||||
_webRootPath = AppDomainAppPath;
|
||||
#else
|
||||
_webRootPath = AppDomainAppPath + "wwwroot/";//asp.net core的wwwroot文件目录结构不一样
|
||||
#endif
|
||||
}
|
||||
return _webRootPath;
|
||||
}
|
||||
set { _webRootPath = value; }
|
||||
}
|
||||
|
||||
public static string GetMapPath(string virtualPath)
|
||||
{
|
||||
if (virtualPath == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else if (virtualPath.StartsWith("~/"))
|
||||
{
|
||||
return virtualPath.Replace("~/", AppDomainAppPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Path.Combine(AppDomainAppPath, virtualPath);
|
||||
}
|
||||
}
|
||||
|
||||
public static HttpContext HttpContext
|
||||
{
|
||||
get
|
||||
{
|
||||
#if NET45
|
||||
HttpContext context = HttpContext.Current;
|
||||
if (context == null)
|
||||
{
|
||||
HttpRequest request = new HttpRequest("Default.aspx", "http://sdk.weixin.senparc.com/default.aspx", null);
|
||||
StringWriter sw = new StringWriter();
|
||||
HttpResponse response = new HttpResponse(sw);
|
||||
context = new HttpContext(request, response);
|
||||
}
|
||||
#else
|
||||
HttpContext context = new DefaultHttpContext();
|
||||
#endif
|
||||
return context;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<DefaultTargetFramework>netcoreapp3.1</DefaultTargetFramework>
|
||||
<MvcVersion>3.1.7</MvcVersion>
|
||||
<Version Condition="$(Version) == ''">0.2.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Abstraction.Enums;
|
||||
|
||||
public enum LlmResponseExtractType
|
||||
{
|
||||
Text = 1,
|
||||
Html = 2,
|
||||
Json = 3
|
||||
}
|
||||
16
Infrastructure/BotSharp.Abstraction/ILlmAgent.cs
Normal file
16
Infrastructure/BotSharp.Abstraction/ILlmAgent.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using Abstraction.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Abstraction;
|
||||
|
||||
public interface ILlmAgent : IDisposable
|
||||
{
|
||||
bool LoggedIn { get; }
|
||||
Task OpenDriver();
|
||||
Task Login();
|
||||
LlmResponse NewSession(LlmPromptInput prompt);
|
||||
LlmResponse Interact(LlmPromptInput input, bool isAsync);
|
||||
}
|
||||
34
Infrastructure/BotSharp.Abstraction/Models/LlmPromptInput.cs
Normal file
34
Infrastructure/BotSharp.Abstraction/Models/LlmPromptInput.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using Abstraction.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Abstraction.Models;
|
||||
|
||||
public class LlmPromptInput
|
||||
{
|
||||
public string Model { get; set; } = string.Empty;
|
||||
public LlmResponseExtractType Format { get; set; }
|
||||
public string SessionId { get; set; } = string.Empty;
|
||||
public List<string> Prompts { get; set; } = new List<string>();
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
var value = SessionId + "-" + string.Join(" | ", Prompts);
|
||||
return Md5(value).GetHashCode();
|
||||
}
|
||||
|
||||
private string Md5(string input)
|
||||
{
|
||||
using var md5 = MD5.Create();
|
||||
var byteHash = md5.ComputeHash(Encoding.UTF8.GetBytes(input.ToLower()));
|
||||
return BitConverter.ToString(byteHash).Replace("-", "").ToLower();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{SessionId}: {Prompts.FirstOrDefault()}";
|
||||
}
|
||||
}
|
||||
12
Infrastructure/BotSharp.Abstraction/Models/LlmResponse.cs
Normal file
12
Infrastructure/BotSharp.Abstraction/Models/LlmResponse.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using Abstraction.Enums;
|
||||
|
||||
namespace Abstraction.Models;
|
||||
|
||||
public class LlmResponse
|
||||
{
|
||||
public string Model { get; set; } = string.Empty;
|
||||
public LlmResponseExtractType Format { get; set; }
|
||||
public string SessionId { get; set; } = string.Empty;
|
||||
public string Content { get; set; } = string.Empty;
|
||||
public bool Success { get; set; }
|
||||
}
|
||||
12
Infrastructure/BotSharp.Abstraction/Models/OpenAiSettings.cs
Normal file
12
Infrastructure/BotSharp.Abstraction/Models/OpenAiSettings.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Abstraction.Models;
|
||||
|
||||
public class OpenAiSettings
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool IsGoogleAccount { get; set; }
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
using BotSharp.Platform.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Platform.Abstractions
|
||||
{
|
||||
public interface IAgentImporter<TAgent>
|
||||
{
|
||||
/// <summary>
|
||||
/// data dir
|
||||
/// </summary>
|
||||
string AgentDir { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Load agent summary
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<TAgent> LoadAgent(AgentImportHeader agentHeader);
|
||||
|
||||
/// <summary>
|
||||
/// Load user customized entity type which defined in dictionary
|
||||
/// </summary>
|
||||
/// <param name="agent"></param>
|
||||
Task LoadCustomEntities(TAgent agent);
|
||||
|
||||
/// <summary>
|
||||
/// Load user customized intents
|
||||
/// </summary>
|
||||
/// <param name="agent"></param>
|
||||
Task LoadIntents(TAgent agent);
|
||||
|
||||
/// <summary>
|
||||
/// Add entities that labeled in intent.UserSays into user customized entity dictionary
|
||||
/// </summary>
|
||||
/// <param name="agent"></param>
|
||||
Task LoadBuildinEntities(TAgent agent);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
using BotSharp.Platform.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Platform.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// Agent could be persisted in any kind of storage.
|
||||
/// Example: local file storage, cloud storage, relational database, key-value database or memory
|
||||
/// </summary>
|
||||
public interface IAgentStorage<TAgent>
|
||||
{
|
||||
/// <summary>
|
||||
/// Save agent instance
|
||||
/// </summary>
|
||||
/// <param name="agent"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Persist(TAgent agent);
|
||||
|
||||
/// <summary>
|
||||
/// Get agent by id
|
||||
/// </summary>
|
||||
/// <param name="agentId"></param>
|
||||
/// <returns></returns>
|
||||
Task<TAgent> FetchById(string agentId);
|
||||
|
||||
/// <summary>
|
||||
/// Get agent by name
|
||||
/// </summary>
|
||||
/// <param name="agentName"></param>
|
||||
/// <returns></returns>
|
||||
Task<TAgent> FetchByName(string agentName);
|
||||
|
||||
/// <summary>
|
||||
/// Query agents
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<TAgent>> Query();
|
||||
|
||||
/// <summary>
|
||||
/// Delete agents
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<int> PurgeAllAgents();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using BotSharp.Platform.Models;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Platform.Abstractions
|
||||
{
|
||||
public interface IAgentStorageFactory<TAgent> where TAgent : AgentBase
|
||||
{
|
||||
IAgentStorage<TAgent> Get();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
using BotSharp.Platform.Models;
|
||||
using BotSharp.Platform.Models.AiRequest;
|
||||
using BotSharp.Platform.Models.AiResponse;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Platform.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// BotEngine is the NLU of bot platform
|
||||
/// </summary>
|
||||
public interface IBotEngine
|
||||
{
|
||||
Task<AiResponse> TextRequest(AiRequest request);
|
||||
|
||||
Task Train(BotTrainOptions options);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Platform.Abstractions
|
||||
{
|
||||
public interface IContextStorage<T>
|
||||
{
|
||||
Task<bool> Persist(string sessionId, T[] context);
|
||||
Task<T[]> Fetch(string sessionId);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Platform.Abstractions
|
||||
{
|
||||
public interface IContextStorageFactory<T>
|
||||
{
|
||||
IContextStorage<T> Get();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
using EntityFrameworkCore.BootKit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Core.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize data for modules
|
||||
/// </summary>
|
||||
public interface IHookDbInitializer
|
||||
{
|
||||
/// <summary>
|
||||
/// value smaller is higher priority
|
||||
/// </summary>
|
||||
int Priority { get; }
|
||||
void Load(Database dc);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Core.Abstractions
|
||||
{
|
||||
public interface IInitializationLoader
|
||||
{
|
||||
int Priority { get; }
|
||||
void Initialize(IConfiguration config, IWebHostEnvironment env);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
using BotSharp.Core.Engines;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Core.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// NLP process pipeline interface
|
||||
/// </summary>
|
||||
public interface INlpPipeline
|
||||
{
|
||||
IConfiguration Configuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Common settings for Pipeline
|
||||
/// </summary>
|
||||
PipeSettings Settings { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
using BotSharp.Core.Engines;
|
||||
using BotSharp.Platform.Models;
|
||||
using BotSharp.Platform.Models.MachineLearning;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Core.Abstractions
|
||||
{
|
||||
public interface INlpPredict : INlpPipeline
|
||||
{
|
||||
Task<bool> Predict(AgentBase agent, NlpDoc doc, PipeModel meta);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
using BotSharp.Core.Engines;
|
||||
using BotSharp.Platform.Models;
|
||||
using BotSharp.Platform.Models.MachineLearning;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Core.Abstractions
|
||||
{
|
||||
public interface INlpProvider : INlpPipeline
|
||||
{
|
||||
Task<bool> Load(AgentBase agent, PipeModel meta);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
using BotSharp.Core.Engines;
|
||||
using BotSharp.Platform.Models;
|
||||
using BotSharp.Platform.Models.MachineLearning;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Core.Abstractions
|
||||
{
|
||||
public interface INlpTrain : INlpPipeline
|
||||
{
|
||||
/// <summary>
|
||||
/// Process
|
||||
/// </summary>
|
||||
/// <param name="agent"></param>
|
||||
/// <param name="doc">Intermediate result</param>
|
||||
/// <param name="meta">Meta data which is packed to model</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Train(AgentBase agent, NlpDoc doc, PipeModel meta);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
using BotSharp.Platform.Models;
|
||||
using BotSharp.Platform.Models.AiRequest;
|
||||
using BotSharp.Platform.Models.AiResponse;
|
||||
using BotSharp.Platform.Models.MachineLearning;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Platform.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// Platform abstraction
|
||||
/// Implement this interface to build a Chatbot platform
|
||||
/// </summary>
|
||||
public interface IPlatformBuilder<TAgent>
|
||||
{
|
||||
TAgent Agent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Agent storage
|
||||
/// </summary>
|
||||
IAgentStorage<TAgent> Storage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Parse options for the incoming text or voice request from the sender.
|
||||
/// </summary>
|
||||
// DialogRequestOptions RequestOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Convert platform specific data to standard training corpus format
|
||||
/// </summary>
|
||||
/// <param name="agent"></param>
|
||||
/// <returns></returns>
|
||||
Task<TrainingCorpus> ExtractorCorpus(TAgent agent);
|
||||
|
||||
/// <summary>
|
||||
/// Load agent from files.
|
||||
/// There must contain a meta.json
|
||||
/// </summary>
|
||||
/// <param name="dataDir"></param>
|
||||
/// <returns></returns>
|
||||
Task<TAgent> LoadAgentFromFile<TImporter>(string dataDir) where TImporter : IAgentImporter<TAgent>, new();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="TStorage"></typeparam>
|
||||
/// <param name="agent"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> SaveAgent(TAgent agent);
|
||||
|
||||
Task<ModelMetaData> Train(TAgent agent, TrainingCorpus corpus, BotTrainOptions options);
|
||||
|
||||
Task<TResult> TextRequest<TResult>(AiRequest request);
|
||||
|
||||
Task<TResult> AssembleResult<TResult>(AiRequest request, AiResponse response);
|
||||
|
||||
Task<TextClassificationResult> FallbackResponse(AiRequest request);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Platform.Abstractions
|
||||
{
|
||||
public interface IPlatformSettings
|
||||
{
|
||||
string BotEngine { get; set; }
|
||||
|
||||
string AgentStorage { get; set; }
|
||||
|
||||
string ContextStorage { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
using BotSharp.Platform.Abstractions;
|
||||
using BotSharp.Platform.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Core.AgentStorage
|
||||
{
|
||||
public class AgentStorageFactory<TAgent> : IAgentStorageFactory<TAgent> where TAgent : AgentBase
|
||||
{
|
||||
private readonly Func<string, IAgentStorage<TAgent>> func;
|
||||
private readonly IPlatformSettings platformSetting;
|
||||
|
||||
public AgentStorageFactory(IPlatformSettings setting, Func<string, IAgentStorage<TAgent>> serviceAccessor)
|
||||
{
|
||||
this.func = serviceAccessor;
|
||||
this.platformSetting = setting;
|
||||
}
|
||||
|
||||
public IAgentStorage<TAgent> Get()
|
||||
{
|
||||
IAgentStorage<TAgent> storage = null;
|
||||
string storageName = this.platformSetting.AgentStorage;
|
||||
storage = func(storageName);
|
||||
return storage as IAgentStorage<TAgent>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
using BotSharp.Platform.Abstractions;
|
||||
using BotSharp.Platform.Models;
|
||||
using CSRedis;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Core.AgentStorage
|
||||
{
|
||||
public class AgentStorageInFile<TAgent> : IAgentStorage<TAgent>
|
||||
where TAgent : AgentBase
|
||||
{
|
||||
private static string storageDir;
|
||||
|
||||
public AgentStorageInFile()
|
||||
{
|
||||
IConfiguration config = (IConfiguration)AppDomain.CurrentDomain.GetData("Configuration");
|
||||
var db = config.GetSection("Database:Default").Value;
|
||||
storageDir = config.GetSection($"Database:ConnectionStrings:{db}").Value;
|
||||
string contentDir = AppDomain.CurrentDomain.GetData("DataPath").ToString();
|
||||
storageDir = storageDir.Replace("|DataDirectory|", contentDir + Path.DirectorySeparatorChar + "AgentStorage" + Path.DirectorySeparatorChar);
|
||||
|
||||
if (!Directory.Exists(storageDir))
|
||||
{
|
||||
Directory.CreateDirectory(storageDir);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<TAgent> FetchById(string agentId)
|
||||
{
|
||||
string dataPath = Path.Combine(storageDir, agentId + ".json");
|
||||
if (File.Exists(dataPath))
|
||||
{
|
||||
string json = File.ReadAllText(dataPath);
|
||||
return JsonConvert.DeserializeObject<TAgent>(json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return default(TAgent);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<TAgent> FetchByName(string agentName)
|
||||
{
|
||||
var files = Directory.GetFiles(storageDir);
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
var file = files[i];
|
||||
string json = File.ReadAllText(file);
|
||||
var agent = JsonConvert.DeserializeObject<TAgent>(json);
|
||||
if (agent.Name.ToLower() == agentName.ToLower())
|
||||
{
|
||||
return agent;
|
||||
}
|
||||
}
|
||||
|
||||
return default(TAgent);
|
||||
}
|
||||
|
||||
public async Task<bool> Persist(TAgent agent)
|
||||
{
|
||||
if (String.IsNullOrEmpty(agent.Id))
|
||||
{
|
||||
agent.Id = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
var json = JsonConvert.SerializeObject(agent, new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
Formatting = Formatting.Indented,
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
Converters = new List<JsonConverter>
|
||||
{
|
||||
new Newtonsoft.Json.Converters.StringEnumConverter()
|
||||
}
|
||||
});
|
||||
|
||||
string dataPath = Path.Combine(storageDir, agent.Id + ".json");
|
||||
|
||||
File.WriteAllText(dataPath, json);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<int> PurgeAllAgents()
|
||||
{
|
||||
var files = Directory.GetFiles(storageDir);
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
File.Delete(files[i]);
|
||||
}
|
||||
|
||||
return files.Length;
|
||||
}
|
||||
|
||||
public async Task<List<TAgent>> Query()
|
||||
{
|
||||
var agents = new List<TAgent>();
|
||||
|
||||
var files = Directory.GetFiles(storageDir);
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
var file = files[i];
|
||||
string json = File.ReadAllText(file);
|
||||
var agent = JsonConvert.DeserializeObject<TAgent>(json);
|
||||
agents.Add(agent);
|
||||
}
|
||||
|
||||
return agents;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
using BotSharp.Platform.Abstractions;
|
||||
using BotSharp.Platform.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Core.AgentStorage
|
||||
{
|
||||
/// <summary>
|
||||
/// Save agent instance into memory.
|
||||
/// Caution: Data will be lost once application restarts.
|
||||
/// </summary>
|
||||
public class AgentStorageInMemory<TAgent> : IAgentStorage<TAgent> where TAgent : AgentBase
|
||||
{
|
||||
private static Dictionary<string, TAgent> agents;
|
||||
|
||||
public AgentStorageInMemory()
|
||||
{
|
||||
if (agents == null) agents = new Dictionary<string, TAgent>();
|
||||
}
|
||||
|
||||
public async Task<TAgent> FetchById(string agentId)
|
||||
{
|
||||
if (agents.ContainsKey(agentId))
|
||||
{
|
||||
return agents[agentId];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<TAgent> FetchByName(string agentName)
|
||||
{
|
||||
var data = agents.FirstOrDefault(x => x.Value.Name == agentName);
|
||||
|
||||
return data.Value;
|
||||
}
|
||||
|
||||
public async Task<bool> Persist(TAgent agent)
|
||||
{
|
||||
if (String.IsNullOrEmpty(agent.Id))
|
||||
{
|
||||
agent.Id = Guid.NewGuid().ToString();
|
||||
agents[agent.Id] = agent;
|
||||
}
|
||||
else
|
||||
{
|
||||
agents[agent.Id] = agent;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<int> PurgeAllAgents()
|
||||
{
|
||||
int count = agents.Count;
|
||||
|
||||
agents.Clear();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public async Task<List<TAgent>> Query()
|
||||
{
|
||||
return agents.Select(x => x.Value).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
using BotSharp.Platform.Abstractions;
|
||||
using BotSharp.Platform.Models;
|
||||
using CSRedis;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Core.AgentStorage
|
||||
{
|
||||
public class AgentStorageInRedis<TAgent> : IAgentStorage<TAgent>
|
||||
where TAgent : AgentBase
|
||||
{
|
||||
private static CSRedisClient csredis;
|
||||
private static string prefix = String.Empty;
|
||||
|
||||
public AgentStorageInRedis()
|
||||
{
|
||||
if (csredis == null)
|
||||
{
|
||||
IConfiguration config = (IConfiguration)AppDomain.CurrentDomain.GetData("Configuration");
|
||||
var db = config.GetSection("Database:Default").Value;
|
||||
var dbConnStr = config.GetSection($"Database:ConnectionStrings:{db}").Value;
|
||||
|
||||
prefix = dbConnStr.Split(',').First(x => x.StartsWith("prefix=")).Split('=')[1];
|
||||
|
||||
csredis = new CSRedisClient(dbConnStr);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<TAgent> FetchById(string agentId)
|
||||
{
|
||||
var key = agentId;
|
||||
if (await csredis.ExistsAsync(key))
|
||||
{
|
||||
return JsonConvert.DeserializeObject<TAgent>(await csredis.GetAsync(key));
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<TAgent> FetchByName(string agentName)
|
||||
{
|
||||
var keys = csredis.Keys($"{prefix}*");
|
||||
foreach (string key in keys)
|
||||
{
|
||||
var data = await csredis.GetAsync(key.Substring(prefix.Length));
|
||||
var agent = JsonConvert.DeserializeObject<TAgent>(data);
|
||||
|
||||
if(agent.Name == agentName)
|
||||
{
|
||||
return agent;
|
||||
}
|
||||
}
|
||||
|
||||
return default(TAgent);
|
||||
}
|
||||
|
||||
public async Task<bool> Persist(TAgent agent)
|
||||
{
|
||||
if (String.IsNullOrEmpty(agent.Id))
|
||||
{
|
||||
agent.Id = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
var json = JsonConvert.SerializeObject(agent, new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
Formatting = Formatting.Indented,
|
||||
});
|
||||
|
||||
await csredis.SetAsync(agent.Id, json);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<int> PurgeAllAgents()
|
||||
{
|
||||
var keys = csredis.Keys($"{prefix}*");
|
||||
|
||||
await csredis.DelAsync(keys.Select(x => x.Substring(prefix.Length)).ToArray());
|
||||
|
||||
return keys.Count();
|
||||
}
|
||||
|
||||
public async Task<List<TAgent>> Query()
|
||||
{
|
||||
var agents = new List<TAgent>();
|
||||
|
||||
var keys = csredis.Keys($"{prefix}*");
|
||||
foreach (string key in keys)
|
||||
{
|
||||
var data = await csredis.GetAsync(key.Substring(prefix.Length));
|
||||
var agent = JsonConvert.DeserializeObject<TAgent>(data);
|
||||
agents.Add(agent);
|
||||
}
|
||||
|
||||
return agents;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
using BotSharp.Platform.Abstractions;
|
||||
using BotSharp.Platform.Models;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Core.AgentStorage
|
||||
{
|
||||
public class AgentStorageServiceRegister
|
||||
{
|
||||
public static void Register<TAgent>(IServiceCollection services)
|
||||
where TAgent : AgentBase
|
||||
{
|
||||
services.AddSingleton<IAgentStorageFactory<TAgent>, AgentStorageFactory<TAgent>>();
|
||||
|
||||
services.AddSingleton<AgentStorageInMemory<TAgent>>();
|
||||
services.AddSingleton<AgentStorageInRedis<TAgent>>();
|
||||
services.AddSingleton<AgentStorageInFile<TAgent>>();
|
||||
|
||||
services.AddSingleton(factory =>
|
||||
{
|
||||
Func<string, IAgentStorage<TAgent>> accesor = key =>
|
||||
{
|
||||
if (key.Equals("AgentStorageInRedis"))
|
||||
{
|
||||
return factory.GetService<AgentStorageInRedis<TAgent>>();
|
||||
}
|
||||
else if (key.Equals("AgentStorageInMemory"))
|
||||
{
|
||||
return factory.GetService<AgentStorageInMemory<TAgent>>();
|
||||
}
|
||||
else if (key.Equals("AgentStorageInFile"))
|
||||
{
|
||||
return factory.GetService<AgentStorageInFile<TAgent>>();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException($"Not Support key : {key}");
|
||||
}
|
||||
};
|
||||
|
||||
return accesor;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Version>0.4.0</Version>
|
||||
</PropertyGroup>
|
||||
|
|
@ -44,30 +45,14 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Accounts\**" />
|
||||
<Compile Remove="Engines\NERs\**" />
|
||||
<Compile Remove="Engines\QuickQA\**" />
|
||||
<Compile Remove="Engines\Sebis\**" />
|
||||
<Compile Remove="Engines\SpaCy\**" />
|
||||
<EmbeddedResource Remove="Accounts\**" />
|
||||
<EmbeddedResource Remove="Engines\NERs\**" />
|
||||
<EmbeddedResource Remove="Engines\QuickQA\**" />
|
||||
<EmbeddedResource Remove="Engines\Sebis\**" />
|
||||
<EmbeddedResource Remove="Engines\SpaCy\**" />
|
||||
<None Remove="Accounts\**" />
|
||||
<None Remove="Engines\NERs\**" />
|
||||
<None Remove="Engines\QuickQA\**" />
|
||||
<None Remove="Engines\Sebis\**" />
|
||||
<None Remove="Engines\SpaCy\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="CoreController.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CherubNLP" Version="0.5.0" />
|
||||
<PackageReference Include="Colorful.Console" Version="1.2.15" />
|
||||
|
|
@ -76,4 +61,8 @@
|
|||
<PackageReference Include="EntityFrameworkCore.BootKit" Version="6.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BotSharp.Abstraction\BotSharp.Abstraction.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
using BotSharp.Platform.Abstractions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Core.ContextStorage
|
||||
{
|
||||
public class ContextStorageFactory<T> : IContextStorageFactory<T>
|
||||
{
|
||||
private readonly Func<string, IContextStorage<T>> func;
|
||||
private readonly IPlatformSettings platformSetting;
|
||||
|
||||
public ContextStorageFactory(IPlatformSettings setting, Func<string, IContextStorage<T>> serviceAccessor)
|
||||
{
|
||||
this.func = serviceAccessor;
|
||||
this.platformSetting = setting;
|
||||
}
|
||||
|
||||
public IContextStorage<T> Get()
|
||||
{
|
||||
IContextStorage<T> storage = null;
|
||||
string storageName = this.platformSetting.ContextStorage;
|
||||
storage = func(storageName);
|
||||
return storage as IContextStorage<T>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
using BotSharp.Platform.Abstractions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Core.ContextStorage
|
||||
{
|
||||
public class ContextStorageInFile<T> : IContextStorage<T>
|
||||
{
|
||||
private static string storageDir;
|
||||
|
||||
public ContextStorageInFile()
|
||||
{
|
||||
IConfiguration config = (IConfiguration)AppDomain.CurrentDomain.GetData("Configuration");
|
||||
var db = config.GetSection("Database:Default").Value;
|
||||
storageDir = config.GetSection($"Database:ConnectionStrings:{db}").Value;
|
||||
string contentDir = AppDomain.CurrentDomain.GetData("DataPath").ToString();
|
||||
storageDir = storageDir.Replace("|DataDirectory|", contentDir + Path.DirectorySeparatorChar + "SessionStorage" + Path.DirectorySeparatorChar);
|
||||
|
||||
if (!Directory.Exists(storageDir))
|
||||
{
|
||||
Directory.CreateDirectory(storageDir);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<T[]> Fetch(string sessionId)
|
||||
{
|
||||
string dataPath = Path.Combine(storageDir, sessionId + ".json");
|
||||
if (File.Exists(dataPath))
|
||||
{
|
||||
string json = File.ReadAllText(dataPath);
|
||||
return JsonConvert.DeserializeObject<T[]>(json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new T[0];
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> Persist(string sessionId, T[] context)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(context, new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
Formatting = Formatting.Indented,
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
Converters = new List<JsonConverter>
|
||||
{
|
||||
new Newtonsoft.Json.Converters.StringEnumConverter()
|
||||
}
|
||||
});
|
||||
|
||||
string dataPath = Path.Combine(storageDir, sessionId + ".json");
|
||||
|
||||
File.WriteAllText(dataPath, json);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
using BotSharp.Platform.Abstractions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Core.ContextStorage
|
||||
{
|
||||
public class ContextStorageServiceRegister
|
||||
{
|
||||
public static void Register<T>(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IContextStorageFactory<T>, ContextStorageFactory<T>>();
|
||||
|
||||
services.AddSingleton<ContextStorageInFile<T>>();
|
||||
|
||||
services.AddSingleton(factory =>
|
||||
{
|
||||
Func<string, IContextStorage<T>> accesor = key =>
|
||||
{
|
||||
if (key.Equals("ContextStorageInFile"))
|
||||
{
|
||||
return factory.GetService<ContextStorageInFile<T>>();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException($"Not Support key : {key}");
|
||||
}
|
||||
};
|
||||
|
||||
return accesor;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
using EntityFrameworkCore.BootKit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Core.Conversations
|
||||
{
|
||||
[Table("Bot_Conversation")]
|
||||
public class Conversation : DbRecord, IDbRecord
|
||||
{
|
||||
[Required]
|
||||
[StringLength(36)]
|
||||
public String AgentId { get; set; }
|
||||
|
||||
[StringLength(36)]
|
||||
public String UserId { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime StartTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
using EntityFrameworkCore.BootKit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Core.Conversations
|
||||
{
|
||||
[Table("Bot_ConversationContext")]
|
||||
public class ConversationContext : DbRecord, IDbRecord
|
||||
{
|
||||
[Required]
|
||||
[StringLength(36)]
|
||||
public String ConversationId { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(64)]
|
||||
public String Context { get; set; }
|
||||
|
||||
public int Lifespan { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,221 +0,0 @@
|
|||
using BotSharp.Platform.Models;
|
||||
using BotSharp.Platform.Models.AiRequest;
|
||||
using BotSharp.Platform.Models.AiResponse;
|
||||
using BotSharp.Platform.Models.Entities;
|
||||
using EntityFrameworkCore.BootKit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Core.Engines
|
||||
{
|
||||
/// <summary>
|
||||
/// Bot engine/ platform base class
|
||||
/// </summary>
|
||||
public abstract class BotEngineBase
|
||||
{
|
||||
protected Database Dc;
|
||||
|
||||
protected AgentBase Agent { get; set; }
|
||||
|
||||
public BotEngineBase()
|
||||
{
|
||||
Dc = new DefaultDataContextLoader().GetDefaultDc();
|
||||
}
|
||||
|
||||
public Task<AiResponse> TextRequest(AiRequest request)
|
||||
{
|
||||
var preditor = new BotPredictor();
|
||||
var doc = preditor.Predict(Agent, new AiRequest
|
||||
{
|
||||
AgentDir = request.AgentDir,
|
||||
Model = request.Model,
|
||||
SessionId = request.SessionId,
|
||||
Text = request.Text
|
||||
}).Result;
|
||||
|
||||
var parameters = new Dictionary<String, Object>();
|
||||
if(doc.Sentences[0].Entities == null)
|
||||
{
|
||||
doc.Sentences[0].Entities = new List<NlpEntity>();
|
||||
}
|
||||
doc.Sentences[0].Entities.ForEach(x => parameters[x.Entity] = x.Value);
|
||||
return Task.FromResult(new AiResponse
|
||||
{
|
||||
/*Lang = request.Language,
|
||||
Timestamp = DateTime.UtcNow,
|
||||
SessionId = request.SessionId,
|
||||
Status = new AIResponseStatus(),
|
||||
Result = new AIResponseResult
|
||||
{
|
||||
Score = doc.Sentences[0].Intent == null ? 0 : doc.Sentences[0].Intent.Confidence,
|
||||
ResolvedQuery = doc.Sentences[0].Text,
|
||||
Fulfillment = new AIResponseFulfillment
|
||||
{
|
||||
Speech = agent.Intents.FirstOrDefault(tnt => tnt.Name == doc.Sentences[0].Intent?.Label)?.Responses?.Random()?.Messages?.Random()?.Speech
|
||||
},
|
||||
Parameters = parameters,
|
||||
Entities = doc.Sentences[0].Entities,
|
||||
Metadata = new AIResponseMetadata
|
||||
{
|
||||
IntentName = doc.Sentences[0].Intent?.Label
|
||||
}
|
||||
}*/
|
||||
});
|
||||
}
|
||||
|
||||
/*public TrainingCorpus GetIntentExpressions(AgentBase agent)
|
||||
{
|
||||
TrainingCorpus corpus = new TrainingCorpus()
|
||||
{
|
||||
UserSays = new List<TrainingIntentExpression<TrainingIntentExpressionPart>>(),
|
||||
Entities = new List<TrainingEntity>()
|
||||
};
|
||||
|
||||
var expressParts = new List<IntentExpressionPart>();
|
||||
|
||||
var intents = agent.Intents;
|
||||
|
||||
intents.ForEach(intent =>
|
||||
{
|
||||
intent.UserSays.ForEach(exp =>
|
||||
{
|
||||
exp.Data = exp.Data.OrderBy(x => x.UpdatedTime).ToList();
|
||||
|
||||
var say = new TrainingIntentExpression<TrainingIntentExpressionPart>
|
||||
{
|
||||
Intent = intent.Name,
|
||||
Text = String.Join("", exp.Data.Select(x => x.Text)),
|
||||
ContextHash = intent.ContextHash
|
||||
};
|
||||
|
||||
// convert entity format
|
||||
exp.Data.Where(x => !String.IsNullOrEmpty(x.Meta))
|
||||
.ToList()
|
||||
.ForEach(x =>
|
||||
{
|
||||
var part = new TrainingIntentExpressionPart
|
||||
{
|
||||
Value = x.Text,
|
||||
Entity = $"{x.Meta}:{x.Alias}",
|
||||
Start = x.Start
|
||||
};
|
||||
|
||||
if (say.Entities == null) say.Entities = new List<TrainingIntentExpressionPart>();
|
||||
say.Entities.Add(part);
|
||||
|
||||
// assemble entity synonmus
|
||||
if (!trainingData.Entities.Any(y => y.EntityType == x.Alias && y.EntityValue == x.Text))
|
||||
{
|
||||
var allSynonyms = (from e in dc.Table<EntityType>()
|
||||
join ee in dc.Table<EntityEntry>() on e.Id equals ee.EntityId
|
||||
join ees in dc.Table<EntrySynonym>() on ee.Id equals ees.EntityEntryId
|
||||
where e.Name == x.Alias && ee.Value == x.Text & ees.Synonym != x.Text
|
||||
select ees.Synonym).ToList();
|
||||
|
||||
var te = new TrainingEntity
|
||||
{
|
||||
EntityType = $"{x.Meta}:{x.Alias}",
|
||||
EntityValue = x.Text,
|
||||
Synonyms = allSynonyms
|
||||
};
|
||||
|
||||
trainingData.Entities.Add(te);
|
||||
}
|
||||
});
|
||||
|
||||
corpus.UserSays.Add(say);
|
||||
});
|
||||
});
|
||||
|
||||
// remove Default Fallback Intent
|
||||
corpus.UserSays = corpus.UserSays.Where(x => x.Intent != "Default Fallback Intent").ToList();
|
||||
|
||||
return corpus;
|
||||
}*/
|
||||
|
||||
public TrainingCorpus GetIntentExpressions()
|
||||
{
|
||||
TrainingCorpus corpus = new TrainingCorpus()
|
||||
{
|
||||
UserSays = new List<TrainingIntentExpression<TrainingIntentExpressionPart>>(),
|
||||
Entities = new List<TrainingEntity>()
|
||||
};
|
||||
|
||||
/*var expressParts = new List<IntentExpressionPart>();
|
||||
|
||||
var intents = dc.Table<Intent>()
|
||||
.Include(x => x.Contexts)
|
||||
.Include(x => x.UserSays).ThenInclude(say => say.Data)
|
||||
.Where(x => x.AgentId == agent.Id && x.UserSays.Count > 0)
|
||||
.ToList();
|
||||
|
||||
intents.ForEach(intent =>
|
||||
{
|
||||
intent.UserSays.ForEach(exp =>
|
||||
{
|
||||
exp.Data = exp.Data.OrderBy(x => x.UpdatedTime).ToList();
|
||||
|
||||
var say = new TrainingIntentExpression<TrainingIntentExpressionPart>
|
||||
{
|
||||
Intent = intent.Name,
|
||||
Text = String.Join("", exp.Data.Select(x => x.Text)),
|
||||
ContextHash = intent.ContextHash
|
||||
};
|
||||
|
||||
// convert entity format
|
||||
exp.Data.Where(x => !String.IsNullOrEmpty(x.Meta))
|
||||
.ToList()
|
||||
.ForEach(x =>
|
||||
{
|
||||
var part = new TrainingIntentExpressionPart
|
||||
{
|
||||
Value = x.Text,
|
||||
Entity = $"{x.Meta}:{x.Alias}",
|
||||
Start = x.Start
|
||||
};
|
||||
|
||||
if (say.Entities == null) say.Entities = new List<TrainingIntentExpressionPart>();
|
||||
say.Entities.Add(part);
|
||||
|
||||
// assemble entity synonmus
|
||||
if (!trainingData.Entities.Any(y => y.EntityType == x.Alias && y.EntityValue == x.Text))
|
||||
{
|
||||
var allSynonyms = (from e in dc.Table<EntityType>()
|
||||
join ee in dc.Table<EntityEntry>() on e.Id equals ee.EntityId
|
||||
join ees in dc.Table<EntrySynonym>() on ee.Id equals ees.EntityEntryId
|
||||
where e.Name == x.Alias && ee.Value == x.Text & ees.Synonym != x.Text
|
||||
select ees.Synonym).ToList();
|
||||
|
||||
var te = new TrainingEntity
|
||||
{
|
||||
EntityType = $"{x.Meta}:{x.Alias}",
|
||||
EntityValue = x.Text,
|
||||
Synonyms = allSynonyms
|
||||
};
|
||||
|
||||
trainingData.Entities.Add(te);
|
||||
}
|
||||
});
|
||||
|
||||
corpus.UserSays.Add(say);
|
||||
});
|
||||
});
|
||||
|
||||
// remove Default Fallback Intent
|
||||
corpus.UserSays = corpus.UserSays.Where(x => x.Intent != "Default Fallback Intent").ToList();*/
|
||||
|
||||
return corpus;
|
||||
}
|
||||
|
||||
public virtual Task Train(BotTrainOptions options)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
using BotSharp.Core.Abstractions;
|
||||
using BotSharp.Platform.Models;
|
||||
using BotSharp.Platform.Models.AiRequest;
|
||||
using BotSharp.Platform.Models.MachineLearning;
|
||||
using DotNetToolkit;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Console = Colorful.Console;
|
||||
|
||||
namespace BotSharp.Core.Engines
|
||||
{
|
||||
public class BotPredictor
|
||||
{
|
||||
public async Task<NlpDoc> Predict(AgentBase agent, AiRequest request)
|
||||
{
|
||||
// load model per context
|
||||
var dir = Path.Combine(request.AgentDir, request.Model);
|
||||
Console.WriteLine($"Load model from {dir}");
|
||||
var metaJson = File.ReadAllText(Path.Combine(dir, "model-meta.json"));
|
||||
var meta = JsonConvert.DeserializeObject<ModelMetaData>(metaJson);
|
||||
|
||||
// Get NLP Provider
|
||||
var config = (IConfiguration)AppDomain.CurrentDomain.GetData("Configuration");
|
||||
var assemblies = (string[])AppDomain.CurrentDomain.GetData("Assemblies");
|
||||
|
||||
var providerPipe = meta.Pipeline.First();
|
||||
var provider = TypeHelper.GetInstance(providerPipe.Name, assemblies) as INlpProvider;
|
||||
provider.Configuration = config.GetSection(meta.Platform);
|
||||
|
||||
var data = new NlpDoc
|
||||
{
|
||||
Sentences = new List<NlpDocSentence>
|
||||
{
|
||||
new NlpDocSentence
|
||||
{
|
||||
Text = request.Text
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
await provider.Load(agent, providerPipe);
|
||||
meta.Pipeline.RemoveAt(0);
|
||||
|
||||
var settings = new PipeSettings
|
||||
{
|
||||
ModelDir = dir,
|
||||
ProjectDir = request.AgentDir
|
||||
};
|
||||
|
||||
|
||||
// pipe process
|
||||
var pipelines = config.GetValue<String>($"{meta.BotEngine}_{agent.Language}:pipe")
|
||||
.Split(',')
|
||||
.Select(x => x.Trim())
|
||||
.ToList();
|
||||
|
||||
for(int pipeIdx = 0; pipeIdx < pipelines.Count; pipeIdx++)
|
||||
{
|
||||
var pipe = TypeHelper.GetInstance(pipelines[pipeIdx], assemblies) as INlpPredict;
|
||||
pipe.Configuration = config.GetSection($"{meta.BotEngine}_{agent.Language}").GetSection(pipelines[pipeIdx]);
|
||||
pipe.Settings = settings;
|
||||
var pipeModel = meta.Pipeline.FirstOrDefault(x => x.Name == pipelines[pipeIdx]);
|
||||
await pipe.Predict(agent, data, pipeModel);
|
||||
}
|
||||
|
||||
/*Console.WriteLine($"Prediction result:", Color.Green);
|
||||
Console.WriteLine(JsonConvert.SerializeObject(data, new JsonSerializerSettings
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
}));*/
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
using BotSharp.Core.Abstractions;
|
||||
using CherubNLP;
|
||||
using CherubNLP.Classify;
|
||||
using BotSharp.Platform.Models;
|
||||
using BotSharp.Platform.Models.AiResponse;
|
||||
using BotSharp.Platform.Models.MachineLearning;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BotSharp.Core.Engines.BotSharp
|
||||
{
|
||||
public class BotSharpIntentClassifier : INlpTrain, INlpPredict
|
||||
{
|
||||
public IConfiguration Configuration { get; set; }
|
||||
public PipeSettings Settings { get; set; }
|
||||
private ClassifierFactory<SentenceFeatureExtractor> _classifier;
|
||||
|
||||
public async Task<bool> Train(AgentBase agent, NlpDoc doc, PipeModel meta)
|
||||
{
|
||||
Init(meta);
|
||||
|
||||
var sentences = doc.Sentences.Select(x => new Sentence
|
||||
{
|
||||
Label = x.Intent.Label,
|
||||
Text = x.Text,
|
||||
Words = x.Tokens
|
||||
}).ToList();
|
||||
|
||||
_classifier.Train(sentences);
|
||||
|
||||
Console.WriteLine($"Saved model to {Settings.ModelDir}");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> Predict(AgentBase agent, NlpDoc doc, PipeModel meta)
|
||||
{
|
||||
Init(meta);
|
||||
|
||||
var sentence = doc.Sentences.Select(s => new Sentence
|
||||
{
|
||||
Text = s.Text,
|
||||
Words = s.Tokens
|
||||
}).First();
|
||||
|
||||
|
||||
var result = _classifier.Classify(sentence);
|
||||
|
||||
doc.Sentences[0].Intent = new TextClassificationResult
|
||||
{
|
||||
Classifier = "BotSharpIntentClassifier",
|
||||
Label = result.First().Item1,
|
||||
Confidence = result.First().Item2
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Init(PipeModel meta)
|
||||
{
|
||||
if (_classifier == null)
|
||||
{
|
||||
meta.Model = "intent.model";
|
||||
|
||||
var options = new ClassifyOptions
|
||||
{
|
||||
ModelFilePath = Path.Combine(Settings.ModelDir, meta.Model),
|
||||
ModelDir = Settings.ModelDir,
|
||||
ModelName = meta.Model,
|
||||
Word2VecFilePath = Configuration.GetValue<string>("wordvecModel")
|
||||
};
|
||||
|
||||
if (!String.IsNullOrEmpty(options.Word2VecFilePath))
|
||||
{
|
||||
string contentDir = AppDomain.CurrentDomain.GetData("DataPath").ToString();
|
||||
options.Word2VecFilePath = options.Word2VecFilePath.Replace("|App_Data|", contentDir + System.IO.Path.DirectorySeparatorChar);
|
||||
}
|
||||
|
||||
_classifier = new ClassifierFactory<SentenceFeatureExtractor>(options, SupportedLanguage.English);
|
||||
|
||||
string classifierName = Configuration.GetValue<String>($"classifer");
|
||||
|
||||
_classifier.GetClassifer(classifierName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,272 +0,0 @@
|
|||
using BotSharp.Core.Abstractions;
|
||||
using Bigtree.Algorithm.CRFLite;
|
||||
using Bigtree.Algorithm.CRFLite.Decoder;
|
||||
using Bigtree.Algorithm.CRFLite.Encoder;
|
||||
using CherubNLP.Tokenize;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BotSharp.Platform.Models;
|
||||
using BotSharp.Platform.Models.MachineLearning;
|
||||
using BotSharp.Platform.Models.Entities;
|
||||
|
||||
namespace BotSharp.Core.Engines.BotSharp
|
||||
{
|
||||
public class BotSharpNER : INlpTrain, INlpPredict
|
||||
{
|
||||
public IConfiguration Configuration { get; set; }
|
||||
public PipeSettings Settings { get; set; }
|
||||
|
||||
public async Task<bool> Train(AgentBase agent, NlpDoc doc, PipeModel meta)
|
||||
{
|
||||
var corpus = agent.Corpus;
|
||||
|
||||
meta.Model = "ner-crf.model";
|
||||
|
||||
List<TrainingIntentExpression<TrainingIntentExpressionPart>> userSays = corpus.UserSays;
|
||||
List<List<TrainingData>> list = new List<List<TrainingData>>();
|
||||
|
||||
string rawTrainingDataFileName = System.IO.Path.Combine(Settings.ModelDir, "ner-crf.corpus.txt");
|
||||
string modelFileName = System.IO.Path.Combine(Settings.ModelDir, meta.Model);
|
||||
|
||||
using (FileStream fs = new FileStream(rawTrainingDataFileName, FileMode.Create))
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(fs))
|
||||
{
|
||||
for (int i = 0; i < doc.Sentences.Count; i++)
|
||||
{
|
||||
List<TrainingData> curLine = Merge(doc, doc.Sentences[i].Tokens, userSays[i].Entities);
|
||||
curLine.ForEach(trainingData =>
|
||||
{
|
||||
string[] wordParams = { trainingData.Token, trainingData.Pos, trainingData.Entity };
|
||||
string wordStr = string.Join("\t", wordParams);
|
||||
sw.WriteLine(wordStr);
|
||||
});
|
||||
list.Add(curLine);
|
||||
sw.WriteLine();
|
||||
}
|
||||
sw.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
string contentDir = AppDomain.CurrentDomain.GetData("DataPath").ToString();
|
||||
string template = Configuration.GetValue<String>($"template");
|
||||
template = template.Replace("|App_Data|", contentDir + System.IO.Path.DirectorySeparatorChar);
|
||||
|
||||
var encoder = new CRFEncoder();
|
||||
bool result = encoder.Learn(new EncoderOptions
|
||||
{
|
||||
TrainingCorpusFileName = rawTrainingDataFileName,
|
||||
TemplateFileName = template,
|
||||
ModelFileName = modelFileName,
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<TrainingData> Merge(NlpDoc doc, List<Token> tokens, List<TrainingIntentExpressionPart> entities)
|
||||
{
|
||||
List<TrainingData> trainingTuple = new List<TrainingData>();
|
||||
HashSet<String> entityWordBag = new HashSet<String>();
|
||||
int wordCandidateCount = 0;
|
||||
|
||||
for (int i = 0; i < tokens.Count; i++)
|
||||
{
|
||||
TrainingIntentExpressionPart curEntity = null;
|
||||
if (entities == null) continue;
|
||||
|
||||
bool entityFinded = false;
|
||||
for (int entityIndex = 0; entityIndex < entities.Count; entityIndex++)
|
||||
{
|
||||
var entity = entities[entityIndex];
|
||||
|
||||
if (!entityFinded)
|
||||
{
|
||||
var vDoc = new NlpDoc { Sentences = new List<NlpDocSentence> { new NlpDocSentence { Text = entity.Value } } };
|
||||
doc.Tokenizer.Predict(null, vDoc, null);
|
||||
string[] words = vDoc.Sentences[0].Tokens.Select(x => x.Text).ToArray();
|
||||
|
||||
for (int j = 0; j < words.Length; j++)
|
||||
{
|
||||
if (tokens[i + j].Text == words[j])
|
||||
{
|
||||
wordCandidateCount++;
|
||||
if (j == words.Length - 1)
|
||||
{
|
||||
curEntity = entity;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wordCandidateCount = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (wordCandidateCount != 0) // && entity.Start == tokens[i].Offset)
|
||||
{
|
||||
String entityName = curEntity.Entity.Contains(":") ? curEntity.Entity.Substring(curEntity.Entity.IndexOf(":") + 1) : curEntity.Entity;
|
||||
|
||||
for(int wordIndex = 0; wordIndex < words.Length; wordIndex++)
|
||||
{
|
||||
var tag = entityName;
|
||||
|
||||
if (wordIndex == 0)
|
||||
{
|
||||
if (words.Length == 1)
|
||||
{
|
||||
tag = "S_" + entityName;
|
||||
}
|
||||
else
|
||||
{
|
||||
tag = "B_" + entityName;
|
||||
}
|
||||
}
|
||||
else if (wordIndex == words.Length - 1)
|
||||
{
|
||||
tag = "E_" + entityName;
|
||||
}
|
||||
else
|
||||
{
|
||||
tag = "M_" + entityName;
|
||||
}
|
||||
|
||||
var word = words[wordIndex];
|
||||
trainingTuple.Add(new TrainingData(tag, word, tokens[i].Pos));
|
||||
}
|
||||
|
||||
entityFinded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wordCandidateCount == 0)
|
||||
{
|
||||
trainingTuple.Add(new TrainingData("S", tokens[i].Text, tokens[i].Pos));
|
||||
}
|
||||
else
|
||||
{
|
||||
i = i + wordCandidateCount - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return trainingTuple;
|
||||
}
|
||||
|
||||
public async Task<bool> Predict(AgentBase agent, NlpDoc doc, PipeModel meta)
|
||||
{
|
||||
var decoder = new CRFDecoder();
|
||||
var options = new DecoderOptions
|
||||
{
|
||||
ModelFileName = System.IO.Path.Combine(Settings.ModelDir, meta.Model)
|
||||
};
|
||||
|
||||
//Load encoded model from file
|
||||
decoder.LoadModel(options.ModelFileName);
|
||||
|
||||
//Create decoder tagger instance.
|
||||
var tagger = decoder.CreateTagger(options.NBest, options.MaxWord);
|
||||
tagger.set_vlevel(options.ProbLevel);
|
||||
|
||||
//Initialize result
|
||||
var crf_out = new CRFSegOut[options.NBest];
|
||||
for (var i = 0; i < options.NBest; i++)
|
||||
{
|
||||
crf_out[i] = new CRFSegOut(options.MaxWord);
|
||||
}
|
||||
|
||||
doc.Sentences.ForEach(sent =>
|
||||
{
|
||||
List<List<String>> dataset = new List<List<string>>();
|
||||
dataset.AddRange(sent.Tokens.Select(token => new List<String> { token.Text, token.Pos }).ToList());
|
||||
//predict given string's tags
|
||||
decoder.Segment(crf_out, tagger, dataset);
|
||||
|
||||
var entities = new List<NlpEntity>();
|
||||
|
||||
for (int i = 0; i < sent.Tokens.Count; i++)
|
||||
{
|
||||
for (int crf_index = 0; crf_index < crf_out.Length; crf_index++)
|
||||
{
|
||||
//entity can be extract in more than 1 run/index
|
||||
//var entity = crf_out[0].result_;
|
||||
var entity = crf_out[crf_index].result_;
|
||||
var contains = entities.Exists(x => x.Entity == entity[i]);
|
||||
if (!contains)
|
||||
{
|
||||
entities.Add(new NlpEntity
|
||||
{
|
||||
Entity = entity[i],
|
||||
Start = doc.Sentences[0].Tokens[i].Start,
|
||||
Value = doc.Sentences[0].Tokens[i].Text,
|
||||
Confidence = 0,
|
||||
Extrator = "BotSharpNER"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sent.Entities = MergeEntity(doc.Sentences[0].Text, entities);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<NlpEntity> MergeEntity(string sentence, List<NlpEntity> tokens)
|
||||
{
|
||||
List<NlpEntity> res = new List<NlpEntity>();
|
||||
|
||||
for(int i = 0; i < tokens.Count; i++)
|
||||
{
|
||||
var entity = tokens[i];
|
||||
|
||||
if (entity.Entity.StartsWith("S_"))
|
||||
{
|
||||
entity.Entity = entity.Entity.Split('_')[1];
|
||||
res.Add(entity);
|
||||
}
|
||||
else if (entity.Entity.StartsWith("B_"))
|
||||
{
|
||||
entity.Entity = entity.Entity.Split('_')[1];
|
||||
|
||||
for(int j = i; j < tokens.Count; j++)
|
||||
{
|
||||
var token = tokens[j];
|
||||
if (token.Entity.StartsWith("E_"))
|
||||
{
|
||||
res.Add(new NlpEntity
|
||||
{
|
||||
Value = sentence.Substring(entity.Start, token.End - entity.Start + 1),
|
||||
Entity = entity.Entity,
|
||||
Extrator = entity.Extrator,
|
||||
Start = entity.Start,
|
||||
Confidence = entity.Confidence
|
||||
});
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public class TrainingData
|
||||
{
|
||||
public String Token { get; set; }
|
||||
public String Entity { get; set; }
|
||||
public String Pos { get; set; }
|
||||
|
||||
public TrainingData(string entity, string token, string pos)
|
||||
{
|
||||
Token = token;
|
||||
Entity = entity;
|
||||
Pos = pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BotSharp.Platform.Abstractions;
|
||||
using BotSharp.Platform.Models;
|
||||
|
||||
namespace BotSharp.Core.Engines.BotSharp
|
||||
{
|
||||
public class BotSharpNLU : BotEngineBase, IBotEngine
|
||||
{
|
||||
public override async Task Train(BotTrainOptions options)
|
||||
{
|
||||
var trainer = new BotTrainer(Agent.Id, Dc);
|
||||
await trainer.Train(Agent, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue