-import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
+import { Component, ElementRef, inject, OnInit, ViewChild } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { NavigationEnd, Router } from '@angular/router'
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'
public input: string = ''
public documentId!: number
+ private chatService: ChatService = inject(ChatService)
+ private router: Router = inject(Router)
+
@ViewChild('scrollAnchor') scrollAnchor!: ElementRef<HTMLDivElement>
@ViewChild('chatInput') chatInput!: ElementRef<HTMLInputElement>
: $localize`Ask a question about a document...`
}
- constructor(
- private chatService: ChatService,
- private router: Router
- ) {}
-
ngOnInit(): void {
this.updateDocumentId(this.router.url)
this.router.events
map((event) => (event as NavigationEnd).url)
)
.subscribe((url) => {
- console.log('URL changed:', url)
-
this.updateDocumentId(url)
})
}
HttpDownloadProgressEvent,
HttpEventType,
} from '@angular/common/http'
-import { Injectable } from '@angular/core'
+import { inject, Injectable } from '@angular/core'
import { filter, map, Observable } from 'rxjs'
import { environment } from 'src/environments/environment'
providedIn: 'root',
})
export class ChatService {
- constructor(private http: HttpClient) {}
+ private http: HttpClient = inject(HttpClient)
streamChat(documentId: number, prompt: string): Observable<string> {
return this.http