- Update `golang.org/x/image` and `golang.org/x/net` to their latest versions.
- Convert the request to the correct request type based on the model.
- Handle the request and response differently depending on the API type.
- Handle all the cases in `relayMode` and `apiType` switch in a consistent manner.
- Retire AI Proxy Library API call pattern.
- Add new cases (Zhipu, Ali, Tencent, Gemini) to generalize the conversion and handling of requests.
- Log the requests if conservation audit is enabled.
- Add support for getting base64-encoded images via openAI's image_url.
- Add `context` as a parameter for the function `LogError`.
- Handle the error from `image.GetImageFromUrl` by logging it.
- Convert the role to `user` if it is `system` and add a dummy model message to make Gemini happy.
```
- Refactor relay-text controller to improve readability and maintainability
- Optimize database queries for improved performance
- Update error handling to provide more informative messages
```
- Remove unused import `gorm.io/gorm/logger` from relay-text controller
- Refactor and consolidate related functions in relay-text controller
- Improve error handling in relay-text controller
- Refactor relay-text controller to improve performance and readability
- Update function signatures for better consistency
- Optimize error handling for improved reliability
* fest: Add Google Gemini Pro, fix#810
* fest: Add tooling to Gemini; Add OpenAI-like system prompt to Gemini
* refactor: removing unused if statement
* fest: Add dummy model message for system message in gemini model
* chore: update implementation
---------
Co-authored-by: JustSong <songquanpeng@foxmail.com>
- Add function `CountVisionImageToken` to count vision image tokens
- Modify function `imageSize` to handle different image types
- Add function `countVisonTokenMessages` to count tokens in vision messages
- Add logic to count tokens for different types of vision messages in `countVisonTokenMessages`
- Add tokens for role and name in `countVisonTokenMessages`
- Update total token count calculation in `countVisonTokenMessages` to include image tokens and message tokens
- Add constant values for tokens per message and tokens per name in `countVisonTokenMessages`
- Modify the error message on line 12 to include the JSON string that failed to unmarshal
- Added new dependencies: `github.com/fsnotify/fsnotify v1.4.9`, `github.com/go-playground/assert/v2 v2.2.0`, `github.com/nxadm/tail v1.4.8`, `github.com/onsi/ginkgo v1.16.5`, `github.com/onsi/gomega v1.18.1`, `golang.org/x/net v0.10.0`, `gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7`
- Updated dependencies: `github.com/gin-gonic/gin` from v1.9.0 to v2.0.0, `golang.org/x/net` from v0.17.0 to v0.10.0
- Removed dependencies: `github.com/golang-jwt/jwt v3.2.2+incompatible`, `github.com/gorilla/websocket v1.5.1`
- Updated Go version from `1.18` to `1.21`
- Made various modifications and refactoring in the code:
- Added new struct `VisionMessage` with fields `Role`, `Content`, and `Name`
- Added constants for certain types
- Added methods and error handling to handle different message types
- Modified existing struct and methods to accommodate changes
- Removed unused imports
* fix: change quota calc code (close#599)
Use float64 during calc and do math.Ceil after calc. This will result in the quota being used slightly more than the official standard, but it will be guaranteed that it will not be less.
* chore: remove blank line
---------
Co-authored-by: JustSong <songquanpeng@foxmail.com>