separa rutas api

This commit is contained in:
Sebarocks 2025-08-02 00:57:39 -04:00
parent 2f74e893bf
commit f7b23a3cec
2 changed files with 9 additions and 9 deletions

View file

@ -1,7 +1,7 @@
const API = import.meta.env.CHATSBT_API_URL || "";
export async function createChat(model = "qwen/qwen3-235b-a22b-2507") {
const r = await fetch(`${API}/chats`, {
const r = await fetch(`${API}/api/chats`, {
method: "POST",
body: JSON.stringify({ model }),
});
@ -9,7 +9,7 @@ export async function createChat(model = "qwen/qwen3-235b-a22b-2507") {
}
export async function sendUserMessage(chatId, text, model = "") {
const r = await fetch(`${API}/chats/${chatId}/messages`, {
const r = await fetch(`${API}/api/chats/${chatId}/messages`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ message: text, model }),
@ -19,13 +19,13 @@ export async function sendUserMessage(chatId, text, model = "") {
export function openStream(chatId, messageId) {
return new EventSource(
`${API}/chats/${chatId}/stream?message_id=${messageId}`,
`${API}/api/chats/${chatId}/stream?message_id=${messageId}`,
);
}
export async function fetchModels() {
try {
const response = await fetch(`${API}/models`);
const response = await fetch(`${API}/api/models`);
const data = await response.json();
return data.models || [];
} catch (error) {