File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ bytes = "1.9.0"
192
192
pagefind = { version = " 1.3.0" }
193
193
tl = " 0.7.8"
194
194
url = " 2.5.4"
195
+ actix-request-reply-cache = " 0.1.5"
195
196
196
197
[build-dependencies ]
197
198
dotenvy = " 0.15.7"
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ use crate::{
15
15
} ;
16
16
use actix_cors:: Cors ;
17
17
use actix_identity:: IdentityMiddleware ;
18
+ use actix_request_reply_cache:: RedisCacheMiddlewareBuilder ;
18
19
use actix_session:: { config:: PersistentSession , storage:: RedisSessionStore , SessionMiddleware } ;
19
20
use actix_web:: {
20
21
cookie:: { Key , SameSite } ,
@@ -1101,6 +1102,18 @@ pub fn main() -> std::io::Result<()> {
1101
1102
. service (
1102
1103
web:: resource ( "/message/get_tool_function_params" )
1103
1104
. route ( web:: post ( ) . to ( handlers:: message_handler:: get_tool_function_params) )
1105
+ . wrap ( RedisCacheMiddlewareBuilder :: new ( redis_url)
1106
+ . cache_prefix ( "function_params:" )
1107
+ . ttl ( 60 * 60 * 24 )
1108
+ . cache_if ( |ctx| {
1109
+ if let Ok ( req_body) = serde_json:: from_slice :: < serde_json:: Value > ( ctx. body ) {
1110
+ return req_body. get ( "audio_input" ) . is_none ( ) || req_body. get ( "audio_input" ) . unwrap ( ) . is_null ( ) ;
1111
+ }
1112
+
1113
+ true
1114
+ } )
1115
+ . build ( )
1116
+ )
1104
1117
)
1105
1118
. service (
1106
1119
web:: resource ( "/message/{message_id}" )
You can’t perform that action at this time.
0 commit comments