From 60704ab5d862b8f9b6a28904bcbbf49abda14356 Mon Sep 17 00:00:00 2001 From: Jakob Pinterits Date: Sun, 7 Apr 2024 22:47:45 +0200 Subject: [PATCH] bugfixes in chatbot snippets --- rio/common.py | 10 ++++------ .../components/empty_chat_placeholder.py | 8 ++++---- .../project-template-AI Chatbot/pages/chat_page.py | 3 ++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/rio/common.py b/rio/common.py index 38d1938d..d34c7cbe 100644 --- a/rio/common.py +++ b/rio/common.py @@ -8,7 +8,7 @@ from io import BytesIO, StringIO from pathlib import Path from typing import * # type: ignore -import imy.asset_manager +import imy.assets import imy.package_metadata from PIL.Image import Image from typing_extensions import Annotated @@ -45,7 +45,7 @@ Readonly = Annotated[T, _READONLY] ImageLike = Path | Image | URL | bytes -ASSET_MANGER: imy.asset_manager.AssetManager = imy.asset_manager.AssetManager( +ASSET_MANGER: imy.assets.AssetManager = imy.assets.AssetManager( xz_dir=RIO_ASSETS_DIR, cache_dir=USER_CACHE_DIR / "rio", version=imy.package_metadata.get_package_version("rio-ui"), @@ -130,12 +130,10 @@ class FileInfo: return self._contents.decode(encoding) @overload - async def open(self, type: Literal["r"]) -> StringIO: - ... + async def open(self, type: Literal["r"]) -> StringIO: ... @overload - async def open(self, type: Literal["rb"]) -> BytesIO: - ... + async def open(self, type: Literal["rb"]) -> BytesIO: ... async def open(self, type: Literal["r", "rb"] = "r") -> StringIO | BytesIO: """ diff --git a/rio/snippets/snippet-files/project-template-AI Chatbot/components/empty_chat_placeholder.py b/rio/snippets/snippet-files/project-template-AI Chatbot/components/empty_chat_placeholder.py index 89daca7d..5089403f 100644 --- a/rio/snippets/snippet-files/project-template-AI Chatbot/components/empty_chat_placeholder.py +++ b/rio/snippets/snippet-files/project-template-AI Chatbot/components/empty_chat_placeholder.py @@ -82,22 +82,22 @@ class EmptyChatPlaceholder(rio.Component): ), rio.Row( comps.ChatSuggestionCard( - "restaurant", + "material/restaurant", "Suggest ways to make a dish more delicious", on_press=self.on_question, ), comps.ChatSuggestionCard( - "coffee", + "material/coffee", "What's the best way to store coffee?", on_press=self.on_question, ), comps.ChatSuggestionCard( - "co-present", + "material/co-present", "Help me improve my presentation technique", on_press=self.on_question, ), comps.ChatSuggestionCard( - "work", + "material/work", "Draft a job application email for me", on_press=self.on_question, ), diff --git a/rio/snippets/snippet-files/project-template-AI Chatbot/pages/chat_page.py b/rio/snippets/snippet-files/project-template-AI Chatbot/pages/chat_page.py index 54ad68b2..85c16a3b 100644 --- a/rio/snippets/snippet-files/project-template-AI Chatbot/pages/chat_page.py +++ b/rio/snippets/snippet-files/project-template-AI Chatbot/pages/chat_page.py @@ -1,10 +1,11 @@ from __future__ import annotations from dataclasses import KW_ONLY, field -from datetime import datetime, timezone from typing import * # type: ignore # +from datetime import datetime, timezone + import openai import rio