Implemented Sentence-Transformer (Setup, Backend & Frontend) => downloading custom torch wheel to not pull gpu packages

This commit is contained in:
Kazgatari
2026-06-12 12:10:47 +02:00
parent ecc6aabfa3
commit bca5bf74bf
12 changed files with 1250 additions and 27 deletions
@@ -11,6 +11,13 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatIconModule } from '@angular/material/icon';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { TopicsService } from '../../api/api/topics.service';
import { Subject, of } from 'rxjs';
import {
debounceTime,
distinctUntilChanged,
switchMap,
catchError,
} from 'rxjs/operators';
export interface TopicItem {
id: string;
@@ -79,7 +86,54 @@ export class TopicHierarchyComponent implements OnInit {
expandedFields = new Set<string>();
expandedSubfields = new Set<string>();
constructor(private topicsService: TopicsService) {}
private readonly searchSubject = new Subject<string>();
constructor(private topicsService: TopicsService) {
this.searchSubject
.pipe(
debounceTime(300),
distinctUntilChanged(),
switchMap((query) => {
if (!query) {
this.filteredFlatTopics = [];
return of({ results: [] });
}
this.loading.set(true);
return this.topicsService.vectorSearchTopics(query, 50).pipe(
catchError((err) => {
console.error('Error in semantic topic search:', err);
// Fallback to local filtering
const q = query.toLowerCase();
this.filteredFlatTopics = this.flatTopics.filter(
(t) =>
t.name.toLowerCase().includes(q) ||
t.path.toLowerCase().includes(q),
);
return of({ results: [] });
}),
);
}),
)
.subscribe((response) => {
this.loading.set(false);
if (response && response.results) {
this.filteredFlatTopics = response.results.map((topic) => {
const parts = [];
if (topic.domain?.display_name)
parts.push(topic.domain.display_name);
if (topic.field?.display_name) parts.push(topic.field.display_name);
if (topic.subfield?.display_name)
parts.push(topic.subfield.display_name);
return {
id: topic.id || '',
name: topic.display_name || '',
path:
parts.length > 0 ? parts.join(' > ') : topic.description || '',
};
});
}
});
}
ngOnInit(): void {
this.topicsService.getTopicHierarchy().subscribe({
@@ -121,12 +175,7 @@ export class TopicHierarchyComponent implements OnInit {
this.filteredFlatTopics = [];
return;
}
const query = this.searchQuery.toLowerCase();
this.filteredFlatTopics = this.flatTopics.filter(
(t) =>
t.name.toLowerCase().includes(query) ||
t.path.toLowerCase().includes(query),
);
this.searchSubject.next(this.searchQuery);
}
toggleTopic(name: string): void {