How to return list of "name" from knowledge base (json file) by order of ID

Dear All,

I used a json file for knowledge base as following instruction link:

I want to list name of obj types same as the order of ID of obj types.

As below examples, I want to list all the name as following order: (same as the order of ID)

1 - Donath

2 - Berlin Burrito Company

3 - I due forni

“restaurant”: [

        "id": 0,
        "name": "Donath",
        "cuisine": "Italian",
        "outside-seating": true,
        "price-range": "mid-range"
        "id": 1,
        "name": "Berlin Burrito Company",
        "cuisine": "Mexican",
        "outside-seating": false,
        "price-range": "cheap"
        "id": 2,
        "name": "I due forni",
        "cuisine": "Italian",
        "outside-seating": true,
        "price-range": "mid-range"

Please advise this …

Hi Hai Ha,

You would call the set_representation_function_of_object() to overwrite the default representation of the object type restaurant. You’ll see an example of this in the and discussed in the Customizing the InMemoryKnowledgeBase section.

Here’s an example for restaurant that adds cuisine to the response:

    "restaurant", lambda obj: obj["name"] + " (" + obj["cuisine"] + ")"

OK, Thank you