AIML Combining the Topic and Learn Commands

87 Views Asked by At

I am trying to utilize the and commands in combination with each other. I want my chatbot to take info gathered from one topic and apply it to another topic. For instance, lets say I have a topic named cats. In this topic, I use to teach the chatbot that I have a light brown cat with white spots. Now lets say I am now in a new topic called pets. In this topic, I want the chatbot to use the information it learned from the cats topic and reference it in this new topic called pets. I have been trying to combine the learn and topic commands to achieve this. For instance, I made a topic within a learn command so I can reference the topic within the learn command. However, I'm unable to get the chatbot to cross reference.

My goal is to make a chatbot that can conversate about a topic in AI ethics. I want to be able to teach it new information and have it use said information in a live conversation. I want whatever code I make to be capable of receiving, storing, and using information at will no matter what the topic is. This way, if I mention information that is in a different topic, the chatbot will already understand it and can use it in the conversation.

Am I approaching this problem correctly? Or is there another approach I could take instead?

1

There are 1 best solutions below

1
On

You can use predicates rather than the learn tag for this.

<category>
    <pattern>TALK ABOUT CATS</pattern>
    <template>
        <think><set name="topic">CATS</set></think>
        <srai>CAT QUESTION</srai>
    </template>
</category>

<topic name="CATS">
    <category>
        <pattern>TALK ABOUT PETS</pattern>
        <template>      
            <think><set name="topic">PETS</set></think>
            Sure. Pets is a good topic.
        </template>
    </category>
    
    <category>
        <pattern>CAT QUESTION</pattern>
        <template>What sort of cat do you have?</template>
    </category>
    
    <category>
        <pattern>*</pattern>
        <that>WHAT SORT OF CAT DO YOU HAVE</that>
        <template>
            <think><set name="cat"><star/></set></think>
            Thanks for telling me that.
        </template>
    </category>
</topic>

<topic name="PETS">
    <category>
        <pattern>WHAT PETS DO I HAVE</pattern>
        <template>
            <get name="cat"/>
        </template>
    </category>
</topic>

This will allow the following conversation:

enter image description here