how I can show all the list eg I want to get the object hotels and show all the list? in the default only 5 will show up
Can you explain more by providing screenshots, what have you done so far etc? You also need to know how to ask a question.
so far I’m using this Sample rasa/examples/knowledgebasebot at main · RasaHQ/rasa · GitHub when you try to run the actions will only see 5 hotels, I want to change to more than that to see the full list inside the json , so far we edit the json then also as test only the shown in the list can be able to inquire or get their data
If you look at this from rasa_sdk.knowledge_base.storage import InMemoryKnowledgeBase
go to definition of InMemoryKnowledgeBase
in the class InMemoryKnowledgeBase(KnowledgeBase)
the method async def get_objects
has paramter limit: int = 5
that is why it is showing only 5 objects.
is it possible to change more than 5 or what all in the list?
from rasa_sdk.knowledge_base.storage import InMemoryKnowledgeBase
from rasa_sdk.knowledge_base.actions import ActionQueryKnowledgeBase
from typing import Any, Text, Dict, List
from rasa_sdk import utils
import json
class ActionMyKB(ActionQueryKnowledgeBase):
def __init__(self):
# load knowledge base with data from the given file
knowledge_base = InMemoryKnowledgeBase("knowledge_base_sgtourism.json")
# overwrite the representation function of the hotel object
# by default the representation function is just the name of the object
knowledge_base.set_representation_function_of_object(
"hotel", lambda obj: obj["name"] + " (" + obj["city"] + ")"
)
super().__init__(knowledge_base)
async def utter_objects(
self,
dispatcher,
object_type,
objects,
) -> None:
if objects:
dispatcher.utter_message(text=f"This is the list {object_type} Available:\n")
for obj in enumerate(objects):
print(obj[1]['name'])
dispatcher.utter_message(text=obj[1]['name'])
def utter_attribute_value(
self,
dispatcher,
object_name,
attribute_name,
attribute_value,
) -> None:
print('attribute_name' ,attribute_name)
if attribute_name == 'free-wifi':
attribute_name = "free wifi"
if attribute_value == True:
dispatcher.utter_message(text=f"Yes {object_name} has {attribute_name}")
else:
dispatcher.utter_message(text=f"Sorry but {object_name} has no {attribute_name}")
if attribute_name == 'price-range':
dispatcher.utter_message(text=f"The price range of {object_name} is {attribute_value}")
if attribute_name == 'swimming-pool':
attribute_name = "swimming pool"
if attribute_value == True:
dispatcher.utter_message(text=f"Yes {object_name} has {attribute_name}")
else:
dispatcher.utter_message(text=f"Sorry but {object_name} has no {attribute_name}")
if attribute_name == 'shopping':
attribute_name = "shopping"
if attribute_value == True:
dispatcher.utter_message(text=f"Yes! you can go {attribute_name} in {object_name}")
else:
dispatcher.utter_message(text=f"Sorry! but cant do {attribute_name} in {object_name}")
if attribute_name == 'star-rating':
dispatcher.utter_message(text=f"The Start Rating in {object_name} is {attribute_value}")
I wish I could help you, I am not good at python .