@@ -61,7 +61,7 @@ def __init__(self, route: ModelRoute, mux_rule: mux_models.MuxRule):
6161 self ._mux_rule = mux_rule
6262
6363 @abstractmethod
64- def match (self , thing_to_match : mux_models .ThingToMatchMux ) -> bool :
64+ async def match (self , thing_to_match : mux_models .ThingToMatchMux ) -> bool :
6565 """Return True if the rule matches the thing_to_match."""
6666 pass
6767
@@ -97,7 +97,7 @@ def create(db_mux_rule: db_models.MuxRule, route: ModelRoute) -> MuxingRuleMatch
9797class CatchAllMuxingRuleMatcher (MuxingRuleMatcher ):
9898 """A catch all muxing rule matcher."""
9999
100- def match (self , thing_to_match : mux_models .ThingToMatchMux ) -> bool :
100+ async def match (self , thing_to_match : mux_models .ThingToMatchMux ) -> bool :
101101 logger .info ("Catch all rule matched" )
102102 return True
103103
@@ -132,7 +132,7 @@ def _is_matcher_in_filenames(self, detected_client: ClientType, data: dict) -> b
132132 )
133133 return is_filename_match
134134
135- def match (self , thing_to_match : mux_models .ThingToMatchMux ) -> bool :
135+ async def match (self , thing_to_match : mux_models .ThingToMatchMux ) -> bool :
136136 """
137137 Return True if the matcher is in one of the request filenames.
138138 """
@@ -156,7 +156,7 @@ def _is_request_type_match(self, is_fim_request: bool) -> bool:
156156 return True
157157 return False
158158
159- def match (self , thing_to_match : mux_models .ThingToMatchMux ) -> bool :
159+ async def match (self , thing_to_match : mux_models .ThingToMatchMux ) -> bool :
160160 """
161161 Return True if the matcher is in one of the request filenames and
162162 if the request type matches the MuxMatcherType.
@@ -194,7 +194,7 @@ def _get_user_messages_from_body(self, body: Dict) -> List[str]:
194194 user_messages .append (msgs_content )
195195 return user_messages
196196
197- def match (self , thing_to_match : mux_models .ThingToMatchMux ) -> bool :
197+ async def match (self , thing_to_match : mux_models .ThingToMatchMux ) -> bool :
198198 """
199199 Return True if the matcher is the persona description matched with the
200200 user messages.
@@ -204,14 +204,11 @@ def match(self, thing_to_match: mux_models.ThingToMatchMux) -> bool:
204204 return False
205205
206206 persona_manager = PersonaManager ()
207- is_persona_matched = persona_manager .check_persona_match (
207+ is_persona_matched = await persona_manager .check_persona_match (
208208 persona_name = self ._mux_rule .matcher , queries = user_messages
209209 )
210- logger .info (
211- "Persona rule matched" ,
212- matcher = self ._mux_rule .matcher ,
213- is_persona_matched = is_persona_matched ,
214- )
210+ if is_persona_matched :
211+ logger .info ("Persona rule matched" , persona = self ._mux_rule .matcher )
215212 return is_persona_matched
216213
217214
@@ -258,7 +255,7 @@ async def get_match_for_active_workspace(
258255 try :
259256 rules = await self .get_ws_rules (self ._active_workspace )
260257 for rule in rules :
261- if rule .match (thing_to_match ):
258+ if await rule .match (thing_to_match ):
262259 return rule .destination ()
263260 return None
264261 except KeyError :
0 commit comments