-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(assistant): changed default model to 4o && vision support (images)
- Loading branch information
1 parent
ce390cf
commit 8e937d4
Showing
30 changed files
with
373 additions
and
52 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
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 (getMessageText) { | ||
<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
29 changes: 20 additions & 9 deletions
29
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,23 @@ | ||
@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"> | ||
@if (messageText) { | ||
<span markdown [data]="messageText"></span> | ||
} | ||
|
||
@if (message.role !== chatRole.System) { | ||
<ai-chat-audio [message]="message"></ai-chat-audio> | ||
} | ||
</div> | ||
@if (message.role !== chatRole.System) { | ||
<ai-chat-audio [message]="message"></ai-chat-audio> | ||
} | ||
|
||
@if (messageImage.length) { | ||
<div class="chat-message__file"> | ||
@for (image of messageImage; track messageImage) { | ||
<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
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
6 changes: 3 additions & 3 deletions
6
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) { | ||
<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> |
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
25 changes: 25 additions & 0 deletions
25
apps/spa/src/app/components/controls/message-content/message-content.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,25 @@ | ||
<ai-control-item | ||
aiFiles | ||
(click)="input.click()" | ||
(drop$)="addFiles($event)" | ||
[files]="imageContentList$()" | ||
[isDisabled]="isDisabled"> | ||
<ai-control-icon>image</ai-control-icon> | ||
|
||
@if (imageContentList$().length) { | ||
<span class="files__counter" (click)="clear($event)"> | ||
<span class="files__number"> | ||
{{ imageContentList$().length }} | ||
</span> | ||
<mat-icon class="files__clear"> close </mat-icon> | ||
</span> | ||
} | ||
|
||
<input | ||
class="files__input" | ||
type="file" | ||
(change)="onFileChange($event)" | ||
multiple | ||
accept=".jpeg, .jpg, .gif, .png" | ||
#input /> | ||
</ai-control-item> |
37 changes: 37 additions & 0 deletions
37
apps/spa/src/app/components/controls/message-content/message-content.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,37 @@ | ||
.files__input { | ||
display: none; | ||
} | ||
|
||
.files__counter { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
background-color: var(--color-red-500); | ||
border-radius: 50%; | ||
min-width: 20px; | ||
min-height: 20px; | ||
text-align: center; | ||
font-size: 10px; | ||
color: var(--color-white); | ||
position: absolute; | ||
right: 2px; | ||
top: 2px; | ||
z-index: 1; | ||
|
||
&:hover { | ||
.files__number { | ||
display: none; | ||
} | ||
|
||
.files__clear { | ||
display: block; | ||
} | ||
} | ||
} | ||
|
||
.files__clear { | ||
display: none; | ||
font-size: 12px; | ||
height: 12px; | ||
width: 12px; | ||
} |
23 changes: 23 additions & 0 deletions
23
apps/spa/src/app/components/controls/message-content/message-content.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,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { MessageContentComponent } from './message-content.component'; | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
|
||
describe('MessageContentComponent', () => { | ||
let component: MessageContentComponent; | ||
let fixture: ComponentFixture<MessageContentComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [MessageContentComponent, HttpClientTestingModule], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(MessageContentComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
46 changes: 46 additions & 0 deletions
46
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Component, ElementRef, Input, ViewChild } from '@angular/core'; | ||
import { MatIcon } from '@angular/material/icon'; | ||
import { toSignal } from '@angular/core/rxjs-interop'; | ||
import { MessageContentService } from './message-content.service'; | ||
import { ControlItemComponent } from '../control-item/control-item.component'; | ||
import { ControlIconComponent } from '../control-icon/control-icon.component'; | ||
import { AiFilesDirective } from '../files/files.directive'; | ||
|
||
@Component({ | ||
selector: 'ai-message-content', | ||
standalone: true, | ||
imports: [ | ||
MatIcon, | ||
AiFilesDirective, | ||
ControlItemComponent, | ||
ControlIconComponent, | ||
], | ||
templateUrl: './message-content.component.html', | ||
styleUrl: './message-content.component.scss', | ||
}) | ||
export class MessageContentComponent { | ||
@ViewChild('input') input!: ElementRef<HTMLInputElement>; | ||
@Input() isDisabled = false; | ||
imageContentList$ = toSignal(this.messageContentService.data$, { | ||
initialValue: [], | ||
}); | ||
|
||
constructor(private readonly messageContentService: MessageContentService) {} | ||
|
||
addFiles(files: FileList) { | ||
this.messageContentService.add(files); | ||
} | ||
|
||
onFileChange(event: Event) { | ||
const input = event.target as HTMLInputElement; | ||
this.addFiles(input.files as FileList); | ||
} | ||
|
||
clear(event: Event): void { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
this.input.nativeElement.files = null; | ||
this.input.nativeElement.value = ''; | ||
this.messageContentService.clear(); | ||
} | ||
} |
Oops, something went wrong.