Skip to content

Commit 8166820

Browse files
committed
feat: make ui work
1 parent ac9b2c4 commit 8166820

File tree

5 files changed

+50
-10
lines changed

5 files changed

+50
-10
lines changed

backend/src/main/resources/application-ollama.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ document-token-limit=150
33
embedding-token-limit=500
44
spring.liquibase.change-log=classpath:/dbchangelog/db.changelog-master-ollama.xml
55
# sql model for free production use with clause that fine tuned values have to be published.
6-
#spring.ai.ollama.chat.model=sqlcoder:15b
6+
#spring.ai.ollama.chat.model=sqlcoder:70b-alpha-q6_K
77
# falcon model config free production use
88
#spring.ai.ollama.chat.model=falcon:40b
99
# beluga model config only for non production/commercial use

frontend/src/angular/src/app/doc-search/doc-search.component.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@
3535
<div class="spinner-container">
3636
<div class="spinner-box">
3737
<mat-spinner></mat-spinner>
38-
<div i18n="@@docSearchWorking">The AI is working on the answer.</div>
39-
<div i18n="@@docSearchBePatient">Please be patient. {{ (msWorking / 1000) | number: '1.3'}} sec.</div>
38+
<div i18n="@@searchWorking">The AI is working on the answer.</div>
39+
<div i18n="@@searchBePatient">Please be patient. {{ (msWorking / 1000) | number: '1.3'}} sec.</div>
4040
</div>
4141
</div>
4242
}
4343
@if(requestFailed) {
44-
<h2 class="error-msg" i18n="@@docSearchRequestFailed">Ai Request Failed. Please try again.</h2>
44+
<h2 class="error-msg" i18n="@@searchRequestFailed">Ai Request Failed. Please try again.</h2>
4545
}
4646
@for(searchResultStr of searchResult?.resultStrings; track searchResult?.resultStrings) {
4747
<div>
4848
<ul>
49-
<li i18n="@@docSearchResultDocument">Result Document:</li>
49+
<li i18n="@@searchResultDocument">Result Document:</li>
5050
<ul>
5151
<li i18n="@@link">Link: <a mat-button href="/rest/document/content/{{!!searchResult && searchResult.documents[$index].id}}" target="_blank">{{!!searchResult && searchResult.documents[$index].documentName}}</a></li>
5252
<li>{{searchResultStr}}</li>

frontend/src/angular/src/app/table-search/table-search.component.html

+14-4
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,24 @@
2929
<div class="spinner-container">
3030
<div class="spinner-box">
3131
<mat-spinner></mat-spinner>
32-
<div i18n="@@docSearchWorking">The AI is working on the answer.</div>
33-
<div i18n="@@docSearchBePatient">Please be patient. {{ (msWorking / 1000) | number: '1.3'}} sec.</div>
32+
<div i18n="@@searchWorking">The AI is working on the answer.</div>
33+
<div i18n="@@searchBePatient">Please be patient. {{ (msWorking / 1000) | number: '1.3'}} sec.</div>
3434
</div>
3535
</div>
3636
}
3737
@if(requestFailed) {
38-
<h2 class="error-msg" i18n="@@docSearchRequestFailed">Ai Request Failed. Please try again.</h2>
38+
<h2 class="error-msg" i18n="@@searchRequestFailed">Ai Request Failed. Please try again.</h2>
3939
}
4040
@if(searchResult && searchResult.resultList?.length) {
41-
{{ searchResult | json }}
41+
<table mat-table [dataSource]="columnData">
42+
43+
<ng-container *ngFor="let disCol of columnNames" matColumnDef="{{disCol}}">
44+
<th mat-header-cell *matHeaderCellDef>{{disCol}}</th>
45+
<td mat-cell *matCellDef="let element">{{element.get(disCol)}}</td>
46+
</ng-container>
47+
48+
49+
<tr mat-header-row *matHeaderRowDef="columnNames"></tr>
50+
<tr mat-row *matRowDef="let row; columns: columnNames"></tr>
51+
</table>
4252
}

frontend/src/angular/src/app/table-search/table-search.component.ts

+28-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ export class TableSearchComponent {
3939
protected requestFailed = false;
4040
protected msWorking = 0;
4141
protected searchResult: TableSearch | null = null;
42+
protected columnData: Map<string,string>[] = [];
43+
protected columnNames = new Set<string>();
4244
private repeatSub: Subscription | null = null;
45+
//private myJson = '{"question":"show the artworks name and the name of the museum that have the style Realism and the subject of portraits","resultList":[{"1_name":"Portrait of Margaret in Skating Costume","2_name":"Philadelphia Museum of Art"},{"1_name":"Portrait of Mary Adeline Williams","2_name":"Philadelphia Museum of Art"},{"1_name":"Portrait of a Little Girl","2_name":"Philadelphia Museum of Art"},{"1_name":"Portrait of Mrs. Frank Hamilton Cushing","2_name":"Philadelphia Museum of Art"},{"1_name":"Portrait of Walt Whitman","2_name":"Philadelphia Museum of Art"},{"1_name":"The Portrait of Miss Helen Parker","2_name":"Philadelphia Museum of Art"},{"1_name":"The Thinker, Portrait of Louis N. Kenton","2_name":"The Metropolitan Museum of Art"},{"1_name":"Portrait of a Man","2_name":"The Metropolitan Museum of Art"},{"1_name":"Portrait of a Woman (Emily Bertie Pott)","2_name":"The Metropolitan Museum of Art"},{"1_name":"Portrait of Lady Grantham","2_name":"Philadelphia Museum of Art"},{"1_name":"Portrait of Marianne Holbech","2_name":"Philadelphia Museum of Art"},{"1_name":"Portrait of Master Ward","2_name":"The Prado Museum"},{"1_name":"Madame Proudhon","2_name":"Musée d Orsay"},{"1_name":"Portrait of Mlle C. D","2_name":"Musée d Orsay"},{"1_name":"Portrait of a Man","2_name":"National Gallery of Art"},{"1_name":"Portrait of Louise-Antoinette Feuardent","2_name":"The J. Paul Getty Museum"},{"1_name":"Portrait of Frieda Schiff","2_name":"The Metropolitan Museum of Art"},{"1_name":"Portrait of Richard Palmer","2_name":"Los Angeles County Museum of Art"},{"1_name":"Marie-Yolande de Fitz-James","2_name":"Cleveland Museum Of Art"},{"1_name":"The Oboe Player, Portrait of Benjamin Sharp","2_name":"Philadelphia Museum of Art"}],"resultAmount":100}';
4346

4447
constructor(private destroyRef: DestroyRef, private router: Router, private tableService: TableService) { }
4548

@@ -61,7 +64,9 @@ export class TableSearchComponent {
6164
}))
6265
.subscribe(result => {
6366
this.searchResult = result;
64-
console.log(this.searchResult);
67+
this.columnData = !result?.resultList ? this.columnData : result.resultList;
68+
this.columnNames = this.getColumnNames(result);
69+
//console.log(this.searchResult);
6570
});
6671
}
6772

@@ -70,6 +75,28 @@ export class TableSearchComponent {
7075
}
7176

7277
protected logout(): void {
78+
//this.searchResult = JSON.parse(this.myJson) as TableSearch;
79+
//this.columnData = !this.searchResult?.resultList ? this.columnData : this.searchResult.resultList;
80+
//this.columnNames = this.getColumnNames(this.searchResult);
81+
//this.columnData.forEach(myMap => this.columnNames.forEach(myName => console.log(myMap.get(myName))));
82+
//console.log(this.columnData);
7383
console.log('logout');
7484
}
85+
86+
private getColumnNames(tableSearch: TableSearch): Set<string> {
87+
const result = new Set<string>();
88+
this.columnData = [];
89+
const myList = !tableSearch?.resultList ? [] : tableSearch.resultList;
90+
myList.forEach((value) => {
91+
//console.log(value);
92+
const myMap = new Map<string,string>();
93+
Object.entries(value).forEach((entry) => {
94+
//console.log(`${entry}`);
95+
result.add(entry[0]);
96+
myMap.set(entry[0],entry[1]);
97+
});
98+
this.columnData.push(myMap);
99+
});
100+
return result;
101+
}
75102
}

questions.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
http://localhost:8080/rest/table/search?query=show+the+artworks+name+and+the+name+of+the+museum+that+have+the+style+Realism+and+the+subject+of+Portraits
2+
http://localhost:8080/rest/table/search?query=show+the+artworks+name+and+the+name+of+the+museum+that+have+the+style+Realism
3+
http://localhost:8080/rest/table/search?query=count+the+artworks+of+the+museum+with+name+Metropolitan+Museum+of+art+that+have+the+style+Realism+and+the+subject+of+Portraits

0 commit comments

Comments
 (0)