feat(assets): add DeepSeek assistant with streaming results and voice input
This commit is contained in:
@@ -6,7 +6,7 @@ export function setTokenGetter(fn: () => string | null) {
|
||||
tokenGetter = fn;
|
||||
}
|
||||
|
||||
export async function fetchJson<T>(url: string, options?: RequestInit): Promise<T> {
|
||||
export async function fetchAuthenticated(url: string, options?: RequestInit): Promise<Response> {
|
||||
const token = tokenGetter();
|
||||
const res = await fetch(url, {
|
||||
...options,
|
||||
@@ -19,6 +19,11 @@ export async function fetchJson<T>(url: string, options?: RequestInit): Promise<
|
||||
window.dispatchEvent(new CustomEvent('auth:unauthorized'));
|
||||
throw new Error('Unauthorized');
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function fetchJson<T>(url: string, options?: RequestInit): Promise<T> {
|
||||
const res = await fetchAuthenticated(url, options);
|
||||
if (!res.ok) throw new Error(`API error: ${res.status} ${res.statusText}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user