Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 committed May 29, 2024
1 parent 55ee7fe commit 082affc
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/applicable_recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file added docs/assets/thumbnails/llama_cpp_python.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/thumbnails/llama_index.mp4
Binary file not shown.
Binary file added docs/assets/thumbnails/llama_index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/videos/llama_cpp_python.mp4
Binary file not shown.
Binary file added docs/assets/videos/llama_index.mp4
Binary file not shown.
15 changes: 11 additions & 4 deletions docs/chat_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ Highlights:
without it, only one letter would be displayed at a time.
"""


from asyncio import sleep

import panel as pn
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand All @@ -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(
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions docs/kickstart_snippets.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Highlights:
- Uses `serialize` to get chat history from the `ChatInterface`.
- Uses `yield` to continuously concatenate the parts of the response.

<video controls poster="../assets/thumbnails/llama_cpp_python.png" >
<source src="../assets/videos/llama_cpp_python.mp4" type="video/mp4"
style="max-height: 400px; max-width: 600px;">
Your browser does not support the video tag.
</video>



<details>

<summary>Source code for <a href='../examples/kickstart_snippets/llama_cpp_python_.py' target='_blank'>llama_cpp_python_.py</a></summary>
Expand Down
6 changes: 4 additions & 2 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,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()

0 comments on commit 082affc

Please sign in to comment.