简体   繁体   English

DialogFlow V2 gRPC(c#)(更新实体等)

[英]DialogFlow V2 gRPC (c#) (updating entities, etc.)

I have to refactor DialogFlow (previously API.AI) from V1 API to new V2 gRPC. 我必须将DialogFlow(以前是API.AI)从V1 API重构为新的V2 gRPC。 So I prepared everything and started refactoring. 因此,我准备了一切并开始重构。 But immediately I had some issues. 但是立即我遇到了一些问题。 See the example below, when trying to update entities for some entityType. 尝试为某些entityType更新实体时,请参见下面的示例。

updateEntity. updateEntity。 Synonyms is READ-ONLY property. 同义词READ-ONLY属性。

W00t ??? W00t ??? Any idea why is that? 知道为什么吗? Or is there another (proper?) way to do this? 还是有另一种(正确的?)方法吗?

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
    );

Definiton for Synonyms goes like this: Definiton for 同义词如下:

//
// 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; }

I have solved the issue. 我已经解决了这个问题。

Synonyms collection (RepeatedField) is ALREADY existing as an empty collection. 同义词集合(RepeatedField)已作为空集合存在。 So you can just add items to it! 因此,您只需向其中添加项目即可!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM