Use NLP for Action Routing? #48
-
I'm considering switching from regex to NLP models for action routing and I'm curious about others' experiences with this. The main idea for NLP is its ability to understand context which allows for more natural interactions. It doesn't need constant updates like regex when new intents or variations show up, and it's generally better at handling ambiguous queries. However, there are notable tradeoffs. NLP models can be resource-heavy, potentially slowing down interactions due to increased computational demands. The integration process is more complex than with regex, involving additional steps like managing the model's lifecycle. Also, maintaining performance might require ongoing training and tuning, which adds a layer of overhead that you don't get with static regex patterns. Does anyone have any ideas or experience with using NLP for routing control flow? async def action_router(text: str, display):
# Alarm and Reminder actions
if re.search(r'\b(alarm|timer|reminder|remind me|^wake me up)\b', text, re.IGNORECASE):
return await alarm_reminder_action(text)
# For Spotify actions
if re.search(r'\b(^play|resume|next song|go back|pause|stop|shuffle|repeat|volume)(\s.*)?(\bon\b\sSpotify)?\b', text, re.IGNORECASE):
return await spotify_action(text)
# For Open Weather actions
elif re.search(r'\b(weather|forecast|temperature)\b.*\b(in|for|at)?\b(\w+)?', text, re.IGNORECASE) or \
re.search(r'\b(is|will)\sit\b.*\b(hot|cold|rain(ing|y)?|sun(ny|ning)?|cloud(y|ing)?|wind(y|ing)?|storm(y|ing)?|snow(ing)?)\b', text, re.IGNORECASE):
return await open_weather_action(text)
# For Philips Hue actions
elif re.search(r'\b(turn\s)?(the\s)?lights?\s?(on|off)?\b', text, re.IGNORECASE):
return await philips_hue_action(text)
# For Calendar & To-Do List actions (CalDAV)
elif re.search(r'\b(event|calendar|schedule|appointment|task|todo|to-do|task\slist|to-do\slist|to do)\b', text, re.IGNORECASE):
return await caldav_action(text)
# If no pattern matches, query OpenAI
else:
return await query_openai(text, display) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
GH Community Post Answer |
Beta Was this translation helpful? Give feedback.
-
Interesting article on LangChain. |
Beta Was this translation helpful? Give feedback.
GH Community Post Answer
https://github.com/orgs/community/discussions/125994#discussioncomment-9577820