fix(colang): use input rails output for intent generation #869
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #866
Description
Hi @drazvan,
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: Do you have any bikes?
Bot: Yes, we have a wide range of bikes. Would you like to see them?
User: sure
Now, query rewriting would transform the "sure" into "Show me some bikes!".
The Problem
The action
generate_user_intent
is called withuser_action
which is the final transcript of theUtteranceUserActionFinished
. However, the input rails set the$user_message
and$last_user_message
through the context.Here's my debugger:
The action has a typo: "Shoe me bikes", whereas the context has been rewritten to "show me bikes".
The solution
Let me first show my debugger again:
Same user input as above with typo: "Shoe me bikes".
Now, the context is consistent, and the example lookup works on the rewritten query.
Example and current workaround.
Currently, I am working around this issue by overriding
flow _user_said_something_unexpected
and performing three new steps:action_uid
andis_success
as before but with updated transcriptHere's the code:
Note: Please also refer to the custom prompt in
config.yml
, where I tried to do query rewriting and intent matching in one step, butexamples
would still be wrong without this fix.Note: I'll gladly enhance the README of the query rewriting example once we find a solution.
Happy to hear your feedback!
Cheers,
Niels
Checklist