Repository: Avaiga/taipy
File: doc/gui/examples/controls/chat-streaming.py (Python)

Code before:
        state_id,
        set_message,
        ["requesting Wikipedia ..."],
    )
    request = wiki_url.format(type=event_type, month=month, day=day)
    req = requests.get(request, headers={"accept": "application/json; charset=utf-8;", "User-Agent": user_agent})
    # handle the response
    if req.status_code == 200:
        # display response
        invoke_callback(
            gui,
            state_id,
            update_message,
            [req.json(), event_type, f"{day}/{month}", idx],
        )
    else:
        # display error
        invoke_callback(
            gui,
            state_id,
            set_message,
            [f"requesting Wikipedia failed: {req.status_code}", idx],
        )


# invoked by the on_action on the chat control when the user press the send button
def send_message(state: State, id: str, payload: dict):
    args = payload.get("args", [])

    # display request
    state.messages.append((f"{len(state.messages)}", args[2], args[3]))
    state.refresh("messages")

    # analyse request
    request = args[2].lower()
    type_event = None
    for word in event_types:
        if word in request:
            type_event = event_types[word]
            break
    type_event = type_event if type_event else "events"

    month = None
    day = None
    for m in re.finditer(r"(\d\d?)", request):
        if month is None:
            month = m.group()
        elif day is None:
            day = m.group()
            break
    if month is None:

Review comment (suggestion):
```suggestion
# Invoked by the 'on_action' callback of the chat control when the user presses the Send button
```

Code after:
        state_id,
        set_message,
        ["Fetching information from Wikipedia ..."],
    )
    request = wiki_url.format(type=event_type, month=month, day=day)
    req = requests.get(request, headers={"accept": "application/json; charset=utf-8;", "User-Agent": user_agent})
    # Handle the response
    if req.status_code == 200:
        # Display the response
        invoke_callback(
            gui,
            state_id,
            update_message,
            [req.json(), event_type, f"{day}/{month}", idx],
        )
    else:
        # Display the error
        invoke_callback(
            gui,
            state_id,
            set_message,
            [f"Wikipedia API call failed: {req.status_code}", idx],
        )


# Invoked by the 'on_action' callback of the chat control when the user presses the Send button
def send_message(state: State, id: str, payload: dict):
    args = payload.get("args", [])

    # Display the request
    state.messages.append((f"{len(state.messages)}", args[2], args[3]))
    state.refresh("messages")

    # Analyse the request
    request = args[2].lower()
    type_event = None
    for word in event_types:
        if word in request:
            type_event = event_types[word]
            break
    type_event = type_event if type_event else "events"

    month = None
    day = None
    for m in re.finditer(r"(\d\d?)", request):
        if month is None:
            month = m.group()
        elif day is None:
            day = m.group()
            break
    if month is None: