import { apiClient } from './apiClient';

export const settingsService = {
  async getVisionModels() {
    const response = await apiClient.get('/models');
    // Filter models that support vision or are of type vision
    return response.data.filter((m: any) => m.supportsVision || m.type === 'vision');
  },

  async getVisionModel() {
    const response = await apiClient.get('/v1/admin/settings');
    return { visionModelId: response.data.selectedVisionId };
  },

  async updateVisionModel(selectedVisionId: string) {
    const response = await apiClient.put('/v1/admin/settings', {
      selectedVisionId,
    });
    return response.data;
  },

  async getLanguage() {
    const response = await apiClient.get('/users/settings');
    return response.data.language;
  },

  async updateLanguage(language: string) {
    const response = await apiClient.put('/users/settings/language', {
      language,
    });
    return response.data;
  },
};