Commit Graph

52 Commits

Author SHA1 Message Date
Laisky.Cai
33f3400c12 fix: update Prompt type in GeneralOpenAIRequest and adjust related logic in ConvertCompletionsRequest 2025-02-10 02:11:53 +00:00
Laisky.Cai
5e351bc02a fix: whisper model billing
- Refactor model name handling across multiple controllers to improve clarity and maintainability.
- Enhance error logging and handling for better debugging and request processing robustness.
- Update pricing models in accordance with new calculations, ensuring accuracy in the billing logic.
2025-01-26 08:02:55 +00:00
Laisky.Cai
21041ec7ac Merge branch 'main' into pr/Laisky/25 2025-01-17 07:45:29 +00:00
Laisky.Cai
bdb695895f fix: enhance token usage calculations and improve logging in OpenAI handler 2025-01-14 13:37:00 +00:00
Laisky.Cai
9730ac3bb5 feat: support gpt-4o-audio 2025-01-14 06:38:07 +00:00
Laisky.Cai
09bfd61f2e refactor: replace Laisky/errors with pkg/errors for improved error handling 2024-12-20 03:06:09 +00:00
Laisky.Cai
3cb1b4fd35 fix: enhance request body handling for OpenAI API type in RelayTextHelper 2024-11-27 06:38:24 +00:00
Laisky.Cai
79257420a8 fix: update request handling to enforce usage inclusion and remove unused import 2024-11-27 06:25:15 +00:00
Laisky.Cai
1f103202a6 fix: refactor postConsumeQuota function to return quota and update user request cost handling 2024-11-22 03:12:09 +00:00
Laisky.Cai
082cfbe574 Merge remote-tracking branch 'origin/upstream/main' 2024-11-20 02:09:28 +00:00
JustSong
6ab87f8a08 feat: add warning in log when system prompt is reset
Some checks failed
CI / Unit tests (push) Has been cancelled
CI / commit_lint (push) Has been cancelled
2024-11-10 17:18:46 +08:00
JustSong
6eb0770a89 feat: support set system prompt for channel (close #1920) 2024-11-10 14:53:34 +08:00
JustSong
92cd46d64f feat: able to use ENFORCE_INCLUDE_USAGE to enforce include usage in response
Some checks are pending
CI / Unit tests (push) Waiting to run
CI / commit_lint (push) Waiting to run
2024-11-10 00:36:08 +08:00
Laisky.Cai
4c96688e7c Merge remote-tracking branch 'origin/upstream/main' 2024-07-23 01:14:23 +00:00
igophper
39383e5532
fix: support embedding models for doubao (#1662)
Fixes #1594
2024-07-22 22:38:50 +08:00
Laisky.Cai
f9417d32e1 Merge remote-tracking branch 'origin/upstream/main' 2024-07-09 06:28:06 +00:00
Qiying Wang
720fe2dfeb
feat: refactor AwsClaude to Aws to support both llama3 and claude (#1601)
* feat: refactor AwsClaude to Aws to support both llama3 and claude

* fix: aws llama3 ratio
2024-07-06 13:19:41 +08:00
Laisky.Cai
c524e60d9f Merge remote-tracking branch 'origin/upstream/main' 2024-05-29 06:12:37 +00:00
Laisky.Cai
ca23dd9a97 Merge commit '1c2654320e5b6268b13b6efca40ce37a523d032b' 2024-04-28 01:53:31 +00:00
JustSong
007906216d feat: support DeepL's model (close #1126) 2024-04-27 13:37:22 +08:00
JustSong
9026ec7510 feat: support cloudflare now 2024-04-26 23:05:48 +08:00
Laisky.Cai
84a6817314 feat: able to fetch every request's cost 2024-04-23 00:58:25 +00:00
Laisky.Cai
c735b9b4d3 Merge commit '2369025842b828ac38f4427fd1ebab8d03b1fe7f' 2024-04-20 01:07:29 +00:00
JustSong
2369025842 fix: use prefix to match more json response 2024-04-20 01:15:33 +08:00
Laisky.Cai
fc9a784950
feat: support aws bedrockruntime claude3 (#1328)
* feat: support aws bedrockruntime claude3

closes #622, closes #749, closes #1300

* fix: convert to aws claude model id

* fix: Update AWS adapter to handle stream completions and calculate usage metrics

Based on the file summaries provided, here are the important bullet points for the commit message:

- Add functionality to handle stream completion events from AWS in the relay/adaptor/aws/main.go file
- Marshall AWS response to OpenAI format and calculate usage metrics in the same file
- Implement a custom render function for streaming events in the same file
- Improve error handling for JSON unmarshalling and marshalling errors in the same file

* fix: Implement AWS handler with usage tracking and error handling

- Implemented streaming response handling for AWS handler
- Set response content type to text/event-stream
- Added error handling for failed marshaling/unmarshaling
- Updated return values to include `relaymodel.ErrorWithStatusCode` and `relaymodel.Usage`
- Improved error handling and response formatting for AWS adaptor

* fix: Refactor AWS Adapter for Improved Model Mapping and Error Handling

* Refactor AWS adapter to improve model management
  - Replace hardcoded model list in `adapter.go` with a function to get models from `awsModelIDMap`
  - Update `GetModelList` function to return model list directly
  - Add `GetChannelName` function to get channel name from `Adaptor` object
* Improve error handling and code organization in main.go
  - Replace switch statement with a map to map AWS model IDs to OpenAI model IDs
  - Return an error if the model is not found in the map
  - Use a single return statement instead of wrapping multiple return statements in the `awsModelID` function
  - Add a new error message for when the model is not found in the map in the `Handler` function

* fix: bug fix

* chore: change variable name & package

* chore: change variable name

* perf: update config related code

---------

Co-authored-by: JustSong <songquanpeng@foxmail.com>
2024-04-20 00:40:47 +08:00
Laisky.Cai
4e1bfe4879 feat: support aws bedrockruntime claude3
closes #622, closes #749, closes #1300
2024-04-18 02:52:26 +00: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
f586ae0ad8 chore: remove helper & util subpackage for relay 2024-04-06 01:50:12 +08:00
JustSong
24ed170e7b chore: reorganize adaptor related package 2024-04-06 01:36:48 +08:00
JustSong
f70506eac1 chore: reorganize relay related package 2024-04-06 01:31:44 +08:00
JustSong
8f4d78e24d chore: reorganize billing related package 2024-04-06 01:26:48 +08:00
JustSong
2ab7d25a80 chore: reorganize helper related package 2024-04-06 01:02:35 +08:00
JustSong
f9d914873f chore: reorganize constant related package 2024-04-06 00:44:33 +08:00
Laisky.Cai
41afad713e Merge remote-tracking branch 'origin/upstream/main' 2024-03-15 09:49:49 +00:00
JustSong
79d0cd378a fix: fix baidu system prompt (close #1079) 2024-03-13 22:56:54 +08:00
Laisky.Cai
d953da1ff2 fix: Upgrade error handling to errors/v2 package and refactor error messages.
- Refactor error handling using `errors/v2` package for improved error management and formatting
- Implement changes in relay/controller/text.go, controller/channel-test.go, controller/relay.go, common/message/email.go, relay/controller/audio.go, controller/channel-billing.go, relay/controller/helper.go, relay/channel/common.go, relay/channel/minimax/main.go, and common/message/main.go
- Add package imports and update package paths for better code organization
- Replace hardcoded strings with error variables for consistency and readability
- Implement secure methods for generating unique Message-ID
- Improve SMTP handling and authentication in email.go
- Update response handling and error messages for better user experience
- Add constant checks and modify functions based on imageRequest parameters in helper.go
- Use `http.NewRequest` instead of `fmt.Fprint` for improved request handling in relay/channel/common.go
- Update error handling and formatting for better consistency across all files
2024-03-12 06:43:54 +00:00
Laisky.Cai
72501cb746 Merge remote-tracking branch 'origin/upstream/main' 2024-03-11 09:32:11 +00:00
JustSong
8388aa537f chore: able to search channel now 2024-03-10 14:59:57 +08: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
JustSong
614c2e0442 feat: support baichuan's models now (close #1057) 2024-03-02 00:55:48 +08: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
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
3c95e1bb0d refactor: Refactor text controller logic
- Move the initialization of `requestBody` to a separate if block.
- Add a comment to indicate that `requestBodyBytes` is created for debugging use.
2024-02-22 03:25:45 +00:00
Laisky.Cai
b9972e0aa4 style: Upgrade relay controller text package
- Refactoring of the Text controller.
2024-02-22 03:09:46 +00:00
JustSong
bd888f2eb7 fix: fix prompt token is zero (close #1023) 2024-02-21 22:19:42 +08:00
JustSong
1aa374ccfb refactor: use adaptor to do relay & test 2024-02-18 00:15:31 +08:00
JustSong
2cd1a78203 chore: update module name 2024-01-28 19:38:58 +08:00
JustSong
b9d3cb0c45 refactor: split RelayTextHelper function 2024-01-28 19:14:46 +08:00