diff --git a/web/src/components/table/users/modals/UserModelRateLimitSection.jsx b/web/src/components/table/users/modals/UserModelRateLimitSection.jsx index 6e169be..fe81b33 100644 --- a/web/src/components/table/users/modals/UserModelRateLimitSection.jsx +++ b/web/src/components/table/users/modals/UserModelRateLimitSection.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useState, useRef } from 'react'; import { useTranslation } from 'react-i18next'; -import { userRateLimitApi, showError, showSuccess } from '../../../../helpers'; +import { API, userRateLimitApi, showError, showSuccess } from '../../../../helpers'; import { Button, Table, @@ -19,6 +19,7 @@ const UserModelRateLimitSection = ({ userId }) => { const [limits, setLimits] = useState([]); const [loading, setLoading] = useState(false); const [addModalVisible, setAddModalVisible] = useState(false); + const [modelOptions, setModelOptions] = useState([]); const formApiRef = useRef(null); const loadLimits = async () => { @@ -42,6 +43,21 @@ const UserModelRateLimitSection = ({ userId }) => { loadLimits(); }, [userId]); + useEffect(() => { + const loadModels = async () => { + try { + const res = await API.get('/api/channel/models'); + const { success, data } = res.data; + if (success && Array.isArray(data)) { + setModelOptions(data.map((m) => ({ label: m.id, value: m.id }))); + } + } catch (e) { + // ignore + } + }; + loadModels(); + }, []); + const saveLimits = async (newLimits) => { try { const res = await userRateLimitApi.set(userId, newLimits); @@ -165,11 +181,16 @@ const UserModelRateLimitSection = ({ userId }) => { getFormApi={(api) => (formApiRef.current = api)} onSubmit={handleAdd} > -