Commit Graph

42 Commits

Author SHA1 Message Date
Laisky.Cai
7047d9605e Merge commit '3d149fedf45472eff92910324974c762fc37dad6' 2024-04-21 15:05:13 +00:00
JustSong
3d149fedf4 chore: do not hardcode context key 2024-04-21 19:43:23 +08:00
Laisky.Cai
c735b9b4d3 Merge commit '2369025842b828ac38f4427fd1ebab8d03b1fe7f' 2024-04-20 01:07:29 +00:00
Laisky.Cai
9cb3a06dd5 Merge commit 'af543ab8ecb6827cbbc151c2cff181cdc3286274' 2024-04-08 01:13:00 +00:00
JustSong
3af4649b52 fix: only check model when request path in whitelist 2024-04-06 20:42:35 +08:00
Laisky.Cai
50bab08496 Refactor codebase, introduce relaymode package, update constants and improve consistency
- Refactor constant definitions and organization
- Clean up package level variables and functions
- Introduce new `relaymode` and `apitype` packages for constant definitions
- Refactor and simplify code in several packages including `openai`, `relay/channel/baidu`, `relay/util`, `relay/controller`, `relay/channeltype`
- Add helper functions in `relay/channeltype` package to convert channel type constants to corresponding API type constants
- Remove deprecated functions such as `ResponseText2Usage` from `relay/channel/openai/helper.go`
- Modify code in `relay/util/validation.go` and related files to use new `validator.ValidateTextRequest` function
- Rename `util` package to `relaymode` and update related imports in several packages
2024-04-06 05:18:04 +00:00
JustSong
0b8ccb94eb chore: reorganize common package 2024-04-06 02:03:59 +08:00
JustSong
348adc2b02 feat: able to set multiple subnets 2024-04-05 17:25:28 +08:00
JustSong
840ef80d94 fix: do not try to parse model when requesting /v1/models (close #1272) 2024-04-05 12:50:31 +08:00
JustSong
c49778c254 feat: now able to limit ip range for token now (close #1275) 2024-04-05 10:09:16 +08:00
JustSong
8b9813d63b feat: /v1/models now only return available models 2024-04-04 02:44:59 +08:00
JustSong
dc7aaf2de5 feat: able to set model limitation for token (close #178) 2024-04-04 02:08:18 +08:00
Laisky.Cai
72501cb746 Merge remote-tracking branch 'origin/upstream/main' 2024-03-11 09:32:11 +00:00
JustSong
6ebc99460e fix: add user to blacklist when it's banned or deleted, and make deletion soft (close #473, close #791) 2024-03-10 15:56:19 +08:00
Laisky.Cai
ba9b258a4b feat: Enhance security and fix bugs in authentication
- Update the minimum access token length from 16 to 32
- Prevent spam by introducing policies and detecting user agents
- Add an authorization header to the login response
- Use base64 to decode the session secret and generate a random one if not set
2024-03-05 13:07:07 +00:00
Laisky.Cai
a94a3f5b36 Merge remote-tracking branch 'origin/upstream/main' 2024-02-27 01:09:14 +00:00
JustSong
565ea58e68 feat: built in retry supported (close #1036, close #770) 2024-02-25 19:01:49 +08:00
Laisky.Cai
10cbe63c0d Merge remote-tracking branch 'origin/upstream/main' 2024-01-28 13:44:16 +00:00
JustSong
2cd1a78203 chore: update module name 2024-01-28 19:38:58 +08:00
Laisky.Cai
7239b3386a Merge remote-tracking branch 'origin/upstream/main' 2023-12-12 06:00:29 +00:00
igophper
d85e356b6e
refactor: remove consumeQuota related logic (#738)
* feat: 删除relay-text中的consumeQuota变量

该变量始终为true,可以删除

* chore: remove useless code

---------

Co-authored-by: JustSong <songquanpeng@foxmail.com>
2023-11-24 20:42:29 +08:00
Laisky.Cai
b3ebf069e2 feat: change default token prefix to laisky-
- Remove prefix "laisky-" from the variable "key" in [middleware/auth.go]
- Modify error message from "用户已被封禁" to "用户已被禁用" in [middleware/auth.go]
- Remove check for "consumeQuota" when request URL starts with "/v1/models" in [middleware/auth.go]
- Add ability for admin users to set "channelId" in context in [middleware/auth.go]
- Update URL and key for `ama` and `opencat` links, and key format for `url` in links in [web/src/components/TokensTable.js]
- Update URL for `nextUrl` in [web/src/components/TokensTable.js]
- Change variable names and improve search function for token names in [web/src/components/TokensTable.js]
- Add delete confirmation popup, copy and open link buttons, sorting functionality for column header, and loading state in [web/src/components/TokensTable.js]
- Update pagination to load more data in [web/src/components/TokensTable.js]
- Update rendering of token information, including quota and timestamp in [web/src/components/TokensTable.js]
2023-10-19 09:01:03 +00:00
JustSong
f9b748c2ca chore: add MEMORY_CACHE_ENABLED env variable 2023-09-29 11:38:27 +08:00
JustSong
42451d9d02 refactor: update logging related logic 2023-09-17 15:39:46 +08:00
JustSong
621eb91b46 chore: pass through error out 2023-09-03 21:31:58 +08:00
JustSong
8a4cd403fd fix: fix http status code (close #193) 2023-06-23 22:59:44 +08:00
JustSong
6d961064d2 feat: do not access database before response return (close #158) 2023-06-21 17:26:26 +08:00
Miniers
46c43396d8
feat: add token name to log (#172)
* add token name to log

* chore: update expression

---------

Co-authored-by: JustSong <songquanpeng@foxmail.com>
2023-06-17 14:56:03 +08:00
JustSong
73d5e0f283 feat: support dummy sk- prefix for token (#82) 2023-05-17 17:04:06 +08:00
JustSong
8afdc56b11 fix: fix quota not consuming 2023-05-16 13:29:22 +08:00
JustSong
bffee4e91d fix: fix /v1/models not working (close #66) 2023-05-15 15:33:34 +08:00
JustSong
4a0e81fe83 fix: fix quota not consumed 2023-05-14 20:36:28 +08:00
JustSong
053bb85a1c feat: now use token as the unit of quota (close #33) 2023-04-28 16:58:55 +08:00
JustSong
601fa5cea8 refactor: use quota instead of times 2023-04-28 14:57:20 +08:00
JustSong
54b1e4adef fix: check user status when validating token (#23) 2023-04-27 15:05:33 +08:00
JustSong
8c305dc1bc feat: able to manage system vai access token (close #12) 2023-04-26 20:54:39 +08:00
JustSong
4f8cbd643d fix: prevent common user from specifying channel id (#12) 2023-04-26 14:49:27 +08:00
JustSong
f16a2a5645 feat: redirect to login page if login expired (close #18) 2023-04-26 11:42:56 +08:00
JustSong
109736cc05 fix: only reduce remain times when request /v1/chat/completions (close #15)
BREAKING CHANGE: now remain_times is -1 doesn't mean unlimited times anymore!
2023-04-26 10:45:34 +08:00
JustSong
852af57c03 Relay done but not working 2023-04-23 18:24:11 +08:00
JustSong
539eac217f Rename to One API 2023-04-22 21:14:09 +08:00
JustSong
ab1f8a2bf4
Initial commit 2023-04-22 20:39:27 +08:00