import { StateCreator } from 'zustand';
import { AiStore } from './ai-store';
import { query } from '@/modules';
export type AiHistoryStore = {
  list: any[];
  getList: () => Promise<any>;
};
export const createAiHistoryStore: StateCreator<AiStore, [], [], AiHistoryStore> = (set, get, store) => {
  return {
    list: [],
    getList: async () => {
      const { key } = get();
      set({ loading: true });
      const res = await query.post({
        path: 'chat-session',
        key: 'list-history',
        data: { key },
      });
      if (res.success) {
        set({ list: res.data });
      }
      console.log('res', res);
    },
  };
};
