diff --git a/README.md b/README.md
index e1c16b0..a4a9bff 100644
--- a/README.md
+++ b/README.md
@@ -45,6 +45,7 @@ To install and serve all examples:
```bash
git clone https://github.com/holoviz-topics/panel-chat-examples
cd panel-chat-examples
+pip install -e ".[all]" # or instead of `all`, just `openai`, `mistralai`, `langchain`, `llamaindex`, `llamacpp`
# Optionally set the OPENAI_API_KEY environment variable
panel serve docs/examples/**/*.py --static-dirs thumbnails=docs/assets/thumbnails --autoreload
```
diff --git a/docs/applicable_recipes.md b/docs/applicable_recipes.md
index 1ee4710..3888be0 100644
--- a/docs/applicable_recipes.md
+++ b/docs/applicable_recipes.md
@@ -146,6 +146,7 @@ We use [OpenAI *Function Calling*](https://platform.openai.com/docs/guides/funct
We use [OpenAI *Function Calling*](https://platform.openai.com/docs/guides/function-calling) and
[hvPlot](https://hvplot.holoviz.org/) to create an **advanced chatbot** that can create plots.
"""
+
import json
from pathlib import Path
diff --git a/docs/assets/thumbnails/llama_cpp_python.png b/docs/assets/thumbnails/llama_cpp_python.png
new file mode 100644
index 0000000..178fcb8
Binary files /dev/null and b/docs/assets/thumbnails/llama_cpp_python.png differ
diff --git a/docs/assets/thumbnails/llama_index.mp4 b/docs/assets/thumbnails/llama_index.mp4
new file mode 100644
index 0000000..7dc1182
Binary files /dev/null and b/docs/assets/thumbnails/llama_index.mp4 differ
diff --git a/docs/assets/thumbnails/llama_index.png b/docs/assets/thumbnails/llama_index.png
new file mode 100644
index 0000000..178fcb8
Binary files /dev/null and b/docs/assets/thumbnails/llama_index.png differ
diff --git a/docs/assets/videos/llama_cpp_python.mp4 b/docs/assets/videos/llama_cpp_python.mp4
new file mode 100644
index 0000000..7dc1182
Binary files /dev/null and b/docs/assets/videos/llama_cpp_python.mp4 differ
diff --git a/docs/assets/videos/llama_index.mp4 b/docs/assets/videos/llama_index.mp4
new file mode 100644
index 0000000..7dc1182
Binary files /dev/null and b/docs/assets/videos/llama_index.mp4 differ
diff --git a/docs/chat_features.md b/docs/chat_features.md
index be7a83b..7d901c3 100644
--- a/docs/chat_features.md
+++ b/docs/chat_features.md
@@ -95,7 +95,6 @@ Highlights:
without it, only one letter would be displayed at a time.
"""
-
from asyncio import sleep
import panel as pn
@@ -321,7 +320,7 @@ async def callback(contents: str, user: str, instance: pn.chat.ChatInterface):
instance.respond()
elif user == PERSON_2:
instance.send(
- f"Yup, I heard!",
+ "Yup, I heard!",
user=PERSON_3,
avatar="😆",
respond=False,
@@ -387,7 +386,10 @@ async def callback(contents: str, user: str, instance: pn.chat.ChatInterface):
# use send instead of stream/yield/return to keep the placeholder text
# while still sending a message; ensure respond=False to avoid a recursive loop
instance.send(
- "Let me flip the coin for you...", user="Game Master", avatar="🎲", respond=False
+ "Let me flip the coin for you...",
+ user="Game Master",
+ avatar="🎲",
+ respond=False,
)
await sleep(1)
@@ -405,7 +407,11 @@ async def callback(contents: str, user: str, instance: pn.chat.ChatInterface):
# equivalently, use a dict instead of a pn.chat.ChatMessage
yield {"object": f"Woohoo, {result}! You win!", "user": "Coin", "avatar": "🎲"}
else:
- yield {"object": f"Aw, got {result}. Try again!", "user": "Coin", "avatar": "🎲"}
+ yield {
+ "object": f"Aw, got {result}. Try again!",
+ "user": "Coin",
+ "avatar": "🎲",
+ }
chat_interface = pn.chat.ChatInterface(
@@ -457,6 +463,7 @@ Highlights:
- Set `show_*` parameters to `False` to hide the respective buttons.
- Use `message_params` to customize the appearance of each chat messages.
"""
+
import panel as pn
pn.extension()
diff --git a/docs/examples/applicable_recipes/openai_chat_with_hvplot.py b/docs/examples/applicable_recipes/openai_chat_with_hvplot.py
index e8f4631..a4bc104 100644
--- a/docs/examples/applicable_recipes/openai_chat_with_hvplot.py
+++ b/docs/examples/applicable_recipes/openai_chat_with_hvplot.py
@@ -2,6 +2,7 @@
We use [OpenAI *Function Calling*](https://platform.openai.com/docs/guides/function-calling) and
[hvPlot](https://hvplot.holoviz.org/) to create an **advanced chatbot** that can create plots.
"""
+
import json
from pathlib import Path
diff --git a/docs/examples/chat_features/chained_response.py b/docs/examples/chat_features/chained_response.py
index eac00dd..c710193 100644
--- a/docs/examples/chat_features/chained_response.py
+++ b/docs/examples/chat_features/chained_response.py
@@ -38,7 +38,7 @@ async def callback(contents: str, user: str, instance: pn.chat.ChatInterface):
instance.respond()
elif user == PERSON_2:
instance.send(
- f"Yup, I heard!",
+ "Yup, I heard!",
user=PERSON_3,
avatar="😆",
respond=False,
diff --git a/docs/examples/chat_features/control_callback_response.py b/docs/examples/chat_features/control_callback_response.py
index a2ef65b..b3c89e3 100644
--- a/docs/examples/chat_features/control_callback_response.py
+++ b/docs/examples/chat_features/control_callback_response.py
@@ -23,7 +23,10 @@ async def callback(contents: str, user: str, instance: pn.chat.ChatInterface):
# use send instead of stream/yield/return to keep the placeholder text
# while still sending a message; ensure respond=False to avoid a recursive loop
instance.send(
- "Let me flip the coin for you...", user="Game Master", avatar="🎲", respond=False
+ "Let me flip the coin for you...",
+ user="Game Master",
+ avatar="🎲",
+ respond=False,
)
await sleep(1)
@@ -41,7 +44,11 @@ async def callback(contents: str, user: str, instance: pn.chat.ChatInterface):
# equivalently, use a dict instead of a pn.chat.ChatMessage
yield {"object": f"Woohoo, {result}! You win!", "user": "Coin", "avatar": "🎲"}
else:
- yield {"object": f"Aw, got {result}. Try again!", "user": "Coin", "avatar": "🎲"}
+ yield {
+ "object": f"Aw, got {result}. Try again!",
+ "user": "Coin",
+ "avatar": "🎲",
+ }
chat_interface = pn.chat.ChatInterface(
diff --git a/docs/examples/chat_features/stream_echo_chat.py b/docs/examples/chat_features/stream_echo_chat.py
index f8166b5..150940f 100644
--- a/docs/examples/chat_features/stream_echo_chat.py
+++ b/docs/examples/chat_features/stream_echo_chat.py
@@ -12,7 +12,6 @@
without it, only one letter would be displayed at a time.
"""
-
from asyncio import sleep
import panel as pn
diff --git a/docs/examples/chat_features/styled_slim_interface.py b/docs/examples/chat_features/styled_slim_interface.py
index 6824b66..fdee428 100644
--- a/docs/examples/chat_features/styled_slim_interface.py
+++ b/docs/examples/chat_features/styled_slim_interface.py
@@ -7,6 +7,7 @@
- Set `show_*` parameters to `False` to hide the respective buttons.
- Use `message_params` to customize the appearance of each chat messages.
"""
+
import panel as pn
pn.extension()
diff --git a/docs/kickstart_snippets.md b/docs/kickstart_snippets.md
index 434b1ea..aa4fbdb 100644
--- a/docs/kickstart_snippets.md
+++ b/docs/kickstart_snippets.md
@@ -18,6 +18,14 @@ Highlights:
- Uses `serialize` to get chat history from the `ChatInterface`.
- Uses `yield` to continuously concatenate the parts of the response.
+
+
+
+
Source code for llama_cpp_python_.py
diff --git a/pyproject.toml b/pyproject.toml
index 93f68e5..7f5962a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -97,14 +97,14 @@ mistralai = [
langchain = [
"langchain>=0.0.350",
]
-llama_index = [
+llamaindex = [
"llama_index>=0.10.40",
]
-llama_cpp_python = [
+llamacpp = [
"llama_cpp_python",
]
all = [
- "panel-chat-examples[openai,mistralai,langchain,llama_index,llama_cpp]",
+ "panel-chat-examples[openai,mistralai,langchain,llamaindex,llamacpp]",
]
[project.urls]
diff --git a/tests/conftest.py b/tests/conftest.py
index 64aca38..7cb936e 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,4 +1,5 @@
"""Sahred pytest configuration and fixtures"""
+
import os
import re
from pathlib import Path
diff --git a/tests/locustfile.py b/tests/locustfile.py
index d69e00f..71eb8a2 100644
--- a/tests/locustfile.py
+++ b/tests/locustfile.py
@@ -1,4 +1,5 @@
"""Locust load test file"""
+
from pathlib import Path
from random import choice
diff --git a/tests/test_all.py b/tests/test_all.py
index e31a336..eba10b5 100644
--- a/tests/test_all.py
+++ b/tests/test_all.py
@@ -1,4 +1,5 @@
"""Test all app .py files py running them with python"""
+
import subprocess
from pathlib import Path
@@ -12,9 +13,11 @@ def test_app(app_path):
def test_has_thumbnail(app_path):
name = Path(app_path).name
- assert (THUMBNAILS_PATH / name.replace(".py", ".png")).exists()
+ assert (
+ THUMBNAILS_PATH / name.replace(".py", ".png").replace("_.png", ".png")
+ ).exists()
def test_has_video(app_path):
name = Path(app_path).name
- assert (VIDEOS_PATH / name.replace(".py", ".mp4")).exists()
+ assert (VIDEOS_PATH / name.replace(".py", ".mp4").replace("_.mp4", ".mp4")).exists()
diff --git a/tests/ui/inputs.py b/tests/ui/inputs.py
index 48b4144..88cfaa6 100644
--- a/tests/ui/inputs.py
+++ b/tests/ui/inputs.py
@@ -1,5 +1,3 @@
-import os
-import re
import time
from pathlib import Path
diff --git a/tests/ui/test_all.py b/tests/ui/test_all.py
index 7cff605..0b2ecf0 100644
--- a/tests/ui/test_all.py
+++ b/tests/ui/test_all.py
@@ -1,4 +1,5 @@
"""Test the UI of all apps via Playwright"""
+
import os
import sys
import time