enabling login btw users

This commit is contained in:
2025-10-25 09:30:54 -04:00
parent 6b616137d3
commit 29ac724d50
25 changed files with 1172 additions and 227 deletions

View File

@@ -0,0 +1,61 @@
import { userService } from "./userService";
interface Message {
id: string;
text: string;
speaker: "user" | "simba";
created_at: string;
}
interface Conversation {
id: string;
name: string;
messages: Message[];
created_at: string;
updated_at: string;
}
interface QueryRequest {
query: string;
}
interface QueryResponse {
response: string;
}
class ConversationService {
private baseUrl = "/api";
async sendQuery(query: string): Promise<QueryResponse> {
const response = await userService.fetchWithRefreshToken(
`${this.baseUrl}/query`,
{
method: "POST",
body: JSON.stringify({ query }),
},
);
if (!response.ok) {
throw new Error("Failed to send query");
}
return await response.json();
}
async getMessages(): Promise<Conversation> {
const response = await userService.fetchWithRefreshToken(
`${this.baseUrl}/messages`,
{
method: "GET",
},
);
if (!response.ok) {
throw new Error("Failed to fetch messages");
}
return await response.json();
}
}
export const conversationService = new ConversationService();