Colang v2 Interaction Loop with Query Rewriting #866
-
Hi all, I am creating an AI solution based on the interaction loop of Colang v2. To improve the intent detection for user messages like confirmations ("yes", "no", etc.) I'd like to add Query Rewriting; basically an LLM call prompting to rephrase the user message with context from the conversation. Example User: Show me some bikes Now, query rewriting would transform the "yes" into "Show me some mountain bikes". I don't find a solution; I tried with a custom action, but from where do I get the conversation. I could use the default prompt for intent detection, but I also would like to reduce cognitive load on LLM calls. Intent detection is one thing, rephrasing another. Here's what I have so far: main.co
config.py @action()
async def RewriteQueryAction(user_message: str, context: dict, llm: BaseLLM) -> ActionResult:
context_updates = {}
# FIXME: no LLM prompt yet, just a static rewrite
rewrote_query = "Test"
context_updates["last_user_message"] = rewrote_query
return ActionResult(context_updates=context_updates)
def init(app: LLMRails):
app.register_action(RewriteQueryAction, "RewriteQueryAction") I use a default config.yml I'd appreciate your help! Thanks and cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Update: I'm currently trying input rails for user message rephrasing, with no luck. It feels like the correct place to do that, though:
|
Beta Was this translation helpful? Give feedback.
-
Opened a PR: #869 |
Beta Was this translation helpful? Give feedback.
Opened a PR: #869