Skip to content

Commit

Permalink
chore: rename type #2250
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok committed Feb 16, 2024
1 parent e8e8fbd commit 42561a5
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 77 deletions.
8 changes: 4 additions & 4 deletions py/examples/chatbot_events_suggestions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Chatbot / Events/ Suggestions
# Use prompt suggestions to simplify user interaction.
# Use suggestions to simplify user interaction.
# #chatbot #events #suggestions
# ---
from h2o_wave import main, app, Q, ui, data
Expand Down Expand Up @@ -34,13 +34,13 @@ async def serve(q: Q):
name='chatbot',
placeholder='Ask me anything...',
events=['suggestion'],
suggestions=[ui.chat_prompt_suggestion(name, label=value[0], caption=value[1], icon=value[2]) for
suggestions=[ui.chat_suggestion(name, label=value[0], caption=value[1], icon=value[2]) for
name, value in suggestions.items()]
)
q.client.initialized = True

elif q.events.chatbot or q.args.chatbot:
# Clear prompt suggestions.
# Clear suggestions.
q.page['example'].suggestions = []

# Handle user input.
Expand All @@ -49,7 +49,7 @@ async def serve(q: Q):
q.page['example'].data += [q.args.chatbot, True]
else:
label, caption, icon = suggestions[q.events.chatbot.suggestion]
# Append user message based on the prompt suggestion event.
# Append user message based on the suggestion event.
q.page['example'].data += [label + ' ' + caption, True]

# Append bot response.
Expand Down
38 changes: 19 additions & 19 deletions py/h2o_lightwave/h2o_lightwave/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8245,7 +8245,7 @@ def load(__d: Dict) -> 'ChatCard':
)


class ChatPromptSuggestion:
class ChatSuggestion:
"""Create a chat prompt suggestion displayed as button below the last response in the chatbot component.
"""
def __init__(
Expand All @@ -8255,10 +8255,10 @@ def __init__(
caption: Optional[str] = None,
icon: Optional[str] = None,
):
_guard_scalar('ChatPromptSuggestion.name', name, (str,), True, False, False)
_guard_scalar('ChatPromptSuggestion.label', label, (str,), False, False, False)
_guard_scalar('ChatPromptSuggestion.caption', caption, (str,), False, True, False)
_guard_scalar('ChatPromptSuggestion.icon', icon, (str,), False, True, False)
_guard_scalar('ChatSuggestion.name', name, (str,), True, False, False)
_guard_scalar('ChatSuggestion.label', label, (str,), False, False, False)
_guard_scalar('ChatSuggestion.caption', caption, (str,), False, True, False)
_guard_scalar('ChatSuggestion.icon', icon, (str,), False, True, False)
self.name = name
"""An identifying name for this component."""
self.label = label
Expand All @@ -8270,10 +8270,10 @@ def __init__(

def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
_guard_scalar('ChatPromptSuggestion.name', self.name, (str,), True, False, False)
_guard_scalar('ChatPromptSuggestion.label', self.label, (str,), False, False, False)
_guard_scalar('ChatPromptSuggestion.caption', self.caption, (str,), False, True, False)
_guard_scalar('ChatPromptSuggestion.icon', self.icon, (str,), False, True, False)
_guard_scalar('ChatSuggestion.name', self.name, (str,), True, False, False)
_guard_scalar('ChatSuggestion.label', self.label, (str,), False, False, False)
_guard_scalar('ChatSuggestion.caption', self.caption, (str,), False, True, False)
_guard_scalar('ChatSuggestion.icon', self.icon, (str,), False, True, False)
return _dump(
name=self.name,
label=self.label,
Expand All @@ -8282,21 +8282,21 @@ def dump(self) -> Dict:
)

@staticmethod
def load(__d: Dict) -> 'ChatPromptSuggestion':
def load(__d: Dict) -> 'ChatSuggestion':
"""Creates an instance of this class using the contents of a dict."""
__d_name: Any = __d.get('name')
_guard_scalar('ChatPromptSuggestion.name', __d_name, (str,), True, False, False)
_guard_scalar('ChatSuggestion.name', __d_name, (str,), True, False, False)
__d_label: Any = __d.get('label')
_guard_scalar('ChatPromptSuggestion.label', __d_label, (str,), False, False, False)
_guard_scalar('ChatSuggestion.label', __d_label, (str,), False, False, False)
__d_caption: Any = __d.get('caption')
_guard_scalar('ChatPromptSuggestion.caption', __d_caption, (str,), False, True, False)
_guard_scalar('ChatSuggestion.caption', __d_caption, (str,), False, True, False)
__d_icon: Any = __d.get('icon')
_guard_scalar('ChatPromptSuggestion.icon', __d_icon, (str,), False, True, False)
_guard_scalar('ChatSuggestion.icon', __d_icon, (str,), False, True, False)
name: str = __d_name
label: str = __d_label
caption: Optional[str] = __d_caption
icon: Optional[str] = __d_icon
return ChatPromptSuggestion(
return ChatSuggestion(
name,
label,
caption,
Expand All @@ -8315,7 +8315,7 @@ def __init__(
placeholder: Optional[str] = None,
events: Optional[List[str]] = None,
generating: Optional[bool] = None,
suggestions: Optional[List[ChatPromptSuggestion]] = None,
suggestions: Optional[List[ChatSuggestion]] = None,
disabled: Optional[bool] = None,
commands: Optional[List[Command]] = None,
):
Expand All @@ -8324,7 +8324,7 @@ def __init__(
_guard_scalar('ChatbotCard.placeholder', placeholder, (str,), False, True, False)
_guard_vector('ChatbotCard.events', events, (str,), False, True, False)
_guard_scalar('ChatbotCard.generating', generating, (bool,), False, True, False)
_guard_vector('ChatbotCard.suggestions', suggestions, (ChatPromptSuggestion,), False, True, False)
_guard_vector('ChatbotCard.suggestions', suggestions, (ChatSuggestion,), False, True, False)
_guard_scalar('ChatbotCard.disabled', disabled, (bool,), False, True, False)
_guard_vector('ChatbotCard.commands', commands, (Command,), False, True, False)
self.box = box
Expand Down Expand Up @@ -8353,7 +8353,7 @@ def dump(self) -> Dict:
_guard_scalar('ChatbotCard.placeholder', self.placeholder, (str,), False, True, False)
_guard_vector('ChatbotCard.events', self.events, (str,), False, True, False)
_guard_scalar('ChatbotCard.generating', self.generating, (bool,), False, True, False)
_guard_vector('ChatbotCard.suggestions', self.suggestions, (ChatPromptSuggestion,), False, True, False)
_guard_vector('ChatbotCard.suggestions', self.suggestions, (ChatSuggestion,), False, True, False)
_guard_scalar('ChatbotCard.disabled', self.disabled, (bool,), False, True, False)
_guard_vector('ChatbotCard.commands', self.commands, (Command,), False, True, False)
return _dump(
Expand Down Expand Up @@ -8395,7 +8395,7 @@ def load(__d: Dict) -> 'ChatbotCard':
placeholder: Optional[str] = __d_placeholder
events: Optional[List[str]] = __d_events
generating: Optional[bool] = __d_generating
suggestions: Optional[List[ChatPromptSuggestion]] = None if __d_suggestions is None else [ChatPromptSuggestion.load(__e) for __e in __d_suggestions]
suggestions: Optional[List[ChatSuggestion]] = None if __d_suggestions is None else [ChatSuggestion.load(__e) for __e in __d_suggestions]
disabled: Optional[bool] = __d_disabled
commands: Optional[List[Command]] = None if __d_commands is None else [Command.load(__e) for __e in __d_commands]
return ChatbotCard(
Expand Down
10 changes: 5 additions & 5 deletions py/h2o_lightwave/h2o_lightwave/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2878,12 +2878,12 @@ def chat_card(
)


def chat_prompt_suggestion(
def chat_suggestion(
name: str,
label: str,
caption: Optional[str] = None,
icon: Optional[str] = None,
) -> ChatPromptSuggestion:
) -> ChatSuggestion:
"""Create a chat prompt suggestion displayed as button below the last response in the chatbot component.
Args:
Expand All @@ -2892,9 +2892,9 @@ def chat_prompt_suggestion(
caption: The caption displayed below the label.
icon: The icon to be displayed for this suggestion.
Returns:
A `h2o_wave.types.ChatPromptSuggestion` instance.
A `h2o_wave.types.ChatSuggestion` instance.
"""
return ChatPromptSuggestion(
return ChatSuggestion(
name,
label,
caption,
Expand All @@ -2909,7 +2909,7 @@ def chatbot_card(
placeholder: Optional[str] = None,
events: Optional[List[str]] = None,
generating: Optional[bool] = None,
suggestions: Optional[List[ChatPromptSuggestion]] = None,
suggestions: Optional[List[ChatSuggestion]] = None,
disabled: Optional[bool] = None,
commands: Optional[List[Command]] = None,
) -> ChatbotCard:
Expand Down
38 changes: 19 additions & 19 deletions py/h2o_wave/h2o_wave/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8245,7 +8245,7 @@ def load(__d: Dict) -> 'ChatCard':
)


class ChatPromptSuggestion:
class ChatSuggestion:
"""Create a chat prompt suggestion displayed as button below the last response in the chatbot component.
"""
def __init__(
Expand All @@ -8255,10 +8255,10 @@ def __init__(
caption: Optional[str] = None,
icon: Optional[str] = None,
):
_guard_scalar('ChatPromptSuggestion.name', name, (str,), True, False, False)
_guard_scalar('ChatPromptSuggestion.label', label, (str,), False, False, False)
_guard_scalar('ChatPromptSuggestion.caption', caption, (str,), False, True, False)
_guard_scalar('ChatPromptSuggestion.icon', icon, (str,), False, True, False)
_guard_scalar('ChatSuggestion.name', name, (str,), True, False, False)
_guard_scalar('ChatSuggestion.label', label, (str,), False, False, False)
_guard_scalar('ChatSuggestion.caption', caption, (str,), False, True, False)
_guard_scalar('ChatSuggestion.icon', icon, (str,), False, True, False)
self.name = name
"""An identifying name for this component."""
self.label = label
Expand All @@ -8270,10 +8270,10 @@ def __init__(

def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
_guard_scalar('ChatPromptSuggestion.name', self.name, (str,), True, False, False)
_guard_scalar('ChatPromptSuggestion.label', self.label, (str,), False, False, False)
_guard_scalar('ChatPromptSuggestion.caption', self.caption, (str,), False, True, False)
_guard_scalar('ChatPromptSuggestion.icon', self.icon, (str,), False, True, False)
_guard_scalar('ChatSuggestion.name', self.name, (str,), True, False, False)
_guard_scalar('ChatSuggestion.label', self.label, (str,), False, False, False)
_guard_scalar('ChatSuggestion.caption', self.caption, (str,), False, True, False)
_guard_scalar('ChatSuggestion.icon', self.icon, (str,), False, True, False)
return _dump(
name=self.name,
label=self.label,
Expand All @@ -8282,21 +8282,21 @@ def dump(self) -> Dict:
)

@staticmethod
def load(__d: Dict) -> 'ChatPromptSuggestion':
def load(__d: Dict) -> 'ChatSuggestion':
"""Creates an instance of this class using the contents of a dict."""
__d_name: Any = __d.get('name')
_guard_scalar('ChatPromptSuggestion.name', __d_name, (str,), True, False, False)
_guard_scalar('ChatSuggestion.name', __d_name, (str,), True, False, False)
__d_label: Any = __d.get('label')
_guard_scalar('ChatPromptSuggestion.label', __d_label, (str,), False, False, False)
_guard_scalar('ChatSuggestion.label', __d_label, (str,), False, False, False)
__d_caption: Any = __d.get('caption')
_guard_scalar('ChatPromptSuggestion.caption', __d_caption, (str,), False, True, False)
_guard_scalar('ChatSuggestion.caption', __d_caption, (str,), False, True, False)
__d_icon: Any = __d.get('icon')
_guard_scalar('ChatPromptSuggestion.icon', __d_icon, (str,), False, True, False)
_guard_scalar('ChatSuggestion.icon', __d_icon, (str,), False, True, False)
name: str = __d_name
label: str = __d_label
caption: Optional[str] = __d_caption
icon: Optional[str] = __d_icon
return ChatPromptSuggestion(
return ChatSuggestion(
name,
label,
caption,
Expand All @@ -8315,7 +8315,7 @@ def __init__(
placeholder: Optional[str] = None,
events: Optional[List[str]] = None,
generating: Optional[bool] = None,
suggestions: Optional[List[ChatPromptSuggestion]] = None,
suggestions: Optional[List[ChatSuggestion]] = None,
disabled: Optional[bool] = None,
commands: Optional[List[Command]] = None,
):
Expand All @@ -8324,7 +8324,7 @@ def __init__(
_guard_scalar('ChatbotCard.placeholder', placeholder, (str,), False, True, False)
_guard_vector('ChatbotCard.events', events, (str,), False, True, False)
_guard_scalar('ChatbotCard.generating', generating, (bool,), False, True, False)
_guard_vector('ChatbotCard.suggestions', suggestions, (ChatPromptSuggestion,), False, True, False)
_guard_vector('ChatbotCard.suggestions', suggestions, (ChatSuggestion,), False, True, False)
_guard_scalar('ChatbotCard.disabled', disabled, (bool,), False, True, False)
_guard_vector('ChatbotCard.commands', commands, (Command,), False, True, False)
self.box = box
Expand Down Expand Up @@ -8353,7 +8353,7 @@ def dump(self) -> Dict:
_guard_scalar('ChatbotCard.placeholder', self.placeholder, (str,), False, True, False)
_guard_vector('ChatbotCard.events', self.events, (str,), False, True, False)
_guard_scalar('ChatbotCard.generating', self.generating, (bool,), False, True, False)
_guard_vector('ChatbotCard.suggestions', self.suggestions, (ChatPromptSuggestion,), False, True, False)
_guard_vector('ChatbotCard.suggestions', self.suggestions, (ChatSuggestion,), False, True, False)
_guard_scalar('ChatbotCard.disabled', self.disabled, (bool,), False, True, False)
_guard_vector('ChatbotCard.commands', self.commands, (Command,), False, True, False)
return _dump(
Expand Down Expand Up @@ -8395,7 +8395,7 @@ def load(__d: Dict) -> 'ChatbotCard':
placeholder: Optional[str] = __d_placeholder
events: Optional[List[str]] = __d_events
generating: Optional[bool] = __d_generating
suggestions: Optional[List[ChatPromptSuggestion]] = None if __d_suggestions is None else [ChatPromptSuggestion.load(__e) for __e in __d_suggestions]
suggestions: Optional[List[ChatSuggestion]] = None if __d_suggestions is None else [ChatSuggestion.load(__e) for __e in __d_suggestions]
disabled: Optional[bool] = __d_disabled
commands: Optional[List[Command]] = None if __d_commands is None else [Command.load(__e) for __e in __d_commands]
return ChatbotCard(
Expand Down
10 changes: 5 additions & 5 deletions py/h2o_wave/h2o_wave/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2878,12 +2878,12 @@ def chat_card(
)


def chat_prompt_suggestion(
def chat_suggestion(
name: str,
label: str,
caption: Optional[str] = None,
icon: Optional[str] = None,
) -> ChatPromptSuggestion:
) -> ChatSuggestion:
"""Create a chat prompt suggestion displayed as button below the last response in the chatbot component.
Args:
Expand All @@ -2892,9 +2892,9 @@ def chat_prompt_suggestion(
caption: The caption displayed below the label.
icon: The icon to be displayed for this suggestion.
Returns:
A `h2o_wave.types.ChatPromptSuggestion` instance.
A `h2o_wave.types.ChatSuggestion` instance.
"""
return ChatPromptSuggestion(
return ChatSuggestion(
name,
label,
caption,
Expand All @@ -2909,7 +2909,7 @@ def chatbot_card(
placeholder: Optional[str] = None,
events: Optional[List[str]] = None,
generating: Optional[bool] = None,
suggestions: Optional[List[ChatPromptSuggestion]] = None,
suggestions: Optional[List[ChatSuggestion]] = None,
disabled: Optional[bool] = None,
commands: Optional[List[Command]] = None,
) -> ChatbotCard:
Expand Down
8 changes: 4 additions & 4 deletions r/R/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -3345,9 +3345,9 @@ ui_chat_card <- function(
#' @param label The text displayed for this suggestion.
#' @param caption The caption displayed below the label.
#' @param icon The icon to be displayed for this suggestion.
#' @return A ChatPromptSuggestion instance.
#' @return A ChatSuggestion instance.
#' @export
ui_chat_prompt_suggestion <- function(
ui_chat_suggestion <- function(
name,
label,
caption = NULL,
Expand All @@ -3361,7 +3361,7 @@ ui_chat_prompt_suggestion <- function(
label=label,
caption=caption,
icon=icon)
class(.o) <- append(class(.o), c(.wave_obj, "WaveChatPromptSuggestion"))
class(.o) <- append(class(.o), c(.wave_obj, "WaveChatSuggestion"))
return(.o)
}

Expand Down Expand Up @@ -3394,7 +3394,7 @@ ui_chatbot_card <- function(
.guard_scalar("placeholder", "character", placeholder)
.guard_vector("events", "character", events)
.guard_scalar("generating", "logical", generating)
.guard_vector("suggestions", "WaveChatPromptSuggestion", suggestions)
.guard_vector("suggestions", "WaveChatSuggestion", suggestions)
.guard_scalar("disabled", "logical", disabled)
.guard_vector("commands", "WaveCommand", commands)
.o <- list(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<option name="Python" value="true"/>
</context>
</template>
<template name="w_chat_prompt_suggestion" value="ui.chat_prompt_suggestion(name='$name$',label='$label$'),$END$" description="Create a minimal Wave ChatPromptSuggestion." toReformat="true" toShortenFQNames="true">
<template name="w_chat_suggestion" value="ui.chat_suggestion(name='$name$',label='$label$'),$END$" description="Create a minimal Wave ChatSuggestion." toReformat="true" toShortenFQNames="true">
<variable name="name" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="label" expression="" defaultValue="" alwaysStopAt="true"/>
<context>
Expand Down Expand Up @@ -1129,7 +1129,7 @@
<option name="Python" value="true"/>
</context>
</template>
<template name="w_full_chat_prompt_suggestion" value="ui.chat_prompt_suggestion(name='$name$',label='$label$',caption='$caption$',icon='$icon$'),$END$" description="Create Wave ChatPromptSuggestion with full attributes." toReformat="true" toShortenFQNames="true">
<template name="w_full_chat_suggestion" value="ui.chat_suggestion(name='$name$',label='$label$',caption='$caption$',icon='$icon$'),$END$" description="Create Wave ChatSuggestion with full attributes." toReformat="true" toShortenFQNames="true">
<variable name="name" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="label" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="caption" expression="" defaultValue="" alwaysStopAt="true"/>
Expand Down
16 changes: 8 additions & 8 deletions tools/vscode-extension/component-snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@
],
"description": "Create a minimal Wave ChatbotMessage."
},
"Wave ChatPromptSuggestion": {
"prefix": "w_chat_prompt_suggestion",
"Wave ChatSuggestion": {
"prefix": "w_chat_suggestion",
"body": [
"ui.chat_prompt_suggestion(name='$1', label='$2'),$0"
"ui.chat_suggestion(name='$1', label='$2'),$0"
],
"description": "Create a minimal Wave ChatPromptSuggestion."
"description": "Create a minimal Wave ChatSuggestion."
},
"Wave Chatbot": {
"prefix": "w_chatbot",
Expand Down Expand Up @@ -1063,12 +1063,12 @@
],
"description": "Create a full Wave ChatbotMessage."
},
"Wave Full ChatPromptSuggestion": {
"prefix": "w_full_chat_prompt_suggestion",
"Wave Full ChatSuggestion": {
"prefix": "w_full_chat_suggestion",
"body": [
"ui.chat_prompt_suggestion(name='$1', label='$2', caption='$3', icon='$4'),$0"
"ui.chat_suggestion(name='$1', label='$2', caption='$3', icon='$4'),$0"
],
"description": "Create a full Wave ChatPromptSuggestion."
"description": "Create a full Wave ChatSuggestion."
},
"Wave Full Chatbot": {
"prefix": "w_full_chatbot",
Expand Down
Loading

0 comments on commit 42561a5

Please sign in to comment.