-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from boldare/feat/annotations
Annotations - displaying numbers and dedicated section in the message
- Loading branch information
Showing
49 changed files
with
675 additions
and
195 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
apps/spa/src/app/components/chat/chat-annotation/chat-annotation.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div | ||
class="annotation" | ||
(mouseover)="showDetails()" | ||
[matTooltip]="fileDetails ? fileDetails.filename : 'Reading data...'" | ||
matTooltipPosition="above"> | ||
[{{ index }}] | ||
</div> |
9 changes: 9 additions & 0 deletions
9
apps/spa/src/app/components/chat/chat-annotation/chat-annotation.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@import 'settings'; | ||
|
||
.annotation { | ||
cursor: pointer; | ||
|
||
&:hover { | ||
background-color: rgba(0, 0, 0, 0.15); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
apps/spa/src/app/components/chat/chat-annotation/chat-annotation.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ChatAnnotationComponent } from './chat-annotation.component'; | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
|
||
describe('ChatAnnotationComponent', () => { | ||
let component: ChatAnnotationComponent; | ||
let fixture: ComponentFixture<ChatAnnotationComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ChatAnnotationComponent, HttpClientTestingModule], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ChatAnnotationComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
apps/spa/src/app/components/chat/chat-annotation/chat-annotation.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { MatTooltip } from '@angular/material/tooltip'; | ||
import { Annotation } from 'openai/resources/beta/threads'; | ||
import { ChatClientService } from '../../../modules/+chat/shared/chat-client.service'; | ||
import { FileObject } from 'openai/resources'; | ||
import { isFileCitation } from '../../../pipes/annotation.pipe'; | ||
import { take } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'ai-chat-annotation', | ||
standalone: true, | ||
templateUrl: './chat-annotation.component.html', | ||
styleUrl: './chat-annotation.component.scss', | ||
imports: [MatTooltip], | ||
}) | ||
export class ChatAnnotationComponent { | ||
@Input() annotation!: Annotation; | ||
@Input() index = 1; | ||
fileDetails!: FileObject; | ||
|
||
get fileId(): string { | ||
return isFileCitation(this.annotation) | ||
? this.annotation.file_citation.file_id | ||
: this.annotation.file_path.file_id; | ||
} | ||
|
||
constructor(private chatClientService: ChatClientService) {} | ||
|
||
showDetails() { | ||
if (!this.fileId || !!this.fileDetails) { | ||
return; | ||
} | ||
|
||
this.chatClientService | ||
.retriveFile(this.fileId) | ||
.pipe(take(1)) | ||
.subscribe(details => (this.fileDetails = details)); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
apps/spa/src/app/components/chat/chat-annotations/chat-annotations.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@if (message && message.type === 'text' && message.text.annotations.length) { | ||
<div class="title">Annotations:</div> | ||
<div class="content"> | ||
@for ( | ||
annotation of message.text.annotations; | ||
track annotation.text + $index | ||
) { | ||
<ai-chat-annotation [annotation]="annotation" [index]="$index + 1"> | ||
[{{ $index + 1 }}] | ||
</ai-chat-annotation> | ||
} | ||
</div> | ||
} |
33 changes: 33 additions & 0 deletions
33
apps/spa/src/app/components/chat/chat-annotations/chat-annotations.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@import 'settings'; | ||
|
||
:host { | ||
display: flex; | ||
align-items: baseline; | ||
gap: $size-2; | ||
border-top: 1px dashed var(--color-grey-500); | ||
margin-top: $size-3; | ||
padding-top: $size-3; | ||
font-size: 12px; | ||
|
||
&:empty { | ||
display: none; | ||
} | ||
} | ||
|
||
.title { | ||
font-weight: 500; | ||
} | ||
|
||
.content { | ||
display: flex; | ||
gap: $size-1; | ||
margin-top: $size-2; | ||
} | ||
|
||
.annotation { | ||
cursor: pointer; | ||
|
||
&:hover { | ||
background-color: rgba(0, 0, 0, 0.15); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
apps/spa/src/app/components/chat/chat-annotations/chat-annotations.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { MarkdownModule } from 'ngx-markdown'; | ||
import { ChatAnnotationsComponent } from './chat-annotations.component'; | ||
|
||
describe('ChatAnnotationsComponent', () => { | ||
let component: ChatAnnotationsComponent; | ||
let fixture: ComponentFixture<ChatAnnotationsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ChatAnnotationsComponent, MarkdownModule.forRoot()], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ChatAnnotationsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
apps/spa/src/app/components/chat/chat-annotations/chat-annotations.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { MatTooltip } from '@angular/material/tooltip'; | ||
import { MessageContent } from 'openai/resources/beta/threads'; | ||
import { ChatAnnotationComponent } from '../chat-annotation/chat-annotation.component'; | ||
|
||
@Component({ | ||
selector: 'ai-chat-annotations', | ||
standalone: true, | ||
templateUrl: './chat-annotations.component.html', | ||
styleUrl: './chat-annotations.component.scss', | ||
imports: [MatTooltip, ChatAnnotationComponent], | ||
}) | ||
export class ChatAnnotationsComponent { | ||
@Input() message!: MessageContent; | ||
} |
2 changes: 1 addition & 1 deletion
2
apps/spa/src/app/components/chat/chat-audio/chat-audio.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/spa/src/app/components/chat/chat-message/chat-message.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/spa/src/app/components/chat/chat-messages/chat-messages.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
apps/spa/src/app/components/chat/chat-tips/chat-tips.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
@for (tip of tips; track tip) { | ||
<ai-chat-tip (click)="tipSelected$.emit(tip)"> | ||
{{ tip }} | ||
</ai-chat-tip> | ||
@for (tip of tips; track $index) { | ||
<ai-chat-tip (click)="tipSelected$.emit(tip)"> | ||
{{ tip }} | ||
</ai-chat-tip> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/spa/src/app/components/controls/message-content/message-content.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.