-
Notifications
You must be signed in to change notification settings - Fork 17
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 #66 from boldare/feat/vision
feat(assistant): changed default model to 4o && vision support (images)
- Loading branch information
Showing
65 changed files
with
949 additions
and
148 deletions.
There are no files selected for viewing
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
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; | ||
} |
16 changes: 8 additions & 8 deletions
16
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
@if (isAudioEnabled && message) { | ||
<span class="chat-audio" [ngClass]="'chat-audio--' + message.role"> | ||
@if(!isStarted) { | ||
<mat-icon (click)="speech()">play_circle</mat-icon> | ||
} @else { | ||
<mat-icon (click)="pause()">pause_circle</mat-icon> | ||
} | ||
</span> | ||
@if (isAudioEnabled && message && (message | messageText)) { | ||
<span class="chat-audio" [ngClass]="'chat-audio--' + message.role"> | ||
@if (!isStarted) { | ||
<mat-icon (click)="speech()">play_circle</mat-icon> | ||
} @else { | ||
<mat-icon (click)="pause()">pause_circle</mat-icon> | ||
} | ||
</span> | ||
} |
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
31 changes: 22 additions & 9 deletions
31
apps/spa/src/app/components/chat/chat-message/chat-message.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,12 +1,25 @@ | ||
@if (message) { @if (message.role === 'assistant') { | ||
<ai-chat-avatar></ai-chat-avatar> | ||
} | ||
@if (message) { | ||
@if (message.role === 'assistant') { | ||
<ai-chat-avatar></ai-chat-avatar> | ||
} | ||
|
||
<div class="chat-message"> | ||
<span markdown [data]="message.content"></span> | ||
<div class="chat-message"> | ||
@for (msg of message.content; track $index) { | ||
@if (msg.type === 'text') { | ||
<span markdown [data]="msg | annotation"></span> | ||
} | ||
<ai-chat-annotations [message]="msg" /> | ||
} | ||
|
||
@if (message.role !== chatRole.System) { | ||
<ai-chat-audio [message]="message"></ai-chat-audio> | ||
} | ||
</div> | ||
@if ((message | messageImageFile).length) { | ||
<div class="chat-message__file"> | ||
@for ( | ||
image of message | messageImageFile; | ||
track image.image_file.file_id | ||
) { | ||
<div>File ID: {{ image.image_file.file_id }}</div> | ||
} | ||
</div> | ||
} | ||
</div> | ||
} |
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
8 changes: 4 additions & 4 deletions
8
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<div class="messages"> | ||
@for (message of initialMessages.concat(messages); track message) { | ||
@for (message of initialMessages.concat(messages); track message.id) { | ||
<span #item> | ||
<ai-chat-message [message]="message"></ai-chat-message> | ||
</span> | ||
<ai-chat-message [message]="message"></ai-chat-message> | ||
</span> | ||
} @empty { | ||
<ai-chat-tips [tips]="tips" (tipSelected$)="tipSelected$.emit($event)" /> | ||
<ai-chat-tips [tips]="tips" (tipSelected$)="tipSelected$.emit($event)" /> | ||
} | ||
<ai-chat-typing [isTyping]="isTyping"></ai-chat-typing> | ||
</div> |
Oops, something went wrong.