chatstream icon indicating copy to clipboard operation
chatstream copied to clipboard

Blank screens?

Open aaron-horowitz opened this issue 2 years ago • 4 comments

Hi folks,

I just wanted to start messing around with this, and I get blank screens for the UI component of chatstream (the part I'm interested in, I could live with or without the python). I've tried to replicate both the examples/basic/app.py, which shows only a blank screen, and the examples/controls/app.py, which shows only the right side panel of controls.

I downloaded via pip install chatstream@git+https://github.com/wch/chatstream.git into a virtual environment on Python 3.9.6, and worked with this on a Ubuntu 18.0 server.

My python libraries in the virtual environment:

              package  version               requirement
1             aiohttp    3.8.4            aiohttp==3.8.4
2           aiosignal    1.3.1          aiosignal==1.3.1
3               anyio    3.7.0              anyio==3.7.0
4             appdirs    1.4.4            appdirs==1.4.4
5             asgiref    3.7.2            asgiref==3.7.2
6       async-timeout    4.0.2      async-timeout==4.0.2
7               attrs   23.1.0             attrs==23.1.0
8             certifi 2023.5.7         certifi==2023.5.7
9  charset-normalizer    3.1.0 charset-normalizer==3.1.0
10              click    8.1.3              click==8.1.3
11        contextvars      2.4          contextvars==2.4
12     exceptiongroup    1.1.1     exceptiongroup==1.1.1
13         frozenlist    1.3.3         frozenlist==1.3.3
14                h11   0.14.0               h11==0.14.0
15          htmltools    0.2.1          htmltools==0.2.1
16               idna      3.4                 idna==3.4
17         immutables     0.19          immutables==0.19
18      linkify-it-py    2.0.2      linkify-it-py==2.0.2
19     markdown-it-py    2.2.0     markdown-it-py==2.2.0
20    mdit-py-plugins    0.3.5    mdit-py-plugins==0.3.5
21              mdurl    0.1.2              mdurl==0.1.2
22          multidict    6.0.4          multidict==6.0.4
23              numpy   1.24.3             numpy==1.24.3
24             openai   0.27.7            openai==0.27.7
25          packaging     23.1           packaging==23.1
26   python-multipart    0.0.6   python-multipart==0.0.6
27              regex 2023.5.5           regex==2023.5.5
28           requests   2.31.0          requests==2.31.0
29              shiny    0.3.3              shiny==0.3.3
30            sniffio    1.3.0            sniffio==1.3.0
31          starlette   0.27.0         starlette==0.27.0
32           tiktoken    0.4.0           tiktoken==0.4.0
33               tqdm   4.65.0              tqdm==4.65.0
34  typing_extensions    4.6.2  typing_extensions==4.6.2
35        uc-micro-py    1.0.2        uc-micro-py==1.0.2
36            urllib3    2.0.2            urllib3==2.0.2
37            uvicorn   0.22.0           uvicorn==0.22.0
38         websockets   11.0.3        websockets==11.0.3
39               yarl    1.9.2               yarl==1.9.2

aaron-horowitz avatar May 30 '23 23:05 aaron-horowitz

Hm, have you set OPENAI_API_KEY? And does the console print out any error messages?

Another possibility is a messed up python configuration, where running shiny at the command line invokes a different copy of shiny (and python) than the one that's intended. I've had this happen personally, and I've helped a few people find and fix this. If you modify the top of your app to have, the following, does it print out the values you expect?

import sys
import shiny

print("Python path: " + sys.executable)
print("Shiny version: " + shiny.__version__)

wch avatar May 31 '23 03:05 wch

Coming back with what I'd expect:

Python path: /home/ahorowitz/.virtualenvs/venv_shinygpt/bin/python
Shiny version: 0.3.3

I've set the OPENAI_API_KEY environment variable, and I've also tried it with specifying the key in the chatstream.chat_server. Same result.

No error messages in the terminal.

This is what shows up in my developer console upon page load:

caught TypeError: Cannot read properties of null (reading 'style')
    at <anonymous>:2:19
    at <anonymous>:3:3
shiny-autoreload.ts:13 WebSocket connection to 'ws://127.0.0.1:32951/autoreload' failed: 
(anonymous) @ shiny-autoreload.ts:13
(anonymous) @ shiny-autoreload.ts:18
DevTools failed to load source map: Could not load content for chrome-extension://liecbddmkiiihnedobmlmillhodjkdmb/js/companionBubble.js.map: System error: net::ERR_BLOCKED_BY_CLIENT

aaron-horowitz avatar May 31 '23 16:05 aaron-horowitz

I think the companionBubble.js.map thing is from a browser extension.

And apologies if you did this, but I just want to make sure: Did you add those lines of code to the top of your app.py and then run it with shiny run app.py? (If you ran it from the python console it could give different answers.)

Stepping back a bit, what do you get if you run:

which shiny
cat `which shiny`

And then it also makes sense to try creating and running a basic test app. Does the following work?

shiny create testapp
shiny run testapp/app.py

wch avatar May 31 '23 17:05 wch

I ran it with the following command, in the terminal:

shiny run --reload --launch-browser --port=0 /home/ahorowitz/projects/py_shiny_gpt/examples/controls/app.py
which shiny
/home/ahorowitz/.virtualenvs/venv_shinygpt/bin/shiny
cat `which shiny`
#!/home/ahorowitz/.virtualenvs/venv_shinygpt/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from shiny._main import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

Created and ran basic test app. Had to add --launch-browser, but then yep, it worked.

¯_(ツ)/¯ ¯_(ツ)

aaron-horowitz avatar May 31 '23 17:05 aaron-horowitz