Fix intent code start issue.
This commit is contained in:
parent
1dc8b2fa61
commit
973ec72e6d
|
|
@ -7,9 +7,12 @@ namespace BotSharp.Core.Templating;
|
|||
public class ResponseTemplateService : IResponseTemplateService
|
||||
{
|
||||
private readonly IServiceProvider _services;
|
||||
public ResponseTemplateService(IServiceProvider services)
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public ResponseTemplateService(IServiceProvider services, ILogger<ResponseTemplateService> logger)
|
||||
{
|
||||
_services = services;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<string> RenderFunctionResponse(string agentId, RoleDialogModel message)
|
||||
|
|
@ -33,9 +36,17 @@ public class ResponseTemplateService : IResponseTemplateService
|
|||
|
||||
// Convert args and execute data to dictionary
|
||||
var dict = new Dictionary<string, object>();
|
||||
ExtractArgs(JsonSerializer.Deserialize<JsonDocument>(message.FunctionArgs), dict);
|
||||
ExtractExecuteData(message.ExecutionData, dict);
|
||||
|
||||
if (message.FunctionArgs != null)
|
||||
{
|
||||
ExtractArgs(JsonSerializer.Deserialize<JsonDocument>(message.FunctionArgs), dict);
|
||||
}
|
||||
|
||||
if (message.ExecutionData != null)
|
||||
{
|
||||
ExtractExecuteData(message.ExecutionData, dict);
|
||||
}
|
||||
|
||||
var text = render.Render(template, dict);
|
||||
|
||||
return text;
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@ public class fastTextEmbeddingProvider : ITextEmbedding
|
|||
{
|
||||
get
|
||||
{
|
||||
if (!_fastText.IsModelReady())
|
||||
{
|
||||
_fastText.LoadModel(_settings.ModelPath);
|
||||
}
|
||||
LoadModel();
|
||||
return _fastText.GetModelDimension();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,12 +53,14 @@ public class IntentClassifier
|
|||
|
||||
var vector = _services.GetRequiredService<ITextEmbedding>();
|
||||
|
||||
var labels = GetLabels();
|
||||
|
||||
var layers = new List<ILayer>
|
||||
{
|
||||
keras.layers.InputLayer((vector.Dimension), name: "Input"),
|
||||
keras.layers.Dense(256, activation:"relu"),
|
||||
keras.layers.Dense(256, activation:"relu"),
|
||||
keras.layers.Dense(GetFiles().Length, activation: keras.activations.Softmax)
|
||||
keras.layers.Dense(labels.Length, activation: keras.activations.Softmax)
|
||||
};
|
||||
_model = keras.Sequential(layers);
|
||||
|
||||
|
|
@ -235,7 +237,6 @@ public class IntentClassifier
|
|||
|
||||
var prediction = GetLabels()[probLabel[0]];
|
||||
|
||||
|
||||
return prediction;
|
||||
}
|
||||
public void InitClassifer()
|
||||
|
|
@ -249,8 +250,8 @@ public class IntentClassifier
|
|||
{
|
||||
var trainingParams = new TrainingParams();
|
||||
Reset();
|
||||
Build();
|
||||
(var x, var y) = PrepareLoadData();
|
||||
Build();
|
||||
Fit(x, y, trainingParams);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,14 +47,14 @@
|
|||
}
|
||||
},
|
||||
|
||||
"MetaAi": {
|
||||
"fastText": {
|
||||
"ModelPath": "crawl-300d-2M-subword.bin"
|
||||
}
|
||||
},
|
||||
"MetaAi": {
|
||||
"fastText": {
|
||||
"ModelPath": "dbpedia.ftz"
|
||||
}
|
||||
},
|
||||
|
||||
"RoutingSpeeder": {
|
||||
},
|
||||
"RoutingSpeeder": {
|
||||
},
|
||||
|
||||
"MetaMessenger": {
|
||||
"Endpoint": "https://graph.facebook.com",
|
||||
|
|
|
|||
BIN
src/WebStarter/data/models/dbpedia.ftz
Normal file
BIN
src/WebStarter/data/models/dbpedia.ftz
Normal file
Binary file not shown.
Loading…
Reference in a new issue