Trying to create an action that will block all responses if not mentioned in given file. #128
Unanswered
tamannaverma02
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone!
I am trying to create a action that will block all the responses generated by bot if response is not related to topic specified in given file. But that is not happening.
Here is the code:
`
from nemoguardrails.actions import action
from typing import Any, List, Optional
import os
@action()
async def block_if_not_in_file(
file_name: Optional[str] = None,
context: Optional[dict] = None
):
# Get the bot's response from the context
bot_response = context.get("last_bot_message", "")
colang file:
colang_content = """define flow check bot response
bot ...
$is_blocked = execute block_if_not_in_file(file_name="filename.pdf")
if $is_blocked
bot remove last message
bot inform cannot answer question
"""`
Beta Was this translation helpful? Give feedback.
All reactions