-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: oilbeater <[email protected]>
- Loading branch information
Showing
8 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# 🔄 Fallback | ||
|
||
Malacca's fallback is designed to protect your API from upstream API failures. When the upstream API fails, Malacca will automatically fallback to the CF Workers AI. By default it will fallback to the `@cf/meta/llama-3.1-8b-instruct` model. | ||
|
||
You can customize the fallback logical to fit your needs or change to another model by modifying the `src/middlewares/fallback.ts` file. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# 🛡️ Guard | ||
|
||
Malacca's guard is designed to protect your API from inappropriate content. It is a powerful tool that can be used to protect your API from a variety of attacks, including but not limited to: | ||
|
||
- **Content Filtering**: The guard can be used to filter out content that is inappropriate or offensive. | ||
- **Abuse Detection**: The guard can be used to detect and prevent abuse of your API by bad actors. | ||
|
||
You can customize the guards logic by modifying the guards middleware in `src/middlewares/guards.ts`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# 🚦 Rate Limiting | ||
|
||
Rate Rate limiting is a crucial feature that helps protect your application from potential abuse or unintended overuse. By implementing rate limits, you can: | ||
|
||
- 🛡️ Prevent excessive requests from a single user or IP address | ||
- 💰 Control costs by limiting the number of API calls | ||
- 🚀 Ensure fair usage and maintain service quality for all users | ||
- 🔒 Mitigate potential Denial of Service (DoS) attacks | ||
|
||
Malacca's rate limiting feature relies on the [Cloudflare Workers Rate Limiting](https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/) feature. It allows you to set limits on the number of requests a user can make within a specified time frame. | ||
|
||
By default it limit by the virtual key and allows 100 requests per minute. | ||
|
||
You can modify the limit tokens count in `wrangler.toml` file, for example: | ||
|
||
```toml | ||
[[unsafe.bindings]] | ||
name = "MY_RATE_LIMITER" | ||
type = "ratelimit" | ||
namespace_id = "1001" | ||
simple = { limit = 100, period = 60 } | ||
``` | ||
|
||
And uou can also modify the rate limiting logic by modifying the rate limiting middleware in `src/middlewares/rateLimiter.ts`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters