new(core.gbapp): More NLP automation.
This commit is contained in:
parent
9e67049698
commit
666c765503
2 changed files with 68 additions and 2 deletions
|
@ -704,7 +704,46 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
req.headers.set('Content-Type', 'application/json');
|
req.headers.set('Content-Type', 'application/json');
|
||||||
req.headers.set('accept-language', '*');
|
req.headers.set('accept-language', '*');
|
||||||
req.headers.set('Ocp-Apim-Subscription-Key', nlpAuthoringKey);
|
req.headers.set('Ocp-Apim-Subscription-Key', nlpAuthoringKey);
|
||||||
req.body = data;
|
req.body = JSON.stringify(data);
|
||||||
|
const httpClient = new ServiceClient();
|
||||||
|
|
||||||
|
return await httpClient.sendRequest(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async trainNLP(
|
||||||
|
location: string,
|
||||||
|
nlpAppId: string,
|
||||||
|
nlpAuthoringKey: string,
|
||||||
|
) {
|
||||||
|
|
||||||
|
const req = new WebResource();
|
||||||
|
req.method = 'POST';
|
||||||
|
req.url = `https://${location}.api.cognitive.microsoft.com/luis/api/v2.0/apps/${nlpAppId}/versions/0.1/train`;
|
||||||
|
req.headers.set('Content-Type', 'application/json');
|
||||||
|
req.headers.set('accept-language', '*');
|
||||||
|
req.headers.set('Ocp-Apim-Subscription-Key', nlpAuthoringKey);
|
||||||
|
const httpClient = new ServiceClient();
|
||||||
|
|
||||||
|
return await httpClient.sendRequest(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async publishNLP(
|
||||||
|
location: string,
|
||||||
|
nlpAppId: string,
|
||||||
|
nlpAuthoringKey: string,
|
||||||
|
) {
|
||||||
|
const body = {
|
||||||
|
versionId: "0.1",
|
||||||
|
isStaging: false,
|
||||||
|
directVersionPublish: false
|
||||||
|
}
|
||||||
|
const req = new WebResource();
|
||||||
|
req.method = 'POST';
|
||||||
|
req.url = `https://${location}.api.cognitive.microsoft.com/luis/api/v2.0/apps/${nlpAppId}/publish`;
|
||||||
|
req.headers.set('Content-Type', 'application/json');
|
||||||
|
req.headers.set('accept-language', '*');
|
||||||
|
req.headers.set('Ocp-Apim-Subscription-Key', nlpAuthoringKey);
|
||||||
|
req.body = body;
|
||||||
const httpClient = new ServiceClient();
|
const httpClient = new ServiceClient();
|
||||||
|
|
||||||
return await httpClient.sendRequest(req);
|
return await httpClient.sendRequest(req);
|
||||||
|
|
|
@ -245,6 +245,33 @@ export class GBDeployer implements IGBDeployer {
|
||||||
return await this.core.saveInstance(instance);
|
return await this.core.saveInstance(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async publishNLP(instance: IGBInstance): Promise<void> {
|
||||||
|
const service = new AzureDeployerService(this);
|
||||||
|
const res = await service.publishNLP(
|
||||||
|
instance.cloudLocation,
|
||||||
|
instance.nlpAppId,
|
||||||
|
instance.nlpAuthoringKey,
|
||||||
|
);
|
||||||
|
if(res.status !== 200) throw res.bodyAsText;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async trainNLP(instance: IGBInstance): Promise<void> {
|
||||||
|
const service = new AzureDeployerService(this);
|
||||||
|
const res = await service.trainNLP(
|
||||||
|
instance.cloudLocation,
|
||||||
|
instance.nlpAppId,
|
||||||
|
instance.nlpAuthoringKey,
|
||||||
|
);
|
||||||
|
if(res.status !== 200) throw res.bodyAsText;
|
||||||
|
let sleep = ms => {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
setTimeout(resolve, ms);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
sleep(5000);
|
||||||
|
}
|
||||||
|
|
||||||
public async refreshNLPEntity(instance: IGBInstance, listName, listData): Promise<void> {
|
public async refreshNLPEntity(instance: IGBInstance, listName, listData): Promise<void> {
|
||||||
const service = new AzureDeployerService(this);
|
const service = new AzureDeployerService(this);
|
||||||
const res = await service.refreshEntityList(
|
const res = await service.refreshEntityList(
|
||||||
|
@ -255,7 +282,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
listData
|
listData
|
||||||
);
|
);
|
||||||
if(res.status !== 200) throw res.bodyAsText;
|
if(res.status !== 200) throw res.bodyAsText;
|
||||||
GBLog.info(res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue