update language detection
This commit is contained in:
parent
de23377782
commit
ab3c6089a6
|
|
@ -23,7 +23,7 @@ public class ResponseToUserRoutingHandler : RoutingHandlerBase, IRoutingHandler
|
|||
new ParameterPropertyDef("user_message_in_english",
|
||||
"Translate user message from non-English to English"),
|
||||
new ParameterPropertyDef("language",
|
||||
"Language detected based on the latest message that USER sent, could be English, Spanish or Chinese.",
|
||||
"User prefered language, considering the whole conversation. Language could be English, Spanish or Chinese.",
|
||||
required: true),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class RouteToAgentRoutingHandler : RoutingHandlerBase, IRoutingHandler
|
|||
new ParameterPropertyDef("user_message_in_english",
|
||||
"Translate user message from non-English to English"),
|
||||
new ParameterPropertyDef("language",
|
||||
"Language detected based on the latest message that USER sent, could be English, Spanish or Chinese.",
|
||||
"User prefered language, considering the whole conversation. Language could be English, Spanish or Chinese.",
|
||||
required: true),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Amazon.Runtime.Internal.Transform;
|
||||
using BotSharp.Abstraction.Options;
|
||||
using BotSharp.Abstraction.Templating;
|
||||
using BotSharp.Abstraction.Translation;
|
||||
using BotSharp.Abstraction.Translation.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
using System.Reflection;
|
||||
|
|
@ -28,16 +29,23 @@ public class TranslationService : ITranslationService
|
|||
{
|
||||
_router = router;
|
||||
_messageId = messageId;
|
||||
|
||||
var unique = new HashSet<string>();
|
||||
Collect(data, ref unique);
|
||||
if (unique.Count == 0)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
var cloned = data;
|
||||
if (clone)
|
||||
{
|
||||
cloned = Clone(data);
|
||||
}
|
||||
|
||||
var unique = new HashSet<string>();
|
||||
Collect(cloned, ref unique);
|
||||
var map = await InnerTranslate(unique, language);
|
||||
cloned = Assign(cloned, map);
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,3 +10,4 @@ Expected user goal agent is {{ expected_user_goal_agent }}.
|
|||
{%- else -%}
|
||||
User goal agent is inferred based on user initial request.
|
||||
{%- endif %}
|
||||
Detect language based on the overall content in [CONVERSATION] and only include user message.
|
||||
Loading…
Reference in a new issue