简体   繁体   English

Java 客户端上的 Dialogflow V2 代理版本控制

[英]Dialogflow V2 Agent Versioning on Java Client

I'm porting to DialogFlow V2 and would like to give agent-versions a try.我正在移植到 DialogFlow V2,并想尝试一下代理版本。 Read about it here: https://cloud.google.com/dialogflow/docs/agents-versions在此处阅读: https://cloud.google.com/dialogflow/docs/agents-versions

The thing is that I don't know how that affects the configuration on credentials, as I wan't able to find anything on the client library.问题是我不知道这会如何影响凭据配置,因为我无法在客户端库中找到任何内容。 The current code I have for authentication is我用于身份验证的当前代码是

  public DialogFlowEngine(DialogFlowConfig config) throws IOException {
    this.config = config;
    GoogleCredentials credentials = GoogleCredentials.fromStream(
        new ByteArrayInputStream(config.getClientCredentials().getBytes())
    );
    this.sessionSettings =
        SessionsSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credentials))
            .build();
    this.projectId = ((ServiceAccountCredentials)credentials).getProjectId();
  }

Then when creating the session:然后在创建 session 时:

try (SessionsClient sessionsClient = SessionsClient.create(this.sessionSettings)) {
        SessionName session = SessionName.of(projectId, requestId);
    ...

I've seen that if I wanted to use the agent-versioning feature using the RAW rest endpoint I'd have to post to a url like "https://dialogflow.googleapis.com/v2beta1/projects/small-talk-dfghk/agent/environments/development/users/-/sessions/e5472b8a-9feb-43f1-8213-648215960d22:detectIntent"我已经看到,如果我想使用 RAW rest 端点来使用代理版本控制功能,我必须发布到 url 像"https://dialogflow.googleapis.com/v2beta1/projects/small-talk-dfghk/agent/environments/development/users/-/sessions/e5472b8a-9feb-43f1-8213-648215960d22:detectIntent"

However by the looks of the api it seems that such operation can't be performed as he SessionName class decompiled matches a URL like so:但是,从 api 的外观看来,似乎无法执行此类操作,因为反编译的 SessionName class 与 URL 匹配,如下所示:

private static final PathTemplate PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding("projects/{project}/agent/sessions/{session}");

Is there a way we could do it?有没有办法我们可以做到? How would you recommend configuring DialogFlow between environments (dev, qa, staging, prod...) otherwise?否则,您将如何建议在环境(开发、质量保证、暂存、产品...)之间配置 DialogFlow?

Even if I had the proper API call I still wonder... Do different agent versions mean we can have different Json credentials per environment?即使我有正确的 API 调用,我仍然想知道......不同的代理版本是否意味着我们可以在每个环境中拥有不同的 Json 凭据?

Thanks for your help!谢谢你的帮助!

You can use SessionName.ofProjectEnvironmentUserSessionName and it receives the environment name just as the REST api does.您可以使用SessionName.ofProjectEnvironmentUserSessionName并像 REST api 一样接收环境名称。

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

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