import { inject, Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { API_URL } from '../core/tokens/api-urls'; import { ChatCollection, MessageCollection, MessageResponse, ChatResponse } from './chat.types'; @Injectable({ providedIn: 'root', }) export class ChatService { private http = inject(HttpClient); private apiUrl = inject(API_URL); public newChat() { return this.http.post(`${this.apiUrl}/chats`, {}); } public sendMessage(id: string, message: string) { return this.http.post(`${this.apiUrl}/chats/${id}/messages`, { prompt: message, }); } public getMessages(id: string, page: number = 1) { return this.http.get(`${this.apiUrl}/chats/${id}/messages?page=${page}`); } public getChats() { return this.http.get(`${this.apiUrl}/chats`); } }