Skip to content

Commit

Permalink
Move chat components into its own namespace (#5633)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 authored Oct 16, 2023
1 parent 9a70094 commit 894f1be
Show file tree
Hide file tree
Showing 19 changed files with 2,714 additions and 2,190 deletions.
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
'global',
'indicators',
'widgets',
'chat',
],
'titles': {
'Vega': 'Altair & Vega',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"import asyncio\n",
"\n",
"import panel as pn\n",
"from panel.widgets import ChatEntry\n",
"from panel.chat import ChatEntry\n",
"\n",
"pn.extension()\n"
]
Expand Down Expand Up @@ -175,7 +175,7 @@
"metadata": {},
"outputs": [],
"source": [
"chat_entry = pn.widgets.ChatEntry()\n",
"chat_entry = pn.chat.ChatEntry()\n",
"chat_entry"
]
},
Expand Down Expand Up @@ -266,7 +266,7 @@
"metadata": {},
"outputs": [],
"source": [
"pn.widgets.ChatEntry(timestamp_format=\"%b %d, %Y %I:%M %p\")"
"pn.chat.ChatEntry(timestamp_format=\"%b %d, %Y %I:%M %p\")"
]
},
{
Expand Down Expand Up @@ -328,7 +328,7 @@
"metadata": {},
"outputs": [],
"source": [
"pn.widgets.ChatEntry(value=\"Love this!\", reactions=[\"favorite\"])"
"pn.chat.ChatEntry(value=\"Love this!\", reactions=[\"favorite\"])"
]
},
{
Expand All @@ -344,7 +344,7 @@
"metadata": {},
"outputs": [],
"source": [
"entry = pn.widgets.ChatEntry(\n",
"entry = pn.chat.ChatEntry(\n",
" value=\"Looks good!\",\n",
" reactions=[\"like\"],\n",
" reaction_icons={\"like\": \"thumb-up\", \"dislike\": \"thumb-down\"},\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"metadata": {},
"outputs": [],
"source": [
"chat_feed = pn.widgets.ChatFeed()\n",
"chat_feed = pn.chat.ChatFeed()\n",
"chat_feed"
]
},
Expand Down Expand Up @@ -147,9 +147,9 @@
"metadata": {},
"outputs": [],
"source": [
"pn.widgets.ChatFeed(value=[\n",
" pn.widgets.ChatEntry(value=\"I'm an emoji!\", avatar=\"🤖\"),\n",
" pn.widgets.ChatEntry(value=\"I'm an image!\", avatar=\"https://upload.wikimedia.org/wikipedia/commons/6/63/Yumi_UBports.png\"),\n",
"pn.chat.ChatFeed(value=[\n",
" pn.chat.ChatEntry(value=\"I'm an emoji!\", avatar=\"🤖\"),\n",
" pn.chat.ChatEntry(value=\"I'm an image!\", avatar=\"https://upload.wikimedia.org/wikipedia/commons/6/63/Yumi_UBports.png\"),\n",
"])"
]
},
Expand Down Expand Up @@ -187,7 +187,7 @@
"def echo_message(contents, user, instance):\n",
" return f\"Echoing... {contents}\"\n",
"\n",
"chat_feed = pn.widgets.ChatFeed(callback=echo_message)\n",
"chat_feed = pn.chat.ChatFeed(callback=echo_message)\n",
"chat_feed"
]
},
Expand All @@ -213,7 +213,7 @@
"metadata": {},
"outputs": [],
"source": [
"chat_feed = pn.widgets.ChatFeed(callback=echo_message, callback_user=\"Echo Bot\")\n",
"chat_feed = pn.chat.ChatFeed(callback=echo_message, callback_user=\"Echo Bot\")\n",
"chat_feed"
]
},
Expand Down Expand Up @@ -242,7 +242,7 @@
"def parrot_message(contents, user, instance):\n",
" return {\"value\": f\"No, {contents.lower()}\", \"user\": \"Parrot\", \"avatar\": \"🦜\"}\n",
"\n",
"chat_feed = pn.widgets.ChatFeed(callback=parrot_message, callback_user=\"Echo Bot\")\n",
"chat_feed = pn.chat.ChatFeed(callback=parrot_message, callback_user=\"Echo Bot\")\n",
"chat_feed"
]
},
Expand Down Expand Up @@ -289,7 +289,7 @@
"def bad_callback(contents, user, instance):\n",
" return 1 / 0\n",
"\n",
"chat_feed = pn.widgets.ChatFeed(callback=bad_callback, callback_exception=\"summary\")\n",
"chat_feed = pn.chat.ChatFeed(callback=bad_callback, callback_exception=\"summary\")\n",
"chat_feed"
]
},
Expand Down Expand Up @@ -325,7 +325,7 @@
" await asyncio.sleep(2.8)\n",
" return {\"value\": f\"No, {contents.lower()}\", \"user\": \"Parrot\", \"avatar\": \"🦜\"}\n",
"\n",
"chat_feed = pn.widgets.ChatFeed(callback=parrot_message, callback_user=\"Echo Bot\")\n",
"chat_feed = pn.chat.ChatFeed(callback=parrot_message, callback_user=\"Echo Bot\")\n",
"chat_feed"
]
},
Expand Down Expand Up @@ -361,7 +361,7 @@
" message += character\n",
" yield message\n",
"\n",
"chat_feed = pn.widgets.ChatFeed(callback=stream_message)\n",
"chat_feed = pn.chat.ChatFeed(callback=stream_message)\n",
"chat_feed"
]
},
Expand Down Expand Up @@ -392,7 +392,7 @@
" await asyncio.sleep(0.1)\n",
" yield character\n",
"\n",
"chat_feed = pn.widgets.ChatFeed(callback=replace_message)\n",
"chat_feed = pn.chat.ChatFeed(callback=replace_message)\n",
"chat_feed"
]
},
Expand Down Expand Up @@ -428,7 +428,7 @@
" message += chunk[\"choices\"][0][\"delta\"].get(\"content\", \"\")\n",
" yield message\n",
"\n",
"chat_feed = pn.widgets.ChatFeed(callback=openai_callback)\n",
"chat_feed = pn.chat.ChatFeed(callback=openai_callback)\n",
"chat_feed.send(\"Have you heard of HoloViz Panel?\")\n",
"```\n",
"\n",
Expand Down Expand Up @@ -466,7 +466,7 @@
" }\n",
"\n",
"\n",
"chat_feed = pn.widgets.ChatFeed(callback=chain_message)\n",
"chat_feed = pn.chat.ChatFeed(callback=chain_message)\n",
"chat_feed"
]
},
Expand Down Expand Up @@ -514,7 +514,7 @@
" instance.respond()\n",
"\n",
"\n",
"chat_feed = pn.widgets.ChatFeed(callback=openai_self_chat, sizing_mode=\"stretch_width\", height=1000).servable()\n",
"chat_feed = pn.chat.ChatFeed(callback=openai_self_chat, sizing_mode=\"stretch_width\", height=1000).servable()\n",
"chat_feed.send(\"What is HoloViz Panel?\")\n",
"```\n",
"\n",
Expand All @@ -534,7 +534,7 @@
"metadata": {},
"outputs": [],
"source": [
"chat_feed = pn.widgets.ChatFeed()\n",
"chat_feed = pn.chat.ChatFeed()\n",
"\n",
"# creates a new entry\n",
"entry = chat_feed.stream(\"Hello\", user=\"Aspiring User\", avatar=\"🤓\")\n",
Expand Down Expand Up @@ -564,7 +564,7 @@
"metadata": {},
"outputs": [],
"source": [
"chat_feed = pn.widgets.ChatFeed()\n",
"chat_feed = pn.chat.ChatFeed()\n",
"chat_feed"
]
},
Expand Down Expand Up @@ -596,7 +596,7 @@
"entry_params = dict(\n",
" default_avatars={\"System\": \"S\", \"User\": \"👤\"}, reaction_icons={\"like\": \"thumb-up\"}\n",
")\n",
"chat_feed = pn.widgets.ChatFeed(entry_params=entry_params)\n",
"chat_feed = pn.chat.ChatFeed(entry_params=entry_params)\n",
"chat_feed.send(user=\"System\", value=\"This is the System speaking.\")\n",
"chat_feed.send(user=\"User\", value=\"This is the User speaking.\")\n",
"chat_feed"
Expand All @@ -619,7 +619,7 @@
"source": [
"import asyncio\n",
"import panel as pn\n",
"from panel.widgets.chat import ChatEntry, ChatFeed\n",
"from panel.chat import ChatEntry, ChatFeed\n",
"\n",
"pn.extension()\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"outputs": [],
"source": [
"import panel as pn\n",
"from panel.widgets import ChatInterface\n",
"from panel.chat import ChatInterface\n",
"\n",
"pn.extension()"
]
Expand Down Expand Up @@ -275,7 +275,7 @@
" instance.active = 0 # Change to TextAreaInput tab\n",
" return f\"Got {num}.\"\n",
"\n",
"pn.widgets.ChatInterface(\n",
"pn.chat.ChatInterface(\n",
" callback=guided_get_num,\n",
" widgets=[\n",
" pn.widgets.TextAreaInput(placeholder=\"Enter some text to get a count!\"),\n",
Expand Down Expand Up @@ -311,7 +311,7 @@
" pn.widgets.TextAreaInput(placeholder=\"Enter some text to get a count!\"),\n",
" pn.widgets.IntSlider(name=\"Number Input\", end=10)\n",
"]\n",
"pn.widgets.ChatInterface(\n",
"pn.chat.ChatInterface(\n",
" callback=get_num_guided,\n",
" widgets=widgets[0],\n",
")"
Expand All @@ -334,7 +334,7 @@
" pn.widgets.TextAreaInput(placeholder=\"Enter some text to get a count!\"),\n",
" pn.widgets.IntSlider(name=\"Number Input\", end=10)\n",
"]\n",
"chat_interface = pn.widgets.ChatInterface(\n",
"chat_interface = pn.chat.ChatInterface(\n",
" widgets=widgets,\n",
")\n",
"print(chat_interface.active_widget)"
Expand All @@ -355,7 +355,7 @@
"metadata": {},
"outputs": [],
"source": [
"pn.widgets.ChatInterface(\n",
"pn.chat.ChatInterface(\n",
" widgets=pn.widgets.TextAreaInput(),\n",
" reset_on_send=False,\n",
")"
Expand All @@ -376,7 +376,7 @@
"metadata": {},
"outputs": [],
"source": [
"pn.widgets.ChatInterface(callback=get_num, show_rerun=False, show_undo=False)"
"pn.chat.ChatInterface(callback=get_num, show_rerun=False, show_undo=False)"
]
},
{
Expand All @@ -392,7 +392,7 @@
"metadata": {},
"outputs": [],
"source": [
"pn.widgets.ChatInterface(callback=get_num, show_button_name=False, width=400)"
"pn.chat.ChatInterface(callback=get_num, show_button_name=False, width=400)"
]
}
],
Expand Down
Loading

0 comments on commit 894f1be

Please sign in to comment.