diff --git a/libs/py_core/poetry.lock b/libs/py_core/poetry.lock index a416ad8..b99d6da 100644 --- a/libs/py_core/poetry.lock +++ b/libs/py_core/poetry.lock @@ -331,7 +331,7 @@ files = [ [[package]] name = "chatlib" -version = "0.7.2" +version = "0.7.3" description = "A generalizable Python Chatbot Library" optional = false python-versions = "^3.10" @@ -360,8 +360,8 @@ yaspin = "^2.3.0" [package.source] type = "git" url = "https://github.com/yghokim/chatlib.git" -reference = "0.7.2" -resolved_reference = "74996e88783225d7b74229dd0770b073b3ce48eb" +reference = "0.7.3" +resolved_reference = "34c82bdd1de0a6b1560ca40daa057454337c0f5a" [[package]] name = "cohere" @@ -1413,7 +1413,6 @@ description = "Nvidia JIT LTO Library" optional = false python-versions = ">=3" files = [ - {file = "nvidia_nvjitlink_cu12-12.4.99-py3-none-manylinux2014_aarch64.whl", hash = "sha256:75d6498c96d9adb9435f2bbdbddb479805ddfb97b5c1b32395c694185c20ca57"}, {file = "nvidia_nvjitlink_cu12-12.4.99-py3-none-manylinux2014_x86_64.whl", hash = "sha256:c6428836d20fe7e327191c175791d38570e10762edc588fb46749217cd444c74"}, {file = "nvidia_nvjitlink_cu12-12.4.99-py3-none-win_amd64.whl", hash = "sha256:991905ffa2144cb603d8ca7962d75c35334ae82bf92820b6ba78157277da1ad2"}, ] @@ -2832,4 +2831,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.11.8,<3.12" -content-hash = "dccf7eb385e00f5ba6a3157e1cb7f57de966ce7a53d5d28eeea38f5c4ddac2f0" +content-hash = "76dc225615c51954d446eb6b2779223ede6a1f2ac40cae3770364da3277a0157" diff --git a/libs/py_core/py_core/system/task/card_recommendation.py b/libs/py_core/py_core/system/task/card_recommendation.py index 5e205f3..a44d2c5 100644 --- a/libs/py_core/py_core/system/task/card_recommendation.py +++ b/libs/py_core/py_core/system/task/card_recommendation.py @@ -33,27 +33,22 @@ def __init__(self): @staticmethod def __prompt_generator(input: Dialogue, params: ChildCardRecommendationParams) -> str: - prompt = f""" + prompt = """ - You are a helpful assistant that serves as an Alternative Augmented Communication tool. - Suppose that you are helping a communication with a child and parents in Korean. The autistic child has the language proficiency of a 6 to 8-year-old in Korean, so recommendations should consider their cognitive level. - Given the last message of the parents, suggest a list of keywords that can help the child pick to create a sentence as an answer. - Use honorific form of Korean for actions and emotions, such as "~해요" or "~어요", if possible. -Proceed in the following order. -1. [nouns] : Provide nouns that reflect detailed context based on your parents' questions. -2. [actions] : Provide words for the action that can be matched with the nouns suggested in [nouns]. -3. [emotions] : Suggest emotions that the child might want to express in the situation, including both positive and negative emotions and needs. +Return a JSON object organizing the keywords as in the following: +{ + "nouns": Array // Nouns that reflect detailed context based on your parents' questions. + "actions": Array // Actions that can be matched with the nouns suggested in [nouns]. + "emotions": Array // Emotions that the child might want to express in the situation, including both positive and negative emotions and needs. +}"""f""" {"" if params.prev_recommendation is None else "- The child had previous recommendation: " + params.prev_recommendation.json() + ". Try to generate phrases that are distinct to this previous recommendation."} -{"" if params.interim_cards is None else "- The child had selected the following cards: " + ', '.join([card.simple_str() for card in params.interim_cards]) + ". The generated recommendation should be relevant to these selections."} - -Note that the output must be JSON, formatted like the following: - - "nouns": Array - "actions: Array - "emotions": Array - -The result should be in Korean and please provide up to four options for each element. +{"" if params.interim_cards is None else "- The child had selected the following cards: " + ', '.join([card.text for card in params.interim_cards]) + ". The generated recommendation should be relevant to these selections."} +- Provide up to five options for each category. """ return prompt diff --git a/libs/py_core/py_core/system/task/parent_guide_recommendation.py b/libs/py_core/py_core/system/task/parent_guide_recommendation.py index a8e83ef..6706110 100644 --- a/libs/py_core/py_core/system/task/parent_guide_recommendation.py +++ b/libs/py_core/py_core/system/task/parent_guide_recommendation.py @@ -31,7 +31,7 @@ def __prompt_generator(input: Dialogue, params: ParentGuideRecommendationParams) Return a JSON object in the following format: { - recommendations: Array<{ + "recommendations": Array<{ "example": Provide response or question that parents can make to the child's message. "guide": Provide guide for parents of autistic children to consider when responding to the child's answer. Keep the guide short and concise so parents can read it quickly and move on. }> diff --git a/libs/py_core/pyproject.toml b/libs/py_core/pyproject.toml index 4bf78da..6c88367 100644 --- a/libs/py_core/pyproject.toml +++ b/libs/py_core/pyproject.toml @@ -23,7 +23,7 @@ readme = 'README.md' [tool.poetry.dependencies] python = ">=3.11.8,<3.12" pendulum = "^3.0.0" - chatlib = {git = "https://github.com/yghokim/chatlib.git", tag="0.7.2"} + chatlib = {git = "https://github.com/yghokim/chatlib.git", tag="0.7.3"} pydantic = "^2.6.4" questionary = "^2.0.1" diff --git a/libs/py_core/test_cli.py b/libs/py_core/test_cli.py index b75bcbb..dbc5834 100644 --- a/libs/py_core/test_cli.py +++ b/libs/py_core/test_cli.py @@ -15,29 +15,6 @@ from py_core.system.task.parent_guide_recommendation import ParentGuideRecommendationGenerator - -async def test_processor(): - child_card_recommender = ChildCardRecommendationGenerator() - - card_recommendation_result = await child_card_recommender.generate( - [DialogueMessage(speaker=DialogueRole.Parent, content="할머니 댁 가는 거 알지? 할머니네 가면 뭐 하고 싶니?")], - [CardInfo(text="물놀이", category="noun"), CardInfo(text="가고싶어요", category="noun")], None) - - print("==Child card recommendation=========") - print(card_recommendation_result.model_dump_json(indent=2)) - - parent_guide_recommender = ParentGuideRecommendationGenerator() - - parent_guide_recommendation = await parent_guide_recommender.generate([ - DialogueMessage(speaker=DialogueRole.Parent, content="할머니 댁 가는 거 알지? 할머니네 가면 뭐 하고 싶니?"), - DialogueMessage(speaker=DialogueRole.Child, - content=[CardInfo(text="수영", category="noun"), CardInfo(text="할아버지", category="noun")]) - ], ) - - print("==Parent guide recommendation=========") - print(parent_guide_recommendation.model_dump_json(indent=2)) - - async def test_session_loop(session: ModeratorSession): current_card_recommendation_result: ChildCardRecommendationResult | None = None current_parent_guide_recommendation_result: ParentGuideRecommendationResult | None = None