Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp and modernize docs completely for 1.4.0 #136

Merged
merged 12 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"codespaces": {
"openFiles": [
"README.md",
"docs/examples/basics/basic_chat.py",
"docs/examples/features/chat.py",
"docs/examples/openai/openai_chat.py"
]
},
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ test-results/
cache/

.DS_STORE
docs/basics.md
docs/components.md
docs/features.md
docs/langchain.md
Expand Down
9 changes: 4 additions & 5 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ On contribution:

```bash
hatch run pytest -s -m ui --screenshot on --video on --headed -k <NAME_OF_YOUR_EXAMPLE>
hatch run python scripts/postprocess_videos.py
hatch run docs-build
git checkout -b <YOUR_BRANCH_NAME>
git add commit
Expand All @@ -63,21 +62,21 @@ Please ensure it's installed on your system with
pip install hatch
```

Please ensure [Playwright](https://playwright.dev/python/) browsers are installed
Please ensure [Playwright](https://playwright.dev/python/) browsers are installed.

```bash
hatch run playwright install chromium
```

The first time `hatch run ...` is run, it will install the required dependencies.

Please ensure `pre-commit` is installed by running
Please ensure `pre-commit` is installed by running:

```bash
hatch run pre-commit install
```

You will also need to set the below environment variables
You will also need to set the below environment variables if it's not already in your environment.

```bash
export OPENAI_API_KEY=...
Expand All @@ -103,7 +102,7 @@ hatch run test

## Run UI tests

To run the Playwright tests in *headed* mode (i.e. show the browser) you can run
To run the Playwright tests in *headed* mode (i.e. show the browser) you can run:

```bash
hatch run pytest -s -m ui --headed
Expand Down
45 changes: 25 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,31 @@ Examples using [Panel](https://panel.holoviz.org/) and its [Chat Components](htt

https://github.com/holoviz-topics/panel-chat-examples/assets/42288570/cdb78a39-b98c-44e3-886e-29de6a079bde

Panels Chat Components are available from Panel v1.3.0.
Panels Chat Components are available with `pip install "panel>=1.3.0"`; most examples require `pip install "panel>=1.4.0"`.

## Quick Start

It's super easy to get started with Panel chat components.

1. Setup imports
2. Define a function to dictate what to do with the input message
3. Define a servable widget with `callback=response_callback`

```python
# 1.)
import panel as pn
pn.extension()

# 2.)
def response_callback(input_message: str, input_user: str, instance: pn.chat.ChatInterface):
# choose your favorite LLM API to respond to the input_message
...
response_message = f"Echoing your input: {input_message}"
return response_message

# 3.)
pn.widgets.ChatInterface(callback=response_callback).servable()
```

## Exploration

Expand All @@ -21,8 +45,6 @@ To install and serve all examples:
```bash
git clone https://github.com/holoviz-topics/panel-chat-examples
cd panel-chat-examples
# Optionally create a new virtual environment with conda, venv, etc.
pip install .
# Optionally set the OPENAI_API_KEY environment variable
panel serve docs/examples/**/*.py --static-dirs thumbnails=docs/assets/thumbnails --autoreload
```
Expand All @@ -31,23 +53,6 @@ Then open [http://localhost:5006](http://localhost:5006) in your browser.

![Panel Index Page](https://raw.githubusercontent.com/holoviz-topics/panel-chat-examples/main/assets/images/panel-chat-examples-index-page.png)

### GPU Usage

Note the default installation is not optimized for GPU usage. To enable GPU support for local
models (i.e. not OpenAI), install `ctransformers` with the [proper backend](https://github.com/marella/ctransformers#gpu) and modify the scripts configs' accordingly, e.g. `n_gpu_layers=1` for a single GPU.

CUDA:

```bash
pip install ctransformers[cuda] --no-binary ctransformers --no-cache --no-binary ctransformers --force
```

Mac M1/2:

```bash
CT_METAL=1 hatch run pip install ctransformers --no-binary ctransformers --no-cache --no-binary ctransformers --force # for m1
```

## Contributing

We would ❤️ to collaborate with you. Check out the [DEVELOPER GUIDE](https://github.com/holoviz-topics/panel-chat-examples/blob/main/DEVELOPER_GUIDE.md) for to get started.
Expand Down
Loading
Loading