Skip to content

Using Panel>=1.3.0 in django_bokeh package #8

Open
@Jesse-vd-Linden

Description

@Jesse-vd-Linden

Hi There,

I am using the bokeh-django package to display a panel.chat.ChatInterface on my website.

The chat using the following panel_handler

def app(doc: Document) -> None:
    chat_interface.server_doc(doc)'

And is added to the bokeh_app with an autoload

bokeh_apps = [
    autoload("chat/", Agents.app)
]

After using the setup instructions for the README I was finally able to display the ChatInterface.
For this, I did have to alter the following in the setting.py

from bokeh.settings import settings as bokeh_settings
# bokeh_settings.resources = 'server'
bokeh_settings.resources = 'inline'

If I use the the resources setting as server, it does not seem to find the static files from Panel.

HTTP GET /chat/autoload.js?bokeh-autoload-element=p1002&bokeh-app-path=/chat&bokeh-absolute-url=http://127.0.0.1:8000/chat 200 [0.22, 127.0.0.1:52925]
HTTP GET /static/js/bokeh.min.js?v=53f9ca7a5b60daf7940a6e91ff6bdf0913c7a7c780cae58750c958d90d0cf4a638713847f81637ff880a0d2dad5c57cf9988ac65af54c12df96cd7c3dffb4ac3 304 [0.01, 127.0.0.1:52925]
HTTP GET /static/js/bokeh-gl.min.js?v=32bcb6e6ccbd3c1a02be8407ea0e1e0b05a12a8c47a196f065fcf8639d99113cd4fcf3a6939fce0478f9c12f2cb7763011318f4fb8b4b8b579132ea29de9a099 304 [0.01, 127.0.0.1:52931]
HTTP GET /static/js/bokeh-widgets.min.js?v=f90def549d46f97ac5d3451c79f33a81b406a43529102059db32abc76aa700f18b8009e5e096f6f7b222a3b51226e53e77e62f5e48ac82cb3de0b300c5100959 304 [0.01, 127.0.0.1:52932]
HTTP GET /static/extensions/panel/panel.min.js?v=59296d23d623ce0adf7675d22156e83b1248c8508135a65dd8a9e38c497e94a8 404 [0.03, 127.0.0.1:52933]
HTTP GET /static/js/bokeh-tables.min.js?v=b3381341845a3f3b239aa9204f891355ff51670b2bba887db6b5f1de2ad890c65ed1d3f4e9d60c389f78f3109f299ade900cb1148e6d718a953fb372820c8573 304 [0.03, 127.0.0.1:52934]

However when using the inline as setting it does load the chat panel, but I am getting the error that protocol is not a key in the _RequestProxy object. Is this due to changing the bokeh_settings?

ERROR:bokeh.application.application:Error running application handler <bokeh.application.handlers.function.FunctionHandler object at 0x00000276821FD490>: 'protocol'
File 'consumers.py', line 355, in __getattr__:
return self[key] Traceback (most recent call last):
  File "C:\dev\PromoAgent\venv\Lib\site-packages\bokeh\application\handlers\function.py", line 140, in modify_document    
    self._func(doc)
  File "C:\dev\PromoAgent\app\PromoAgent\pn_app.py", line 9, in app
    chat_interface.server_doc(doc)
  File "C:\dev\PromoAgent\venv\Lib\site-packages\panel\viewable.py", line 1038, in server_doc
    self._add_location(doc, location, model)
  File "C:\dev\PromoAgent\venv\Lib\site-packages\panel\viewable.py", line 329, in _add_location
    loc = state.location
          ^^^^^^^^^^^^^^
  File "C:\dev\PromoAgent\venv\Lib\site-packages\panel\io\state.py", line 996, in location
    loc = Location.from_request(self.curdoc.session_context.request)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dev\PromoAgent\venv\Lib\site-packages\panel\io\location.py", line 76, in from_request
    if request.protocol:
       ^^^^^^^^^^^^^^^^
  File "C:\dev\PromoAgent\venv\Lib\site-packages\bokeh\server\contexts.py", line 378, in __getattr__
    val = getattr(self._request, name, None)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dev\PromoAgent\venv\Lib\site-packages\bokeh_django\consumers.py", line 355, in __getattr__
    return self[key]
           ~~~~^^^^^
KeyError: 'protocol'

Current dependencies are:
bokeh==3.2.0
bokeh-django==0.1.0
channels==3.0.5
daphne==3.0.2
Django==4.2.9
Jinja2==3.1.3
panel==1.3.0
tornado==6.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions