123
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
* Validates: Requirements 12.1-12.6
|
* Validates: Requirements 12.1-12.6
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import api, { API_BASE_URL } from './api';
|
import api, { API_BASE_URL, getAccessToken } from './api';
|
||||||
import type {
|
import type {
|
||||||
ApiResponse,
|
ApiResponse,
|
||||||
AIChatResponse,
|
AIChatResponse,
|
||||||
@@ -105,7 +105,7 @@ export async function streamChatMessage(
|
|||||||
onChunk: (text: string) => void
|
onChunk: (text: string) => void
|
||||||
): Promise<AIChatResponse> {
|
): Promise<AIChatResponse> {
|
||||||
const sessionId = existingSessionId || getSessionId();
|
const sessionId = existingSessionId || getSessionId();
|
||||||
const token = localStorage.getItem('token'); // Assuming auth token is stored here
|
const token = getAccessToken(); // Get token from shared storage logic
|
||||||
|
|
||||||
// Use fetch directly for streaming support
|
// Use fetch directly for streaming support
|
||||||
const response = await fetch(`${API_BASE_URL}/ai/chat/stream`, {
|
const response = await fetch(`${API_BASE_URL}/ai/chat/stream`, {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ interface RequestOptions extends RequestInit {
|
|||||||
/**
|
/**
|
||||||
* Get access token from storage
|
* Get access token from storage
|
||||||
*/
|
*/
|
||||||
function getAccessToken(): string | null {
|
export function getAccessToken(): string | null {
|
||||||
return localStorage.getItem(ACCESS_TOKEN_KEY);
|
return localStorage.getItem(ACCESS_TOKEN_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user