First, let me thank you for your wonderful work. I am testing your whole ecosystem for the first time and I am quite pleased and impressed with it. As I was trying to build a toy project with your Chat interfaces I found discrepancies between your latest available docs and the code.
callback_avatar (str | bytes | BytesIO | pn.pane.ImageBase): The avatar to use for the user. Can be a single character text, an emoji, or anything supported by pn.pane.Image. If not set, uses the first character of the name.
However, trying to use the argument callback_avatar gets me:
self.chat_interface = pn.chat.ChatInterface(
callback=self.chat_callback,
callback_user="Assistant",
callback_avatar="A",
widgets=[pn.chat.ChatAreaInput(name="Ask", placeholder="Ask something")]
)
# Error on the browser:
TypeError: ChatInterface.init() got an unexpected keyword argument 'callback_avatar'
As I saw that it didn't work (and checked the source code and there isn't a callback_avatar declared) I went to try the next thing from the async callbacks documentation where it says:
Encountered ValueError("'value' is not a parameter of ChatMessage"). Set callback_exception='verbose' to see the full traceback.
So, checking the code, I see that value is not the correct key, the correct one is object.
Complete, minimal, self-contained example code that reproduces the issue
This code reproduces both issues:
"""
Demonstrates how to use the `ChatInterface` and a `callback` function to
stream back responses.
The chatbot Assistant echoes back the message entered by the User in an
*async streaming* fashion.
Highlights:
- The function is defined as `async` and uses `yield` to stream back responses.
- Initialize `message` first to gather the characters and then `yield` it;
without it, only one letter would be displayed at a time.
"""
from asyncio import sleep
import panel as pn
pn.extension()
async def callback(contents: str, user: str, instance: pn.chat.ChatInterface):
await sleep(1)
message = ""
for char in "Echoing User: " + contents:
await sleep(0.05)
message += char
yield {"value": message}
chat_interface = pn.chat.ChatInterface(callback=callback,
callback_avatar="A"
)
chat_interface.send(
"Enter a message below and receive an echo!",
user="System",
respond=False,
)
chat_interface.servable()
First, let me thank you for your wonderful work. I am testing your whole ecosystem for the first time and I am quite pleased and impressed with it. As I was trying to build a toy project with your Chat interfaces I found discrepancies between your latest available docs and the code.
ALL software version info
I cloned https://github.com/holoviz-topics/panel-chat-examples and used devcontainer environment. So all versions as specified in: https://github.com/holoviz-topics/panel-chat-examples/blob/main/pyproject.toml
panel's version is: panel==1.5.0a8
My output of
pip freeze
in the devcontainer is:Description of expected behavior and the observed behavior
The ChatFeed documentation states that you can:
However, trying to use the argument
callback_avatar
gets me:As I saw that it didn't work (and checked the source code and there isn't a
callback_avatar
declared) I went to try the next thing from the async callbacks documentation where it says:However if I try that, I get in the browser chat:
So, checking the code, I see that
value
is not the correct key, the correct one isobject
.Complete, minimal, self-contained example code that reproduces the issue
This code reproduces both issues:
Screenshots or screencasts of the bug in action