Commit Graph

1228 Commits

Author SHA1 Message Date
Laisky.Cai
099e15f98b Merge remote-tracking branch 'origin/upstream/main' 2024-03-09 01:31:04 +00:00
JustSong
cf16f44970 feat: load channel models from server 2024-03-09 02:28:23 +08:00
JustSong
bf2e26a48f feat: support claude-3 (close #1080, close #1094) 2024-03-09 01:12:47 +08:00
Laisky.Cai
577ec90736 fix: Initialize transport object, set timeouts, and add IdleTimeout config
- Introduced idle connection timeout for HTTP client transport
- Implemented custom timeout for HTTP client when `RelayTimeout` is 0
- Set ImpatientHTTPClient timeout to 5 seconds
- Added new config variable `IdleTimeout` with default value of 30 seconds
- Utilized shared transport object for all HTTP clients in relay/util package
2024-03-08 12:58:05 +00:00
Laisky.Cai
758378e45a fix: Improve Image Generation Request Handling and Error Messaging
- Implemented error messages with request details and request parameter validation for image requests
- Added URL logic and Azure channel support for image generation requests
- Integrated quota management and updated quota usage logging for image generation requests
- Mapped original model names to mapped model names and unmarshalled image responses into a struct for further processing
2024-03-08 03:42:58 +00:00
Laisky.Cai
cad6f9d3ba fix: Improve quota consumption and logging in relay controller
- Modify `PostConsumeQuota` function in `common.go` to check if `totalQuota` is less than 0 and add error logging
- Update log content in `RecordConsumeLog` function of `common.go` to include model ratio and group ratio
- Change the method of calculating user used quota and request count in `UpdateUserUsedQuotaAndRequestCount` function of `common.go`
- Implement calculation of `completionRatio` and update `quota` calculation based on `completionRatio` in `postConsumeQuota` function of `helper.go`
- Implement error handling for `model.PostConsumeTokenQuota` and `model.CacheUpdateUserQuota` in `helper.go`
- Update `UserUsedQuota` and `ChannelUsedQuota` with new `quota` value in `helper.go`
2024-03-08 03:22:29 +00:00
Laisky.Cai
849920b91f fix: Improve error handling and add checks in relay.go
- Refactor error handling in `relay.go` using the `errors` package
- Implement specific error handling for `specific_channel_id` in `shouldRetry` function
- Add checks for various status codes (`StatusTooManyRequests`, `Status5xx`, `Status2xx`) in `Relay` function
- Improve code quality by adding missing imports (`io`, `net/http`) in `relay.go`
2024-03-08 02:32:47 +00: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
bcd5cf3d5f refactor: Refactor: Improve Anthropic event stream response handling
- Move `scanner.Split` instantiation to a new function
- Introduce a new regular expression to extract data from the response
- Utilize regular expressions to pre-process the event stream
2024-03-05 08:17:14 +00:00
Laisky.Cai
fdde066252 Refactor: Anthropic model response proto update
- Refactor content response

- Update channel adaptor to support `claude_model`
- Remove `null` stop reasons from content responses
- Add logging for error responses
- Change content start, ping, and message delta types to return true
- Set stop reason to end turn when response does not include a stop reason
- Set content response stop reason to null
- Add error handling for unmarshalling stream responses
- Rename `Completion` to `Text` in type definitions and `StopReason` to `Delta.StopReason`
- Count tokens in the `Delta.Text` field of the response instead of `Completion`
- Remove `Model` from the full text response
- Trim \r from incoming data
2024-03-05 05:05:57 +00:00
Laisky.Cai
c8713a0212 feat: SimplifyAnthropicRequest
- Remove `N` parameter from Anthropic request
- Append system messages from Claude to the `System` field instead of sending them as separate messages
2024-03-05 03:54:59 +00:00
Laisky.Cai
bb8755bc98 refactor: Refactor: Consolidate Anthropic model requests into GeneralOpenAIRequest
- Refactor Anthropic adapter to work with the new Anthropic API and model requests
- Remove the default value for `MaxTokensToSample`
- Set `MaxTokens` to 500 instead of 1000000
- Use `system` messages as the system prompt instead of the first message
2024-03-05 03:38:26 +00:00
Laisky.Cai
fb23ea0c9a fix: Remove Anthropic channel
- Remove Discord Antropic Hackathon Announcement.
2024-03-05 01:20:27 +00:00
Laisky.Cai
003ec2eabc fix: Switch default Adaptor from Anthropic to OpenAI
- Switch the default Adaptor from Anthropic to OpenAI
2024-03-05 01:15:52 +00:00
Laisky.Cai
b1a7e197b7 fix: Log request URL for non-ok status codes
- Refactor: Log full request URL in case of non-ok response
- Fix: URIScheme invalid model in proton-go
2024-03-05 01:08:44 +00:00
Laisky.Cai
cb6cb66646 Merge remote-tracking branch 'origin/upstream/main' 2024-03-05 01:02:35 +00:00
Laisky.Cai
f9df8eaa63 feat: Migrate to Anthropic Message API
- Migrate to Anthropic Message API
2024-03-05 00:58:52 +00:00
Laisky.Cai
75d2055e03 docs: Implement a function to get completion ratio
- Implement retrieval for the completion ratio of a given model
2024-03-04 02:54:44 +00:00
momomobinx
4fb22ad4ce
feat: support third part models of baidu (#1046)
百度千帆平台上的第三方大模型调用
2024-03-03 23:50:28 +08:00
JustSong
95cfb8e8c9 fix: using the first available model if default model is not found (close #1021) 2024-03-03 22:58:41 +08:00
JustSong
c6ace985c2 fix: set missing ali parameters (close #1028) 2024-03-03 22:51:01 +08:00
JustSong
10a926b8f3 feat: only use the top priority when first retry (#1048) 2024-03-03 22:16:34 +08:00
JustSong
2df877a352 feat: switch priority when retry (close #1048) 2024-03-03 22:14:07 +08:00
JustSong
9d8967f7d3 feat: support Mistral's models now (close #1051) 2024-03-03 21:46:45 +08:00
JustSong
b35f3523d3 feat: add gemini model alias (close #1064) 2024-03-03 21:03:04 +08:00
JustSong
82e916b5ff fix: fix azure test (close #1069) 2024-03-03 20:51:28 +08:00
JustSong
de18d6fe16 refactor: refactor image relay (close #1068) 2024-03-03 19:30:11 +08:00
Laisky.Cai
359fc6aa18 fix: Hide free quota display for zero quotas
- Remove the quota display for Zero quotas
- Parse the `const quotaPerUnit` once
2024-03-02 02:09:01 +00:00
Laisky.Cai
5bdf577b0e fix: Enhance logs table with sorting, quotas, and UI improvements
- Improve LogsTable functionality for admin users.
- Add quota calculation column.
- Display quotas in the summary header.
2024-03-02 01:17:03 +00:00
Laisky.Cai
a7c43ab248 fix: display issue for quota
- DRY up `LogsTable.js` codebase
- Fix formatting in `LogsTable.js`
- Display 'free' for a 0 quota instead of empty string
2024-03-02 01:10:59 +00:00
Laisky.Cai
268690219e fix: Rename limit to cost and allow for 0 limit
- Rename `额度` column to `费用`
- Allow for a quota to be 0.
- If the quota is 0, return 'free'
2024-03-02 00:59:22 +00:00
JustSong
1d0b7fb5ae feat: support chatglm-4 (close #1045, close #952, close #952, close #943) 2024-03-02 03:05:25 +08:00
JustSong
f9490bb72e fix: able to use updated default ratio 2024-03-02 01:32:04 +08:00
JustSong
76467285e8 docs: update readme 2024-03-02 01:25:21 +08:00
JustSong
df1fd9aa81 feat: support minimax's models now (close #354) 2024-03-02 01:24:28 +08:00
JustSong
614c2e0442 feat: support baichuan's models now (close #1057) 2024-03-02 00:55:48 +08:00
JustSong
eac6a0b9aa fix: fix version is blank 2024-03-02 00:03:29 +08:00
Laisky.Cai
06350ae5a2 fix: Refactor: Remove Quota Consumption Logic When Quota is 0
- Remove quota consumption logic when quota is 0
- Improve logging of quota usage when quota is greater than 0
- Reduce noise in logs when quota is 0
2024-03-01 14:00:50 +00:00
Laisky.Cai
2989686ace fix: Refactor: Migrate Distributor logging to ratio metrics
- Log a ratio for each channel in the context
- Initialize `minimalRatio` to -1 instead of 0
2024-03-01 13:55:21 +00:00
Laisky.Cai
dbe3930a8c fix: Switch to channel-ratio
- Use channel ratios instead of group ratios in all applicable places
- Start using the lowest channel ratio of the specified channel's groups
2024-03-01 13:49:23 +00:00
Laisky.Cai
ba827b95e3 revert: Rework text model logic and update dependencies
- Rewrite model name for relay text
- Simplify logic and move logging statements
- Remove a check that filtered out models by model-mapping
- Remove abilities for the model mapping
- Lower numeric tolerance for test files
2024-03-01 02:14:32 +00:00
Laisky.Cai
c849292621 fix 2024-02-29 09:11:01 +00:00
Laisky.Cai
1a036d977e Merge branch 'patch/model-mapping' 2024-02-29 09:05:13 +00:00
Laisky.Cai
90a039d325 fix: #1054 Add model mapping to abilities
- Update Abilities model to include model mapping key
- Parse model mapping in Channel model and filter models by model mapping in Update function
2024-02-29 09:04:04 +00:00
Laisky.Cai
6ee7281a0a feat: Map channel model changes to ability mappings
Fix: Add model mappings to a channel's abilities

- Add model mappings to a channel's abilities.
- Add model mapping unit tests.
2024-02-29 06:55:55 +00:00
Laisky.Cai
3da0f62055 fix: Improve error handling and logging in channel update abilities
- Improve error handling in `UpdateAbilities()` method
- Log model name change request to the mapped model
2024-02-29 06:44:31 +00:00
Laisky.Cai
4625a0b97d chore: Upgrade dependencies of GoWebProd
- Add GoWebProd libraries for UUID version 7, various utilities, xxHash calculation, sets, and more.
- Update various libraries for improved file system monitoring, deques, JSON handling, logging, stubbing, and comparison.
- Log supported models when initializing channel cache and remove duplicates.
2024-02-29 06:29:03 +00:00
Laisky.Cai
a94a3f5b36 Merge remote-tracking branch 'origin/upstream/main' 2024-02-27 01:09:14 +00:00
JustSong
b747cdbc6f fix: fix getAndValidateTextRequest failed: unexpected end of JSON input (close #1043) 2024-02-26 22:52:16 +08:00
JustSong
6b27d6659a fix: add role for ChatCompletionsStreamResponseChoice.Delta 2024-02-25 19:49:22 +08:00