19
bizmatch/src/app/services/ai.service.ts
Normal file
19
bizmatch/src/app/services/ai.service.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import { BusinessListingCriteria, CommercialPropertyListingCriteria, UserListingCriteria } from '../../../../bizmatch-server/src/models/main.model';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AiService {
|
||||
private apiBaseUrl = environment.apiBaseUrl;
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
async generateAiReponse(prompt: string): Promise<BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria> {
|
||||
let headers = new HttpHeaders();
|
||||
headers = headers.set('X-Hide-Loading', 'true');
|
||||
return lastValueFrom(this.http.post<BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria>(`${this.apiBaseUrl}/bizmatch/ai`, { query: prompt }, { headers }));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { lastValueFrom, Observable } from 'rxjs';
|
||||
import { BehaviorSubject, lastValueFrom, Observable } from 'rxjs';
|
||||
import urlcat from 'urlcat';
|
||||
import { User } from '../../../../bizmatch-server/src/models/db.model';
|
||||
import { ResponseUsersArray, StatesResult, UserListingCriteria } from '../../../../bizmatch-server/src/models/main.model';
|
||||
@@ -12,8 +12,14 @@ import { environment } from '../../environments/environment';
|
||||
export class UserService {
|
||||
private apiBaseUrl = environment.apiBaseUrl;
|
||||
|
||||
private userSource = new BehaviorSubject<User>(undefined);
|
||||
currentUser = this.userSource.asObservable();
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
changeUser(user: User) {
|
||||
this.userSource.next(user);
|
||||
}
|
||||
// -----------------------------
|
||||
// DB services
|
||||
// -----------------------------
|
||||
|
||||
Reference in New Issue
Block a user