import { createAsyncThunk } from '@reduxjs/toolkit';

/**
 * Fetch Ask IA HTML
 */
export const getAskIa = createAsyncThunk(
  'askIa/getAskIa',
  async (): Promise<string> => {
    try {
      const response = await fetch(
        'https://api.sage-ai-studio.webexpr.dev/api/embed/ask?mode=light&lang=fr&productSlug=sage100dataven&model=mistral-small',
        {
          headers: {
            'Authorization': 'Bearer sk_live_bef70d4dd6bc671fd815d21104d5dce8'
          }
        }
      );
      
      if (!response.ok) {
        throw new Error('Erreur de chargement du dashboard');
      }
      
      return await response.text();
    } catch (err) {
      throw err;
    }
  }
);