Skip to content

Commit

Permalink
Implement fix for the chat auto-selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Mutugiii committed Oct 3, 2024
1 parent 020a0ea commit f95bac3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app/chat/chat.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<span class="titlebar" i18n>AI Chat</span>
<span class="toolbar-fill"></span>
<mat-button-toggle-group *ngIf="displayToggle; else textDisplay" [(ngModel)]="activeService" (change)="toggleAIService()">
<mat-button-toggle *ngFor="let service of aiServices" [value]="service.value" i18n>{{service.name}}</mat-button-toggle>
<mat-button-toggle *ngFor="let service of aiServices" [value]="service.model" i18n>{{service.name}}</mat-button-toggle>
</mat-button-toggle-group>
<ng-template #textDisplay>
<span i18n>{{activeService}}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class CoursesStepViewComponent implements OnInit, OnDestroy {
});
this.resourcesService.requestResourcesUpdate(this.parent);
this.chatService.listAIProviders().subscribe((providers) => {
this.isOpenai = providers.some(provider => provider.value === 'openai');
this.isOpenai = providers.some(provider => provider.model === 'openai');
});
}

Expand Down
12 changes: 6 additions & 6 deletions src/app/shared/chat.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { BehaviorSubject, Observable, Subject, of } from 'rxjs';
import { catchError, map, shareReplay } from 'rxjs/operators';
import { catchError, map } from 'rxjs/operators';

import { environment } from '../../environments/environment';
import { findDocuments, inSelector } from '../shared/mangoQueries';
import { CouchService } from '../shared/couchdb.service';
import { AIServices } from '../chat/chat.model';
import { AIServices, AIProvider } from '../chat/chat.model';

@Injectable({
providedIn: 'root'
Expand All @@ -22,7 +22,7 @@ import { AIServices } from '../chat/chat.model';
private newChatSelected: Subject<void> = new Subject<void>();
private toggleAIService = new Subject<string>();
private selectedConversationIdSubject = new BehaviorSubject<object | null>(null);
private aiProvidersSubject = new BehaviorSubject<Array<{ name: string; value: string }>>([]);
private aiProvidersSubject = new BehaviorSubject<Array<AIProvider>>([]);

newChatAdded$ = this.newChatAdded.asObservable();
newChatSelected$ = this.newChatSelected.asObservable();
Expand Down Expand Up @@ -61,8 +61,8 @@ import { AIServices } from '../chat/chat.model';
map((services: AIServices) => {
if (services) {
return Object.entries(services)
.filter(([ _, value ]) => value === true)
.map(([ key ]) => ({ name: key, value: key }));
.filter(([ _, model ]) => model === true)
.map(([ key ]) => ({ name: key, model: key }));
} else {
return [];
}
Expand All @@ -73,7 +73,7 @@ import { AIServices } from '../chat/chat.model';
});
}

listAIProviders(): Observable<Array<{ name: string; value: string }>> {
listAIProviders(): Observable<Array<AIProvider>> {
return this.aiProviders$;
}

Expand Down

0 comments on commit f95bac3

Please sign in to comment.