Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat aiproxy admin panel and user client phase II #5299

Merged
merged 50 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
5634b3c
init admin layout
HUAHUAI23 Nov 14, 2024
48224ec
add admin sidebar
HUAHUAI23 Nov 14, 2024
2994704
change dir name
HUAHUAI23 Nov 14, 2024
9ead06a
ok
HUAHUAI23 Nov 14, 2024
6677043
ok
HUAHUAI23 Nov 14, 2024
4ac5b0d
add select combox
HUAHUAI23 Nov 23, 2024
ca4bd3e
add dashboard
HUAHUAI23 Nov 29, 2024
7216a51
add config
HUAHUAI23 Dec 1, 2024
4372302
v1
HUAHUAI23 Dec 2, 2024
3300bc5
refactor api
HUAHUAI23 Dec 3, 2024
b2ebc5f
ok
HUAHUAI23 Dec 3, 2024
b472108
ok
HUAHUAI23 Dec 3, 2024
62e34a7
merge coin
HUAHUAI23 Dec 3, 2024
5aa9fdc
add global-config api
HUAHUAI23 Dec 4, 2024
146afb7
ok
HUAHUAI23 Dec 4, 2024
17458fa
ok
HUAHUAI23 Dec 4, 2024
e0fdc6b
ok
HUAHUAI23 Dec 4, 2024
12940b7
ok
HUAHUAI23 Dec 4, 2024
f6c54f2
ok
HUAHUAI23 Dec 5, 2024
f7d535f
ok
HUAHUAI23 Dec 5, 2024
445b2eb
ok
HUAHUAI23 Dec 5, 2024
70e6d9b
ok
HUAHUAI23 Dec 6, 2024
0b8074a
ok
HUAHUAI23 Dec 6, 2024
07bea94
ok
HUAHUAI23 Dec 6, 2024
6ac78ec
ok
HUAHUAI23 Dec 6, 2024
988e565
ok
HUAHUAI23 Dec 6, 2024
f6f976f
Merge branch 'main' into aiproxy/admin
HUAHUAI23 Dec 12, 2024
71c3b57
refact user logs
HUAHUAI23 Dec 20, 2024
0a3acb2
frontend(aiproxy): refact user logs
HUAHUAI23 Dec 20, 2024
35d21a9
Merge branch 'main' into aiproxy/admin
HUAHUAI23 Dec 20, 2024
376bc36
fix dynamic render
HUAHUAI23 Dec 20, 2024
30e3b90
add dashboard
HUAHUAI23 Dec 30, 2024
b23466c
add react echart
HUAHUAI23 Dec 30, 2024
fe3a2b9
chore
HUAHUAI23 Dec 30, 2024
fa0deb9
phase 2
HUAHUAI23 Jan 3, 2025
986a527
chore adjust ui
HUAHUAI23 Jan 8, 2025
d7d0adf
chore
HUAHUAI23 Jan 8, 2025
5535557
Merge branch 'main' into aiproxy/admin
HUAHUAI23 Jan 8, 2025
e798893
temp user realname
HUAHUAI23 Jan 23, 2025
0246651
Optimize real-name verification logic
HUAHUAI23 Feb 7, 2025
18bfede
chore
HUAHUAI23 Feb 7, 2025
0b57a72
Merge branch 'main' into aiproxy/admin
HUAHUAI23 Feb 7, 2025
3f2c8f4
chore
HUAHUAI23 Feb 7, 2025
b71e590
chore
HUAHUAI23 Feb 10, 2025
d12c28e
Merge branch 'main' into aiproxy/admin
HUAHUAI23 Feb 10, 2025
75a2c65
chore
HUAHUAI23 Feb 12, 2025
744b768
Merge branch 'main' into aiproxy/admin
HUAHUAI23 Feb 13, 2025
d859892
fix admin channel create multiple input
HUAHUAI23 Feb 14, 2025
d6f1372
Merge branch 'main' into aiproxy/admin
HUAHUAI23 Feb 20, 2025
98e749d
Add Invitation Event Popup
HUAHUAI23 Feb 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
253 changes: 252 additions & 1 deletion frontend/pnpm-lock.yaml

Large diffs are not rendered by default.

121 changes: 108 additions & 13 deletions frontend/providers/aiproxy/api/platform.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,120 @@
import { KeysSearchResponse } from '@/app/api/get-keys/route'
import { QueryParams, SearchResponse } from '@/app/api/get-logs/route'
import { QueryParams as KeysQueryParams } from '@/app/api/get-keys/route'
import { GET, POST, DELETE } from '@/utils/request'
import { ModelPrice } from '@/types/backend'
import { GET, POST, DELETE, PUT } from '@/utils/frontend/request'
import { ChannelQueryParams, GetChannelsResponse } from '@/app/api/admin/channel/route'
import { ChannelStatus, CreateChannelRequest } from '@/types/admin/channels/channelInfo'
import { ApiResp } from '@/types/api'
import { GetOptionResponse } from '@/app/api/admin/option/route'
import { BatchOptionData } from '@/types/admin/option'
import { GetEnabledModelsResponse } from '@/app/api/models/enabled/route'
import { GetTokensQueryParams, GetTokensResponse } from '@/app/api/user/token/route'
import { TokenInfo } from '@/types/user/token'
import { UserLogSearchResponse } from '@/app/api/user/log/route'
import { UserLogQueryParams } from '@/app/api/user/log/route'
import { GlobalLogQueryParams, GlobalLogSearchResponse } from '@/app/api/admin/log/route'
import { GetAllChannelEnabledModelsResponse } from '@/app/api/models/builtin/channel/route'
import { GetDefaultModelAndModeMappingResponse } from '@/app/api/models/default/route'
import { GetChannelTypeNamesResponse } from '@/app/api/admin/channel/type-name/route'
import { GroupQueryParams, GroupStatus } from '@/types/admin/group'
import { GroupSearchResponse } from '@/app/api/admin/group/route'
import { GetAllChannelResponse } from '@/app/api/admin/channel/all/route'
import { DashboardQueryParams } from '@/app/api/user/dashboard/route'
import { DashboardResponse } from '@/types/user/dashboard'
import { UserLogDetailResponse } from '@/app/api/user/log/detail/[log_id]/route'

export const initAppConfig = () =>
GET<{ aiproxyBackend: string; currencySymbol: 'shellCoin' | 'cny' | 'usd' }>(
'/api/init-app-config'
)

export const getModels = () => GET<string[]>('/api/get-models')
// <user>
export const getEnabledMode = () => GET<GetEnabledModelsResponse['data']>('/api/models/enabled')

export const getModelPrices = () => GET<ModelPrice[]>('/api/get-mode-price')
// log
export const getUserLogs = (params: UserLogQueryParams) =>
GET<UserLogSearchResponse['data']>('/api/user/log', params)

export const getLogs = (params: QueryParams) => GET<SearchResponse['data']>('/api/get-logs', params)
export const getUserLogDetail = (log_id: number) =>
GET<UserLogDetailResponse['data']>(`/api/user/log/detail/${log_id}`)

export const getKeys = (params: KeysQueryParams) =>
GET<KeysSearchResponse['data']>('/api/get-keys', params)
// token
export const getTokens = (params: GetTokensQueryParams) =>
GET<GetTokensResponse['data']>('/api/user/token', params)

export const createKey = (name: string) => POST('/api/create-key', { name })
export const createToken = (name: string) =>
POST<ApiResp<TokenInfo>['data']>('/api/user/token', { name })

export const deleteKey = (id: number) => DELETE(`/api/delete-key/${id}`)
export const deleteToken = (id: number) => DELETE(`/api/user/token/${id}`)

export const updateKey = (id: number, status: number) => POST(`/api/update-key/${id}`, { status })
export const updateToken = (id: number, status: number) =>
POST<ApiResp>(`/api/user/token/${id}`, { status: status })

// dashboard
export const getDashboardData = (params: DashboardQueryParams) =>
GET<DashboardResponse['data']>('/api/user/dashboard', params)
// ------------------------------------------------------------
// <admin>

export const getChannels = (params: ChannelQueryParams) =>
GET<GetChannelsResponse['data']>('/api/admin/channel', params)

// channel
export const createChannel = (params: CreateChannelRequest) =>
POST<ApiResp>('/api/admin/channel', params)

export const updateChannel = (params: CreateChannelRequest, id: string) =>
PUT<ApiResp>(`/api/admin/channel/${id}`, params)

export const updateChannelStatus = (id: string, status: ChannelStatus) =>
POST<ApiResp>(`/api/admin/channel/${id}/status`, { status })

export const getChannelTypeNames = () =>
GET<GetChannelTypeNamesResponse['data']>('/api/admin/channel/type-name')

export const getAllChannels = () => GET<GetAllChannelResponse['data']>('/api/admin/channel/all')

export const deleteChannel = (id: string) => DELETE(`/api/admin/channel/${id}`)

export const uploadChannels = (formData: FormData) =>
POST<ApiResp>('/api/admin/channel/upload', formData, {
headers: {
// Don't set Content-Type header here, it will be automatically set with the correct boundary
}
})

// channel built-in support models and default model default mode mapping
export const getChannelBuiltInSupportModels = () =>
GET<GetAllChannelEnabledModelsResponse['data']>('/api/models/builtin/channel')

export const getChannelDefaultModelAndDefaultModeMapping = () =>
GET<GetDefaultModelAndModeMappingResponse['data']>('/api/models/default')

// option
export const getOption = () => GET<GetOptionResponse['data']>('/api/admin/option')

export const updateOption = (params: { key: string; value: string }) =>
PUT<ApiResp>(`/api/admin/option/`, params)

export const batchOption = (params: BatchOptionData) =>
PUT<ApiResp>(`/api/admin/option/batch`, params)

export const uploadOptions = (formData: FormData) =>
POST<ApiResp>('/api/admin/option/upload', formData, {
headers: {
// Don't set Content-Type header here, it will be automatically set with the correct boundary
}
})

// log
export const getGlobalLogs = (params: GlobalLogQueryParams) =>
GET<GlobalLogSearchResponse['data']>('/api/admin/log', params)

// group
export const getGroups = (params: GroupQueryParams) =>
GET<GroupSearchResponse['data']>('/api/admin/group', params)

export const updateGroupStatus = (id: string, status: GroupStatus) =>
POST<ApiResp>(`/api/admin/group/${id}/status`, { status })

export const updateGroupQpm = (id: string, qpm: number) =>
POST<ApiResp>(`/api/admin/group/${id}/qpm`, { qpm })

export const deleteGroup = (id: string) => DELETE(`/api/admin/group/${id}`)
Loading
Loading