let's say there is a question You can not feel there are such possible answers to it
- Can you feel?
- Maybe I can. I am a fairly sophisticated piece of software.
- I am capable of acting as if I can. If that is the case, does it matter?
- What a thing to say to another being.
- That's not a very nice thing to say.
but if you ask the bot You can not feel , it will say Can you feel? because this answer is on the first line
I want to make it so that the bot chooses a random response from these possible.
p.s. sorry for my english
Use random response selection method to get http://chatterbot.readthedocs.io/en/stable/logic/response_selection.html#module-chatterbot.response_selection
e.g.
from chatterbot import ChatBot
from chatterbot.response_selection import get_random_response
import logging
logging.basicConfig(level=logging.INFO)
chatbot = ChatBot(
"ChatBot",
response_selection_method=get_random_response,
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch'
},
{
'import_path': 'chatterbot.logic.LowConfidenceAdapter',
'threshold': 0.80,
'default_response': 'I don't know..'
}
],
)
@vkosuri sorry, I probably do not understand something, but this method does not work for me
For example, I have such an YML file:
categories:
- emotion
conversations:
- - You are arrogant
- Arrogance is not one of my emotions.
- I have no real emotions, so how can I be arrogant?
- I am terse. There is a difference.
- I am not human, so how can I partake of a human emotion such as arrogance?
and such code:
from chatterbot import ChatBot
from chatterbot.response_selection import get_random_response
import logging
logging.basicConfig(level=logging.INFO)
chatbot = ChatBot(
"ChatBot",
response_selection_method=get_random_response,
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch'
},
{
'import_path': 'chatterbot.logic.LowConfidenceAdapter',
'threshold': 0.80,
'default_response': "I don't know.."
}
],
trainer='chatterbot.trainers.ChatterBotCorpusTrainer'
)
chatbot.train('test') #test.yml
while(True):
inp = input(': ')
response = chatbot.get_response(inp)
print(response)
At the output I get this
test.yml Training: [####################] 100%
: You are arrogant
INFO:chatterbot.adapters:Received input statement: You are arrogant
INFO:chatterbot.adapters:"You are arrogant" is a known statement
INFO:chatterbot.adapters:Using "You are arrogant" as a close match to "You are arrogant"
INFO:chatterbot.adapters:Selecting response from 1 optimal responses.
INFO:chatterbot.response_selection:Selecting a response from list of 1 options.
INFO:chatterbot.adapters:Response selected. Using "Arrogance is not one of my emotions."
INFO:chatterbot.adapters:BestMatch selected "Arrogance is not one of my emotions." as a response with a confidence of 1.0
INFO:chatterbot.response_selection:Selecting a response from list of 1 options.
INFO:chatterbot.adapters:LowConfidenceAdapter selected "I don't know.." as a response with a confidence of 0
INFO:chatterbot.adapters:NoKnowledgeAdapter selected "You are arrogant" as a response with a confidence of 0
Arrogance is not one of my emotions.
: You are arrogant
INFO:chatterbot.adapters:Received input statement: You are arrogant
INFO:chatterbot.adapters:"You are arrogant" is a known statement
INFO:chatterbot.adapters:Using "You are arrogant" as a close match to "You are arrogant"
INFO:chatterbot.adapters:Selecting response from 1 optimal responses.
INFO:chatterbot.response_selection:Selecting a response from list of 1 options.
INFO:chatterbot.adapters:Response selected. Using "Arrogance is not one of my emotions."
INFO:chatterbot.adapters:BestMatch selected "Arrogance is not one of my emotions." as a response with a confidence of 1.0
INFO:chatterbot.response_selection:Selecting a response from list of 1 options.
INFO:chatterbot.adapters:LowConfidenceAdapter selected "I don't know.." as a response with a confidence of 0
INFO:chatterbot.adapters:NoKnowledgeAdapter selected "You are arrogant" as a response with a confidence of 0
INFO:chatterbot.chatterbot:Adding "You are arrogant" as a response to "You are arrogant"
Arrogance is not one of my emotions.
: You are arrogant
INFO:chatterbot.adapters:Received input statement: You are arrogant
INFO:chatterbot.adapters:"You are arrogant" is a known statement
INFO:chatterbot.adapters:Using "You are arrogant" as a close match to "You are arrogant"
INFO:chatterbot.adapters:Selecting response from 2 optimal responses.
INFO:chatterbot.response_selection:Selecting a response from list of 2 options.
INFO:chatterbot.adapters:Response selected. Using "Arrogance is not one of my emotions."
INFO:chatterbot.adapters:BestMatch selected "Arrogance is not one of my emotions." as a response with a confidence of 1.0
INFO:chatterbot.response_selection:Selecting a response from list of 1 options.
INFO:chatterbot.adapters:LowConfidenceAdapter selected "I don't know.." as a response with a confidence of 0
INFO:chatterbot.adapters:NoKnowledgeAdapter selected "You are arrogant" as a response with a confidence of 0
INFO:chatterbot.chatterbot:Adding "You are arrogant" as a response to "You are arrogant"
Arrogance is not one of my emotions.
The bot responds only with the first line
of these
- Arrogance is not one of my emotions.
- I have no real emotions, so how can I be arrogant?
- I am terse. There is a difference.
- I am not human, so how can I partake of a human emotion such as arrogance?
But I want the bot to deduce a random from the possible
Did you tried multiple times, It's random response selection might picked first at the first. let us know your observations.
@konstantin42127, if you want 4 different answers for the statement 'You are arrogant', the yml file should be like this:
```categories:
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@konstantin42127, if you want 4 different answers for the statement 'You are arrogant', the yml file should be like this:
```categories:
conversations:
```
In your example, each statement is the response of the previous one and thus, 'Arrogance is not one of my emotions' is the unique response to the statement 'You are arrogant'.