我必须将DialogFlow (以前的API.AI)从V1 API重构为新的V2 gRPC。所以我准备好了一切开始重构。但我立刻遇到了一些问题。当试图更新某些entityType的实体时,请参阅下面的示例。
updateEntity.Synonyms是只读属性.
W00t?知道为什么吗?或者还有其他的(合适的)?这么做的方法?
var client = DialogFlowHelper.DialogFlowCreateChannelClientEntityTypes();
List<EntityEntry> input = JsonConvert.DeserializeObject<List<EntityEntry>>(jsonData);
List<EntityType.Types.Entity> updateEntities = new List<EntityType.Types.Entity>();
foreach (var e in input)
{
var updateEntity = new EntityType.Types.Entity();
updateEntity.Value = e.value;
// HERE IS THE PROBLEM !!!!
// HERE IS THE PROBLEM !!!!
// HERE IS THE PROBLEM !!!!
//updateEntity.Synonyms =
updateEntities.Add(updateEntity);
}
var res = await client.BatchUpdateEntitiesAsync(
new EntityTypeName("no_problem", "no_problem"),
updateEntities
);同义词的定义如下:
//
// Summary:
// Required. A collection of synonyms. For `KIND_LIST` entity types this must contain
// exactly one synonym equal to `value`.
[DebuggerNonUserCode]
public RepeatedField<string> Synonyms { get; }发布于 2018-10-03 11:50:02
我已经解决了这个问题。
同义词集合(RepeatedField)已经作为一个空集合存在。这样您就可以添加项目到它!
https://stackoverflow.com/questions/52625697
复制相似问题