Skip to content

Commit 9f4aade

Browse files
Merge pull request #66 from boldare/feat/vision
feat(assistant): changed default model to 4o && vision support (images)
2 parents 3d52538 + c2f8eec commit 9f4aade

File tree

65 files changed

+949
-148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+949
-148
lines changed

apps/api/src/app/chat/chat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const assistantParams: AssistantCreateParams = {
66
name: '@boldare/openai-assistant',
77
instructions: `You are a chatbot assistant. Use the general knowledge to answer questions. Speak briefly and clearly.`,
88
tools: [{ type: 'code_interpreter' }, { type: 'file_search' }],
9-
model: 'gpt-4-turbo',
9+
model: 'gpt-4o',
1010
temperature: 0.05,
1111
};
1212

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div
2+
class="annotation"
3+
(mouseover)="showDetails()"
4+
[matTooltip]="fileDetails ? fileDetails.filename : 'Reading data...'"
5+
matTooltipPosition="above">
6+
[{{ index }}]
7+
</div>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@import 'settings';
2+
3+
.annotation {
4+
cursor: pointer;
5+
6+
&:hover {
7+
background-color: rgba(0, 0, 0, 0.15);
8+
}
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { ChatAnnotationComponent } from './chat-annotation.component';
3+
import { HttpClientTestingModule } from '@angular/common/http/testing';
4+
5+
describe('ChatAnnotationComponent', () => {
6+
let component: ChatAnnotationComponent;
7+
let fixture: ComponentFixture<ChatAnnotationComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [ChatAnnotationComponent, HttpClientTestingModule],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(ChatAnnotationComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it('should create', () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Component, Input } from '@angular/core';
2+
import { MatTooltip } from '@angular/material/tooltip';
3+
import { Annotation } from 'openai/resources/beta/threads';
4+
import { ChatClientService } from '../../../modules/+chat/shared/chat-client.service';
5+
import { FileObject } from 'openai/resources';
6+
import { isFileCitation } from '../../../pipes/annotation.pipe';
7+
import { take } from 'rxjs';
8+
9+
@Component({
10+
selector: 'ai-chat-annotation',
11+
standalone: true,
12+
templateUrl: './chat-annotation.component.html',
13+
styleUrl: './chat-annotation.component.scss',
14+
imports: [MatTooltip],
15+
})
16+
export class ChatAnnotationComponent {
17+
@Input() annotation!: Annotation;
18+
@Input() index = 1;
19+
fileDetails!: FileObject;
20+
21+
get fileId(): string {
22+
return isFileCitation(this.annotation)
23+
? this.annotation.file_citation.file_id
24+
: this.annotation.file_path.file_id;
25+
}
26+
27+
constructor(private chatClientService: ChatClientService) {}
28+
29+
showDetails() {
30+
if (!this.fileId || !!this.fileDetails) {
31+
return;
32+
}
33+
34+
this.chatClientService
35+
.retriveFile(this.fileId)
36+
.pipe(take(1))
37+
.subscribe(details => (this.fileDetails = details));
38+
}
39+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@if (message && message.type === 'text' && message.text.annotations.length) {
2+
<div class="title">Annotations:</div>
3+
<div class="content">
4+
@for (
5+
annotation of message.text.annotations;
6+
track annotation.text + $index
7+
) {
8+
<ai-chat-annotation [annotation]="annotation" [index]="$index + 1">
9+
[{{ $index + 1 }}]
10+
</ai-chat-annotation>
11+
}
12+
</div>
13+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@import 'settings';
2+
3+
:host {
4+
display: flex;
5+
align-items: baseline;
6+
gap: $size-2;
7+
border-top: 1px dashed var(--color-grey-500);
8+
margin-top: $size-3;
9+
padding-top: $size-3;
10+
font-size: 12px;
11+
12+
&:empty {
13+
display: none;
14+
}
15+
}
16+
17+
.title {
18+
font-weight: 500;
19+
}
20+
21+
.content {
22+
display: flex;
23+
gap: $size-1;
24+
margin-top: $size-2;
25+
}
26+
27+
.annotation {
28+
cursor: pointer;
29+
30+
&:hover {
31+
background-color: rgba(0, 0, 0, 0.15);
32+
}
33+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { MarkdownModule } from 'ngx-markdown';
3+
import { ChatAnnotationsComponent } from './chat-annotations.component';
4+
5+
describe('ChatAnnotationsComponent', () => {
6+
let component: ChatAnnotationsComponent;
7+
let fixture: ComponentFixture<ChatAnnotationsComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [ChatAnnotationsComponent, MarkdownModule.forRoot()],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(ChatAnnotationsComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it('should create', () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Component, Input } from '@angular/core';
2+
import { MatTooltip } from '@angular/material/tooltip';
3+
import { MessageContent } from 'openai/resources/beta/threads';
4+
import { ChatAnnotationComponent } from '../chat-annotation/chat-annotation.component';
5+
6+
@Component({
7+
selector: 'ai-chat-annotations',
8+
standalone: true,
9+
templateUrl: './chat-annotations.component.html',
10+
styleUrl: './chat-annotations.component.scss',
11+
imports: [MatTooltip, ChatAnnotationComponent],
12+
})
13+
export class ChatAnnotationsComponent {
14+
@Input() message!: MessageContent;
15+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
@if (isAudioEnabled && message) {
2-
<span class="chat-audio" [ngClass]="'chat-audio--' + message.role">
3-
@if(!isStarted) {
4-
<mat-icon (click)="speech()">play_circle</mat-icon>
5-
} @else {
6-
<mat-icon (click)="pause()">pause_circle</mat-icon>
7-
}
8-
</span>
1+
@if (isAudioEnabled && message && (message | messageText)) {
2+
<span class="chat-audio" [ngClass]="'chat-audio--' + message.role">
3+
@if (!isStarted) {
4+
<mat-icon (click)="speech()">play_circle</mat-icon>
5+
} @else {
6+
<mat-icon (click)="pause()">pause_circle</mat-icon>
7+
}
8+
</span>
99
}

0 commit comments

Comments
 (0)