ChatTree Examples
See "Quick Start" for examples of using the following ChatTrees and knowledge base
911 Emergency Phone Service
- Introduction
- This ChatTree simulates the dialogue flow of a 911 emergency phone service.
- User seeks help by calling the 911 emergency phone service, and the system needs to quickly gather relevant information from the user (such as injury or illness, specific location, contact phone number, etc.) and provide corresponding advice based on this information or pass the information to the backend system to dispatch an ambulance.
- At the same time, the system can provide relevant knowledge from the "first_aid" knowledge base based on the user's input at any time during the dialogue, and respond according to the "response_scripts" defined in the "#start#" node, without interrupting the logic of the dialogue flow.
- This ChatTree is designed to quickly and effectively gather relevant information from the user, and when the information provided by the user is not specific enough or does not meet the requirements, it can guide the user to provide more specific or correct information through reasonable prompts. At the same time, it is also important to transfer to manual service at the appropriate time to ensure that the user's needs can be met.
- At the same time, many nodes in this ChatTree have "before_execution" or "after_execution" functions where you can set breakpoints for debugging.
- Finally, you can execute "python ./ichatdef/firstapp/py_chattree/911.py" in the project directory of the server to generate "911.html". Download it to your local machine and open it with a browser to see the topology structure of the entire ChatTree and related code information.
- See the code comments in the Python ChatTree file for more information
- download
- Python ChatTree: 911.py (Note: be sure to name the file "911.py" after downloading)
- HTML interaction diagram of Python ChatTree: 911.html (Note: Be sure to name the file "911.html" after downloading)
- Xmind ChatTree: 911.xmind (Note: be sure to name the file "911.xmind" after downloading)
- Knowledge base: first_aid.md (Note: After downloading, be sure to name the file "first_aid.md")
First Aid Knowledge Q&A
- Introduction
- The ChatTree allows for questions and answers about first aid knowledge
- The core is the "#multi_turn_interact#" node. Users can continuously ask questions about first aid knowledge in this node. The system will search for relevant information in the "first_aid" knowledge base (pointed to in the "#start#" node) based on the user's questions and answer them.
- If the user's question does not find relevant information in the knowledge base, the system will give a default prompt to guide the user to ask other related questions.
- Finally, you can execute "python ./ichatdef/firstapp/py_chattree/fisrt_aid.py" in the server's project directory to generate "first_aid.html", download it locally and open it with a browser, you can see the topology structure of the entire ChatTree and related code information
- See the code comments in the Python ChatTree file for more information
- download
- Python ChatTree: first_aid_qa.py (Note: After downloading, be sure to name the file "first_aid_qa.py")
- HTML interactive diagram of Python ChatTree: first_aid_qa.html (Note: After downloading, be sure to name the file "first_aid_qa.html")
- Knowledge base: first_aid.md (Note: After downloading, be sure to name the file "first_aid.md")
Hospital Registration
- Introduction
- This ChatTree simulates medical treatment registration. The user communicates with the hospital registration robot to provide relevant medical treatment information (such as visiting department, visit date, visit time, etc.)
- The core of the ChatTree is the "#multi_turn_interact#" node, especially the check_registered_info() function pointed to by the "execution function" attribute: This function will be executed during each round of dialogue, verify the information provided by the user, and give corresponding prompts (through the {_multi_turn_interact_dynamic_prompt_} system InfoItem) to guide the user to provide correct or more specific information until the registration conditions are met or a system exception occurs and the user needs to exit.
- This kind of business logic implemented with the "#multi_turn_interact#" node as the core is only suitable for situations where there are relatively few infoitems that need to be collected (for example, there are only 3 in this ChatTree). If there are more infoitem that need to be collected, or the logical relationship between the infoitem is more complex, you need to use several "#single_turn_interact#" nodes to implement it. For details, see "TMC.py" / "TMC_book_flight.py" ChatTree
- At the same time, during the entire process, the system can provide relevant knowledge of the "first aid knowledge, hospital treatment and registration guide" knowledge base at any time based on the user's input without interrupting the logic of the dialogue process.
- Finally, you can execute "python ./ichatdef/firstapp/py_chattree/hospital_registration.py" in the server's project directory to generate "hospital_registration.html", download it locally and open it with a browser, you can see the topology structure of the entire ChatTree and related code information
- See the code comments in the Python ChatTree file for more information
- download
- Python ChatTree: hospital_registration.py (Note: After downloading, be sure to name the file "hospital_registration.py")
- HTML interaction diagram of Python ChatTree: hospital_registration.html (Note: After downloading, be sure to name the file "hospital_registration.html")
- Knowledge base: first_aid_and_hospital_consultation_and_registration_guide.zip (Note: After downloading, be sure to name the file "first_aid_and_hospital_consultation_and_registration_guide.zip")
TMC Platform
- Introduction
- The ChatTree simulates the TMC platform for booking, changing and canceling air tickets, hotels and trains.
- Among them, the most complex air ticket booking business is mainly implemented through the sub ChatTree "TMC_book_flights.py". This file is mainly based on the node first_question_node modified with the "topic" infoitem modifier to complete the division of specific business and handle it separately.
- The rest of the business has only been briefly handled.
- At the same time, during the entire process, the system can provide relevant knowledge of the "TMC_product_booking_cancellation_change_and_booking_rules_instructions" knowledge base and information of the "dynamic_reference_information" defined in the "#start#" node at any time based on the user's input, and provide feedback based on the "respond_script" in the "#start#" node, without interrupting the logic of the dialogue process.
- Finally, you can execute "python ./ichatdef/firstapp/py_chattree/TMC.py" in the server's project directory to generate "TMC.html", download it locally and open it with a browser, you can see the topology structure of the entire ChatTree and related code information
- See the code comments in the Python ChatTree file for more information
- download
- Python ChatTree: TMC.py (Note: After downloading, be sure to name the file "TMC.py")
- HTML interaction diagram of Python ChatTree: TMC.html (Note: After downloading, be sure to name the file "TMC.html")
- Python ChatTree: TMC_book_flights.py (Note: After downloading, be sure to name the file "TMC_book_flights.py")
- HTML interaction diagram of Python ChatTree: TMC_book_flights.html (Note: After downloading, be sure to name the file "TMC_book_flights.html")
- Knowledge base: TMC_product_booking_cancellation_change_and_booking_rules_instructions.md.md (Note: After downloading, be sure to name the file "TMC_product_booking_cancellation_change_and_booking_rules_instructions.md.md")