You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by sm...@apache.org on 2020/04/26 12:55:01 UTC
[incubator-nlpcraft-ui] branch master updated: Better formatting of
model responses.
This is an automated email from the ASF dual-hosted git repository.
smakov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft-ui.git
The following commit(s) were added to refs/heads/master by this push:
new b48d6ca Better formatting of model responses.
b48d6ca is described below
commit b48d6ca45d694a7d4d55f0123b88e7e87446bd7c
Author: smakov <sm...@apache.org>
AuthorDate: Sun Apr 26 15:53:44 2020 +0300
Better formatting of model responses.
---
src/app/ui/main/chat/chat.component.html | 2 +-
src/app/ui/main/chat/chat.component.ts | 41 +++++++++++++++++++++++---------
2 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/src/app/ui/main/chat/chat.component.html b/src/app/ui/main/chat/chat.component.html
index 56e32e1..a82a74e 100644
--- a/src/app/ui/main/chat/chat.component.html
+++ b/src/app/ui/main/chat/chat.component.html
@@ -53,7 +53,7 @@
<ng-container *ngIf="s.status === 'QRY_READY'">
<div *ngIf="s.resBody" class="alert alert-success">
- {{s.resBody}}
+ <pre>{{s.resBody | json}}</pre>
</div>
<div *ngIf="s.error" class="alert alert-danger">
{{s.error}}
diff --git a/src/app/ui/main/chat/chat.component.ts b/src/app/ui/main/chat/chat.component.ts
index 19bea1e..a08f55e 100644
--- a/src/app/ui/main/chat/chat.component.ts
+++ b/src/app/ui/main/chat/chat.component.ts
@@ -31,8 +31,9 @@ export class ChatComponent implements OnInit, OnDestroy {
selectedQuery: NlpQueryState
- @Input()
- allProbes: NlpProbe[]
+ private _allProbes: NlpProbe[]
+
+ private _allModels: NlpModel[]
private _states: NlpQueryState[]
@@ -46,6 +47,26 @@ export class ChatComponent implements OnInit, OnDestroy {
// No-op.
}
+ get allProbes(): NlpProbe[] {
+ return this._allProbes
+ }
+
+ @Input()
+ set allProbes(value: NlpProbe[]) {
+ if (!this.isSameProbeList(value)) {
+ this._allProbes = value
+
+ // Update models cache.
+ this._allModels = []
+
+ value.forEach(p => {
+ p.models.forEach(m => {
+ this._allModels.push(m)
+ })
+ })
+ }
+ }
+
get states(): NlpQueryState[] {
return this._states
}
@@ -75,15 +96,7 @@ export class ChatComponent implements OnInit, OnDestroy {
}
allModels(): NlpModel[] {
- const allModels: NlpModel[] = []
-
- this.allProbes.forEach(p => {
- p.models.forEach(m => {
- allModels.push(m)
- })
- })
-
- return allModels
+ return this._allModels
}
async checkStatus() {
@@ -156,4 +169,10 @@ export class ChatComponent implements OnInit, OnDestroy {
this.selectedModelId = this.allModels()[0].id
}
}
+
+ private isSameProbeList(value: NlpProbe[]) {
+ // Using JSON comparison for simplicity.
+ // Should replace with comparison by probe ID for better performance.
+ return JSON.stringify(value) === JSON.stringify(this._allProbes)
+ }
}