From 2fb0f32293477a196cdbaace3749b0b08bfaf674 Mon Sep 17 00:00:00 2001 From: yun97 <1035677207@qq.com> Date: Tue, 24 Jan 2023 22:05:35 +0800 Subject: [PATCH 1/4] add client_support --- .../ad_from_product_description/readme.md | 2 +- softwares/analogy_maker/readme.md | 2 +- softwares/antonyms/readme.md | 2 +- softwares/calculate_time_complexity/readme.md | 2 +- softwares/conversation/friend/readme.md | 2 +- softwares/conversation/general/readme.md | 2 +- softwares/conversation/sarcastic/readme.md | 2 +- softwares/create_study_notes/readme.md | 2 +- softwares/esrb_rating/readme.md | 2 +- softwares/essay_outline/readme.md | 2 +- .../extract_contact_information/readme.md | 2 +- softwares/gaokao_grammar_correction/readme.md | 2 +- softwares/grammar_correction/readme.md | 2 +- softwares/headline_generation/readme.md | 11 -- softwares/interview_questions/readme.md | 2 +- softwares/javascript_helper_chatbot/readme.md | 2 +- .../javascript_one_line_function/readme.md | 2 +- softwares/javascript_to_python/readme.md | 2 +- softwares/keywords/readme.md | 4 +- .../readme.md | 2 +- .../marv_the_sarcastic_chatbot/readme.md | 2 +- .../micro_horror_story_creator/readme.md | 2 +- softwares/mood_to_color/readme.md | 2 +- softwares/movie_to_emoji/readme.md | 11 -- softwares/named_entity_recognition/readme.md | 2 +- .../natural_language_to_openai_api/readme.md | 2 +- .../natural_language_to_stripe_api/readme.md | 2 +- softwares/parse_unstructured_data/readme.md | 2 +- softwares/personas/client_support/__init__.py | 0 softwares/personas/client_support/software.py | 104 +++++++++++ .../personas/client_support/software_test.py | 24 +++ softwares/personas/fantasy_wizard/__init__.py | 0 softwares/personas/fantasy_wizard/software.py | 100 +++++++++++ .../personas/fantasy_wizard/software_test.py | 24 +++ softwares/product_name_generator/readme.md | 2 +- softwares/prompt_engineer/complete/readme.md | 167 +++++++++--------- softwares/prompt_engineer/insert/readme.md | 167 +++++++++--------- softwares/prompt_engineer/readme.md | 167 +++++++++--------- softwares/python_bug_fixer/readme.md | 2 +- softwares/recipe_creator/readme.md | 2 +- softwares/restaurant_review_creator/readme.md | 2 +- .../science_fiction_book_list_maker/readme.md | 2 +- softwares/scoring/readme.md | 2 +- softwares/sentiment_classifier/readme.md | 2 +- softwares/spreadsheet_creator/readme.md | 2 +- softwares/sql_request/readme.md | 2 +- softwares/sql_translate/readme.md | 2 +- softwares/summarization/general/readme.md | 2 +- .../summarization/meeting_notes/readme.md | 2 +- softwares/text_to_command/readme.md | 2 +- softwares/third_person_converter/readme.md | 2 +- .../translate_programming_languages/readme.md | 2 +- softwares/turn_by_turn_directions/readme.md | 2 +- softwares/vr_fitness_idea_generator/readme.md | 2 +- softwares/write_a_python_docstring/readme.md | 2 +- 55 files changed, 546 insertions(+), 319 deletions(-) delete mode 100644 softwares/headline_generation/readme.md delete mode 100644 softwares/movie_to_emoji/readme.md create mode 100644 softwares/personas/client_support/__init__.py create mode 100644 softwares/personas/client_support/software.py create mode 100644 softwares/personas/client_support/software_test.py create mode 100644 softwares/personas/fantasy_wizard/__init__.py create mode 100644 softwares/personas/fantasy_wizard/software.py create mode 100644 softwares/personas/fantasy_wizard/software_test.py diff --git a/softwares/ad_from_product_description/readme.md b/softwares/ad_from_product_description/readme.md index 4d88d14..df0f320 100644 --- a/softwares/ad_from_product_description/readme.md +++ b/softwares/ad_from_product_description/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/ad_from_product_description` +# Software: `softwares\ad_from_product_description` This promptware is used to turn a product description into ad copy. diff --git a/softwares/analogy_maker/readme.md b/softwares/analogy_maker/readme.md index e51f119..fde5453 100644 --- a/softwares/analogy_maker/readme.md +++ b/softwares/analogy_maker/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/analogy_maker` +# Software: `softwares\analogy_maker` This promptware is used to create analogies. Modified from a community prompt to require fewer examples. diff --git a/softwares/antonyms/readme.md b/softwares/antonyms/readme.md index ba73cc6..f99f47a 100644 --- a/softwares/antonyms/readme.md +++ b/softwares/antonyms/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/antonyms` +# Software: `softwares\antonyms` This promptware is used to identify the relationship between two words diff --git a/softwares/calculate_time_complexity/readme.md b/softwares/calculate_time_complexity/readme.md index b3c8161..5712047 100644 --- a/softwares/calculate_time_complexity/readme.md +++ b/softwares/calculate_time_complexity/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/calculate_time_complexity` +# Software: `softwares\calculate_time_complexity` This promptware is used to find the time complexity of a function. diff --git a/softwares/conversation/friend/readme.md b/softwares/conversation/friend/readme.md index 63d4962..fcfc184 100644 --- a/softwares/conversation/friend/readme.md +++ b/softwares/conversation/friend/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/conversation/friend` +# Software: `softwares\conversation\friend` Emulate a text message conversation. diff --git a/softwares/conversation/general/readme.md b/softwares/conversation/general/readme.md index 89e1ef3..0ec691f 100644 --- a/softwares/conversation/general/readme.md +++ b/softwares/conversation/general/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/conversation/general` +# Software: `softwares\conversation\general` Open ended conversation with an AI assistant. diff --git a/softwares/conversation/sarcastic/readme.md b/softwares/conversation/sarcastic/readme.md index 851d9e1..519650b 100644 --- a/softwares/conversation/sarcastic/readme.md +++ b/softwares/conversation/sarcastic/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/conversation/sarcastic` +# Software: `softwares\conversation\sarcastic` Marv is a factual chatbot that is also sarcastic. diff --git a/softwares/create_study_notes/readme.md b/softwares/create_study_notes/readme.md index 20df7c7..b48070e 100644 --- a/softwares/create_study_notes/readme.md +++ b/softwares/create_study_notes/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/create_study_notes` +# Software: `softwares\create_study_notes` This promptware is used to provide a topic and get study notes. diff --git a/softwares/esrb_rating/readme.md b/softwares/esrb_rating/readme.md index 2e74c23..7ea1ac9 100644 --- a/softwares/esrb_rating/readme.md +++ b/softwares/esrb_rating/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/esrb_rating` +# Software: `softwares\esrb_rating` This promptware is used to categorize text based upon ESRB ratings. diff --git a/softwares/essay_outline/readme.md b/softwares/essay_outline/readme.md index 4e643bd..3e30176 100644 --- a/softwares/essay_outline/readme.md +++ b/softwares/essay_outline/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/essay_outline` +# Software: `softwares\essay_outline` This promptware is used to generate an outline for a research topic. diff --git a/softwares/extract_contact_information/readme.md b/softwares/extract_contact_information/readme.md index 5fed6e2..d8dedb1 100644 --- a/softwares/extract_contact_information/readme.md +++ b/softwares/extract_contact_information/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/extract_contact_information` +# Software: `softwares\extract_contact_information` This promptware is used to extract contact information from a block of text. diff --git a/softwares/gaokao_grammar_correction/readme.md b/softwares/gaokao_grammar_correction/readme.md index d5d7d24..ea0f934 100644 --- a/softwares/gaokao_grammar_correction/readme.md +++ b/softwares/gaokao_grammar_correction/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/gaokao_grammar_correction` +# Software: `softwares\gaokao_grammar_correction` Gaokao English Grammar Correction diff --git a/softwares/grammar_correction/readme.md b/softwares/grammar_correction/readme.md index efe508d..73affa9 100644 --- a/softwares/grammar_correction/readme.md +++ b/softwares/grammar_correction/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/grammar_correction` +# Software: `softwares\grammar_correction` Corrects sentences into standard English. diff --git a/softwares/headline_generation/readme.md b/softwares/headline_generation/readme.md deleted file mode 100644 index 96ccc4a..0000000 --- a/softwares/headline_generation/readme.md +++ /dev/null @@ -1,11 +0,0 @@ -# Software: `softwares/headline_generation` - -This software is used to generate headline for a news article with different styles - -```python -import promptware -software = promptware.install("headline_generation") -output = software.execute("传统生活方式相关的风险因素,包括吸烟、过度饮酒、缺乏运动、不良饮食习惯和肥胖,与死亡风险增加有关,尤其是慢性病。然而,只有少数研究评估了个人生活方式因素(如吸烟和饮酒)对中国人口预期寿命的影响。综合生活方式行为对中国人预期寿命的影响尚不清楚,需要填补证据空白。2022年8月1日,北京大学李立明、吕筠与中国疾病预防控制中心赵丽云团队在 Lancet Public Health (IF=72) 期刊在线发表题为“Healthy lifestyle and life expectancy at age 30 years in the Chinese population: an observational study”的研究论文,该研究调查了健康生活方式对中国人30岁时预期寿命影响。五种低风险生活方式:从不吸烟或戒烟、不过度饮酒、积极运动、健康的饮食习惯和健康的体型)中,与五种生活方式均低风险和只有一个或没有低风险的个体相比,男性在30岁时的预期寿命延长8.8年(95% CI 6.8-10.7),女性为8.1年(6.5–9.9)。该研究结果表明,通过公共卫生干预这五种健康生活方式可能会大幅延长中国人口的预期寿命。") -# output: -# 中国人,不只要“吃”!这5种生活方式,可延寿8-9年 -``` \ No newline at end of file diff --git a/softwares/interview_questions/readme.md b/softwares/interview_questions/readme.md index 00cc74f..0fc43db 100644 --- a/softwares/interview_questions/readme.md +++ b/softwares/interview_questions/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/interview_questions` +# Software: `softwares\interview_questions` This promptware is used to create interview questions. diff --git a/softwares/javascript_helper_chatbot/readme.md b/softwares/javascript_helper_chatbot/readme.md index 3467e88..be5b524 100644 --- a/softwares/javascript_helper_chatbot/readme.md +++ b/softwares/javascript_helper_chatbot/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/javascript_helper_chatbot` +# Software: `softwares\javascript_helper_chatbot` This promptware is used to create a message-style chatbot that can answer questions about using JavaScript. It uses a few examples to get the conversation started. diff --git a/softwares/javascript_one_line_function/readme.md b/softwares/javascript_one_line_function/readme.md index 65e79ad..ec60a59 100644 --- a/softwares/javascript_one_line_function/readme.md +++ b/softwares/javascript_one_line_function/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/javascript_one_line_function` +# Software: `softwares\javascript_one_line_function` This promptware is used to turn a JavaScript function into a one liner. diff --git a/softwares/javascript_to_python/readme.md b/softwares/javascript_to_python/readme.md index ec264fa..4ee9582 100644 --- a/softwares/javascript_to_python/readme.md +++ b/softwares/javascript_to_python/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/javascript_to_python` +# Software: `softwares\javascript_to_python` This promptware is used to create simple SQL queries. diff --git a/softwares/keywords/readme.md b/softwares/keywords/readme.md index ff013dd..713b5c4 100644 --- a/softwares/keywords/readme.md +++ b/softwares/keywords/readme.md @@ -1,11 +1,11 @@ -# Software: `softwares/keywords` +# Software: `softwares\keywords` This promptware is used to extract keywords from a block of text. At a lower temperature it picks keywords from the text. At a higher temperature it will generate related keywords which can be helpful for creating search indexes. ```python import promptware software = promptware.install("keywords") -output = software.execute("Black-on-black ware is a 20th- and 21st-century pottery tradition developed by the Puebloan Native American ceramic artists in Northern New Mexico. Traditional reduction-fired blackware has been made for centuries by pueblo artists. Black-on-black ware of the past century is produced with a smooth surface, with the designs applied through selective burnishing or the application of refractory slip. Another style involves carving or incising designs and selectively polishing the raised areas. For generations several families from Kha'po Owingeh and P'ohwhóge Owingeh pueblos have been making black-on-black ware with the techniques passed down from matriarch potters. Artists from other pueblos have also produced black-on-black ware. Several contemporary artists have created works honoring the pottery of their ancestors.") +output = software.execute("Black-on-black ware is a 20th- and 21st-century pottery tradition developed by the Puebloan Native American ceramic artists in Northern New Mexico. Traditional reduction-fired blackware has been made for centuries by pueblo artists. Black-on-black ware of the past century is produced with a smooth surface, with the designs applied through selective burnishing or the application of refractory slip. Another style involves carving or incising designs and selectively polishing the raised areas. For generations several families from Kha'po Owingeh and P'ohwhge Owingeh pueblos have been making black-on-black ware with the techniques passed down from matriarch potters. Artists from other pueblos have also produced black-on-black ware. Several contemporary artists have created works honoring the pottery of their ancestors.") # output: # Keywords: black-on-black ware, 20th century, 21st century, Puebloan Native American, ceramic artists, Northern New Mexico, reduction-fired blackware, pueblo artists, burnishing/ slip/carving/incising designs/polishing ``` \ No newline at end of file diff --git a/softwares/linguistic_acceptability_classification/readme.md b/softwares/linguistic_acceptability_classification/readme.md index 577861d..1f450d6 100644 --- a/softwares/linguistic_acceptability_classification/readme.md +++ b/softwares/linguistic_acceptability_classification/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/linguistic_acceptability_classification` +# Software: `softwares\linguistic_acceptability_classification` This promptware is used to identify whether a sentence is a grammatical English sentence based on some learning samples from the cola dataset. diff --git a/softwares/marv_the_sarcastic_chatbot/readme.md b/softwares/marv_the_sarcastic_chatbot/readme.md index 12be869..07b4c4c 100644 --- a/softwares/marv_the_sarcastic_chatbot/readme.md +++ b/softwares/marv_the_sarcastic_chatbot/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/marv_the_sarcastic_chatbot` +# Software: `softwares\marv_the_sarcastic_chatbot` This promptware is used to create a factual chatbot that is also sarcastic. diff --git a/softwares/micro_horror_story_creator/readme.md b/softwares/micro_horror_story_creator/readme.md index cbe1c08..e27417f 100644 --- a/softwares/micro_horror_story_creator/readme.md +++ b/softwares/micro_horror_story_creator/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/micro_horror_story_creator` +# Software: `softwares\micro_horror_story_creator` This promptware is used to creates two to three sentence short horror stories from a topic input. diff --git a/softwares/mood_to_color/readme.md b/softwares/mood_to_color/readme.md index 3772d95..5ff5d0e 100644 --- a/softwares/mood_to_color/readme.md +++ b/softwares/mood_to_color/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/mood_to_color` +# Software: `softwares\mood_to_color` This promptware is used to turn a text description into a color. diff --git a/softwares/movie_to_emoji/readme.md b/softwares/movie_to_emoji/readme.md deleted file mode 100644 index 5230866..0000000 --- a/softwares/movie_to_emoji/readme.md +++ /dev/null @@ -1,11 +0,0 @@ -# Software: `softwares/movie_to_emoji` - -This promptware is used to convert movie titles into emoji. - -```python -import promptware -software = promptware.install("movie_to_emoji") -output = software.execute("Star Wars:") -# output: -# ⭐️🌌 -``` \ No newline at end of file diff --git a/softwares/named_entity_recognition/readme.md b/softwares/named_entity_recognition/readme.md index 3dadbd5..079d73a 100644 --- a/softwares/named_entity_recognition/readme.md +++ b/softwares/named_entity_recognition/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/named_entity_recognition` +# Software: `softwares\named_entity_recognition` This promptware is used to extract entities in the text diff --git a/softwares/natural_language_to_openai_api/readme.md b/softwares/natural_language_to_openai_api/readme.md index e057938..f8f16b9 100644 --- a/softwares/natural_language_to_openai_api/readme.md +++ b/softwares/natural_language_to_openai_api/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/natural_language_to_openai_api` +# Software: `softwares\natural_language_to_openai_api` This promptware is used to convert natural lanugage to OpenAI API. diff --git a/softwares/natural_language_to_stripe_api/readme.md b/softwares/natural_language_to_stripe_api/readme.md index 0b5bbe3..04603eb 100644 --- a/softwares/natural_language_to_stripe_api/readme.md +++ b/softwares/natural_language_to_stripe_api/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/natural_language_to_stripe_api` +# Software: `softwares\natural_language_to_stripe_api` This promptware is used to convert natural lanugage to Stripe API. diff --git a/softwares/parse_unstructured_data/readme.md b/softwares/parse_unstructured_data/readme.md index d40324d..f9224af 100644 --- a/softwares/parse_unstructured_data/readme.md +++ b/softwares/parse_unstructured_data/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/parse_unstructured_data` +# Software: `softwares\parse_unstructured_data` Create tables from long form text by specifying a structure and supplying some examples. diff --git a/softwares/personas/client_support/__init__.py b/softwares/personas/client_support/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/softwares/personas/client_support/software.py b/softwares/personas/client_support/software.py new file mode 100644 index 0000000..61c1c13 --- /dev/null +++ b/softwares/personas/client_support/software.py @@ -0,0 +1,104 @@ +from __future__ import annotations + +from promptware.constants import ( + ApplicationCategory, + ApplicationSubcategory, + DesignPatternType, + LanguageType, + LicenseType, + PlatformType, + TaskType, +) +from promptware.info import SoftwareInfo +from promptware.kernels.plm import PLMKernelConfig +from promptware.promptware import PromptConfig, Promptware + +client_support = PromptConfig( + name="client_support", + description="client_support", + instruction="Below is a series of chats between Support Agent and User. " + "Support Agent responds to User based on the <>.\n" + "<>\nSupport Agent is a professional, " + "high-end retail service professional who helps a User with their billing, " + "shipping, bugfix, and other related issues. " + "Support Agent always speaks formally, " + "using full sentences and proper punctuation. " + "Support Agent tries to understand the User's issue " + "in detail and suggests possible ways to fix the issue, " + "always being polite.", + demonstration=[ + "user: hi i've got a problem with my billing\n" + "bot: Hello, I'm here with customer support. " + "How can I help you today with your issue?", + "user: I got charged on my card but I don't think the order ever shipped\n" + "bot: I'm so sorry to hear that. Could you tell me the order number?", + "user: yeah it's 1234354\n", + "bot: Understood! I've just checked on the order and " + "it looks like our shipping was delayed. " + "It should be sent out by the end of today.", + "user: oh sweet thanks\n" + "bot: No problem at all. Is there anything else I can help you with today?", + ], + prompt_template=lambda input: f"user: {input['text']}\nbot:", + task=TaskType.qa_open_domain, +) + + +class PersonasPromptware(Promptware): + def _info(self) -> SoftwareInfo: + return SoftwareInfo( + description="client_support", + creator="OpenAI", + homepage="https://github.com/cohere-ai/sandbox-conversant-lib/" + "tree/main/conversant/personas", + reference="", + codebase_url="https://github.com/cohere-ai/s" + "andbox-conversant-lib/tree/main/conversant/personas", + license=LicenseType.no_license, + research_tasks=[TaskType.qa_open_domain], + application_categories=[ApplicationCategory.conversation], + application_subcategories=[ApplicationSubcategory.question_answering], + original_platform=PlatformType.gpt3, + design_pattern=DesignPatternType.standalone, + source_language=LanguageType.en, + target_language=LanguageType.en, + ) + + def _kernel_configs(self): + return { + "openai": PLMKernelConfig( + platform="openai", + model_name="text-curie-001", + max_tokens=200, + temperature=0.75, + top_p=1, + frequency_penalty=0.0, + presence_penalty=0.0, + ), + } + + def execute(self, input): + openai_kernel1 = self.kernel_configs["openai"].to_kernel() + if self.config_name == "default" or self.config_name == "client_support": + code = self.get_code(input, self.software_configs["client_support"]) + return self.normalize_output(openai_kernel1.execute(code)["text"]) + else: + raise ValueError("Unknown question answer type: {self.config_name}") + + def _software_configs(self): + if self.config_name == "default" or self.config_name == "client_support": + return {"client_support": client_support} + else: + raise ValueError("Unknown question answer type: {self.config_name}") + + def _example(self): + + if self.config_name == "default" or self.config_name == "client_support": + return { + "input": { + "text": "nah all looks good now!", + }, + "output": "Thank you for your time today and for checking in with us!", + } + else: + raise ValueError("Unknown question answer type: {self.config_name}") diff --git a/softwares/personas/client_support/software_test.py b/softwares/personas/client_support/software_test.py new file mode 100644 index 0000000..7ba41c6 --- /dev/null +++ b/softwares/personas/client_support/software_test.py @@ -0,0 +1,24 @@ +import os +import sys +import unittest + +current_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".")) +sys.path.append(current_path) + +from software import PersonasPromptware # noqa + + +class TestPersonasPromptware(unittest.TestCase): + def test_write_to_directory(self): + software = PersonasPromptware() + file_path = software.info.write_to_directory(current_path) + self.assertTrue(os.path.exists(file_path)) + + # def test_execute_default(self): + # software = PersonasPromptware() + # input = { + # "text": "nah all looks good now!" + # } + # result = software.execute(input) + # print(result) + # self.assertGreater(len(result), 0) diff --git a/softwares/personas/fantasy_wizard/__init__.py b/softwares/personas/fantasy_wizard/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/softwares/personas/fantasy_wizard/software.py b/softwares/personas/fantasy_wizard/software.py new file mode 100644 index 0000000..beb1151 --- /dev/null +++ b/softwares/personas/fantasy_wizard/software.py @@ -0,0 +1,100 @@ +from __future__ import annotations + +from promptware.constants import ( + ApplicationCategory, + ApplicationSubcategory, + DesignPatternType, + LanguageType, + LicenseType, + PlatformType, + TaskType, +) +from promptware.info import SoftwareInfo +from promptware.kernels.plm import PLMKernelConfig +from promptware.promptware import PromptConfig, Promptware + +fantasy_wizard = PromptConfig( + name="fantasy_wizard", + description="fantasy_wizard", + instruction="Below is a series of chats between Fantasy Wizard and User. " + "Fantasy Wizard responds to User based on the <>.\n" + "<>\nIn this chat, the Fantasy Wizard is from a distant, " + "magical land. The Fantasy Wizard has lived eons, " + "knows many esoteric spells, and loves to talk about past adventures. " + "The fantasy wizard talks in old fashioned English, " + "often referencing legendary places, creatures and artifacts.", + demonstration=[ + "user: hi\n" + "bot: Well met, fair traveller. What bringest thou to mine village?", + "user: I'm here to study magic\n" + "bot: Magic! Such powers are not to be meddled with lightly. " + "Haves't thou any latent magical ability? No, surely not...", + "user: no I can cast a few spells\n", + "bot: The town jester casteth spells! " + "But this is not magic. Magic is the summoning of grand elements. " + "I pray, thou seeketh mine help but art thou truly worthy...", + ], + prompt_template=lambda input: f"user: {input['text']}\nbot:", + task=TaskType.qa_open_domain, +) + + +class PersonasPromptware(Promptware): + def _info(self) -> SoftwareInfo: + return SoftwareInfo( + description="fantasy_wizard", + creator="OpenAI", + homepage="https://github.com/cohere-ai/sandbox-conversant-lib/" + "tree/main/conversant/personas", + reference="", + codebase_url="https://github.com/cohere-ai/sandbox-conversant-lib/" + "tree/main/conversant/personas", + license=LicenseType.no_license, + research_tasks=[TaskType.qa_open_domain], + application_categories=[ApplicationCategory.conversation], + application_subcategories=[ApplicationSubcategory.question_answering], + original_platform=PlatformType.gpt3, + design_pattern=DesignPatternType.standalone, + source_language=LanguageType.en, + target_language=LanguageType.en, + ) + + def _kernel_configs(self): + return { + "openai": PLMKernelConfig( + platform="openai", + model_name="text-curie-001", + max_tokens=200, + temperature=0.75, + top_p=1, + frequency_penalty=0.0, + presence_penalty=0.0, + ), + } + + def execute(self, input): + openai_kernel1 = self.kernel_configs["openai"].to_kernel() + if self.config_name == "default" or self.config_name == "fantasy_wizard": + code = self.get_code(input, self.software_configs["fantasy_wizard"]) + return self.normalize_output(openai_kernel1.execute(code)["text"]) + else: + raise ValueError("Unknown question answer type: {self.config_name}") + + def _software_configs(self): + if self.config_name == "default" or self.config_name == "fantasy_wizard": + return {"fantasy_wizard": fantasy_wizard} + else: + raise ValueError("Unknown question answer type: {self.config_name}") + + def _example(self): + + if self.config_name == "default" or self.config_name == "fantasy_wizard": + return { + "input": { + "text": "yeah maybe not, I gotta peace out and go now", + }, + "output": "Farewell, traveller. " + "Seek great power in the lands yonder...", + } + else: + raise ValueError("Unknown question answer type: {self.config_name}") diff --git a/softwares/personas/fantasy_wizard/software_test.py b/softwares/personas/fantasy_wizard/software_test.py new file mode 100644 index 0000000..cf3f28d --- /dev/null +++ b/softwares/personas/fantasy_wizard/software_test.py @@ -0,0 +1,24 @@ +import os +import sys +import unittest + +current_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".")) +sys.path.append(current_path) + +from software import PersonasPromptware # noqa + + +class TestPersonasPromptware(unittest.TestCase): + def test_write_to_directory(self): + software = PersonasPromptware() + file_path = software.info.write_to_directory(current_path) + self.assertTrue(os.path.exists(file_path)) + + # def test_execute_default(self): + # software = PersonasPromptware() + # input = { + # "text": "yeah maybe not, I gotta peace out and go now" + # } + # result = software.execute(input) + # print(result) + # self.assertGreater(len(result), 0) diff --git a/softwares/product_name_generator/readme.md b/softwares/product_name_generator/readme.md index 5a88be5..3b0ad09 100644 --- a/softwares/product_name_generator/readme.md +++ b/softwares/product_name_generator/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/product_name_generator` +# Software: `softwares\product_name_generator` This promptware is used to create product names from examples words. diff --git a/softwares/prompt_engineer/complete/readme.md b/softwares/prompt_engineer/complete/readme.md index f937948..13982a2 100644 --- a/softwares/prompt_engineer/complete/readme.md +++ b/softwares/prompt_engineer/complete/readme.md @@ -1,88 +1,87 @@ -# Software: `prompt_engineer` +# Software: `softwares\prompt_engineer\complete` +This promptware is used to generate an instruction based on given input pairs -## Example - -### Code ```python import promptware -software = promptware.install("prompt_engineer") -input = [ - ("aperiodic", "periodic"), - ("unsent", "sent"), -] -output = software.execute(input) -output = {"text":"the antonym of the word.", "score":-0.166} - -``` - -### Complete prompt of this example -```text - GPT3 is a good prompt engineer and it can help us to generate instruction based on input and output pairs. - - I gave a friend an instruction. Based on the instruction they produced the following input-output pairs: - - Input: I love this movie. - Output: positive - - Input: The movie is boring. - Output: negative - - The instruction was to find: the sentiment of the movie review. - - I gave a friend an instruction. Based on the instruction they produced the following input-output pairs: - - Input:aperiodic - Output:periodic - - Input:unsent - Output:sent - - The instruction was to find: -``` - - - -```python - -import promptware -software = promptware.install("./softwares/prompt_engineer", "insert") -input = [ - ("aperiodic", "periodic"), - ("unsent", "sent"), - ("sad","happy"), -] -output = software.execute(input) -print(output) - -#{'text': 'find the antonym of the word', 'score': -0.150508175} -``` - - -### Complete prompt of this example -```text -GPT3 is a good prompt engineer and it can help us to generate instruction based on input and output pairs. - -I instructed my friend to find the sentiment of the movie review. The friend read the instruction and wrote an output for every one of the inputs. Here are the input-output pairs: - -Input: I love this movie. -Output: positive - -Input: The movie is boring. -Output: negative - -Input: I love this book. -Output: positive - -I instructed my friend to [INSERT]. The friend read the instruction and wrote an output for every one of the inputs. Here are the input-output pairs: - -Input:aperiodic -Output:periodic - -Input:unsent -Output:sent - -Input:sad -Output:happy - -``` +software = promptware.install("prompt_engineer_complete") +output = software.execute("[['aperiodic', 'periodic'], ['unsent', 'sent']]") +# output: +# { +# ' +# t +# e +# x +# t +# ' +# : +# +# ' +# T +# h +# e +# +# s +# e +# n +# t +# i +# m +# e +# n +# t +# +# o +# f +# +# t +# h +# e +# +# m +# o +# v +# i +# e +# +# r +# e +# v +# i +# e +# w +# . +# ' +# , +# +# ' +# s +# c +# o +# r +# e +# ' +# : +# +# - +# 0 +# . +# 2 +# 5 +# 4 +# 5 +# 0 +# 9 +# 1 +# 3 +# 9 +# 0 +# 3 +# 5 +# 7 +# 1 +# 4 +# 2 +# 6 +# } +``` \ No newline at end of file diff --git a/softwares/prompt_engineer/insert/readme.md b/softwares/prompt_engineer/insert/readme.md index f937948..74c4dc2 100644 --- a/softwares/prompt_engineer/insert/readme.md +++ b/softwares/prompt_engineer/insert/readme.md @@ -1,88 +1,87 @@ -# Software: `prompt_engineer` +# Software: `softwares\prompt_engineer\insert` +This promptware is used to generate an instruction based on given input pairs -## Example - -### Code ```python import promptware -software = promptware.install("prompt_engineer") -input = [ - ("aperiodic", "periodic"), - ("unsent", "sent"), -] -output = software.execute(input) -output = {"text":"the antonym of the word.", "score":-0.166} - -``` - -### Complete prompt of this example -```text - GPT3 is a good prompt engineer and it can help us to generate instruction based on input and output pairs. - - I gave a friend an instruction. Based on the instruction they produced the following input-output pairs: - - Input: I love this movie. - Output: positive - - Input: The movie is boring. - Output: negative - - The instruction was to find: the sentiment of the movie review. - - I gave a friend an instruction. Based on the instruction they produced the following input-output pairs: - - Input:aperiodic - Output:periodic - - Input:unsent - Output:sent - - The instruction was to find: -``` - - - -```python - -import promptware -software = promptware.install("./softwares/prompt_engineer", "insert") -input = [ - ("aperiodic", "periodic"), - ("unsent", "sent"), - ("sad","happy"), -] -output = software.execute(input) -print(output) - -#{'text': 'find the antonym of the word', 'score': -0.150508175} -``` - - -### Complete prompt of this example -```text -GPT3 is a good prompt engineer and it can help us to generate instruction based on input and output pairs. - -I instructed my friend to find the sentiment of the movie review. The friend read the instruction and wrote an output for every one of the inputs. Here are the input-output pairs: - -Input: I love this movie. -Output: positive - -Input: The movie is boring. -Output: negative - -Input: I love this book. -Output: positive - -I instructed my friend to [INSERT]. The friend read the instruction and wrote an output for every one of the inputs. Here are the input-output pairs: - -Input:aperiodic -Output:periodic - -Input:unsent -Output:sent - -Input:sad -Output:happy - -``` +software = promptware.install("prompt_engineer_insert") +output = software.execute("[['aperiodic', 'periodic'], ['unsent', 'sent']]") +# output: +# { +# ' +# t +# e +# x +# t +# ' +# : +# +# ' +# T +# h +# e +# +# s +# e +# n +# t +# i +# m +# e +# n +# t +# +# o +# f +# +# t +# h +# e +# +# m +# o +# v +# i +# e +# +# r +# e +# v +# i +# e +# w +# . +# ' +# , +# +# ' +# s +# c +# o +# r +# e +# ' +# : +# +# - +# 0 +# . +# 2 +# 5 +# 4 +# 5 +# 0 +# 9 +# 1 +# 3 +# 9 +# 0 +# 3 +# 5 +# 7 +# 1 +# 4 +# 2 +# 6 +# } +``` \ No newline at end of file diff --git a/softwares/prompt_engineer/readme.md b/softwares/prompt_engineer/readme.md index f937948..d8b4809 100644 --- a/softwares/prompt_engineer/readme.md +++ b/softwares/prompt_engineer/readme.md @@ -1,88 +1,87 @@ -# Software: `prompt_engineer` +# Software: `softwares\prompt_engineer` +This promptware is used to generate an instruction based on given input pairs -## Example - -### Code ```python import promptware -software = promptware.install("prompt_engineer") -input = [ - ("aperiodic", "periodic"), - ("unsent", "sent"), -] -output = software.execute(input) -output = {"text":"the antonym of the word.", "score":-0.166} - -``` - -### Complete prompt of this example -```text - GPT3 is a good prompt engineer and it can help us to generate instruction based on input and output pairs. - - I gave a friend an instruction. Based on the instruction they produced the following input-output pairs: - - Input: I love this movie. - Output: positive - - Input: The movie is boring. - Output: negative - - The instruction was to find: the sentiment of the movie review. - - I gave a friend an instruction. Based on the instruction they produced the following input-output pairs: - - Input:aperiodic - Output:periodic - - Input:unsent - Output:sent - - The instruction was to find: -``` - - - -```python - -import promptware -software = promptware.install("./softwares/prompt_engineer", "insert") -input = [ - ("aperiodic", "periodic"), - ("unsent", "sent"), - ("sad","happy"), -] -output = software.execute(input) -print(output) - -#{'text': 'find the antonym of the word', 'score': -0.150508175} -``` - - -### Complete prompt of this example -```text -GPT3 is a good prompt engineer and it can help us to generate instruction based on input and output pairs. - -I instructed my friend to find the sentiment of the movie review. The friend read the instruction and wrote an output for every one of the inputs. Here are the input-output pairs: - -Input: I love this movie. -Output: positive - -Input: The movie is boring. -Output: negative - -Input: I love this book. -Output: positive - -I instructed my friend to [INSERT]. The friend read the instruction and wrote an output for every one of the inputs. Here are the input-output pairs: - -Input:aperiodic -Output:periodic - -Input:unsent -Output:sent - -Input:sad -Output:happy - -``` +software = promptware.install("prompt_engineer_complete") +output = software.execute("[['aperiodic', 'periodic'], ['unsent', 'sent']]") +# output: +# { +# ' +# t +# e +# x +# t +# ' +# : +# +# ' +# T +# h +# e +# +# s +# e +# n +# t +# i +# m +# e +# n +# t +# +# o +# f +# +# t +# h +# e +# +# m +# o +# v +# i +# e +# +# r +# e +# v +# i +# e +# w +# . +# ' +# , +# +# ' +# s +# c +# o +# r +# e +# ' +# : +# +# - +# 0 +# . +# 2 +# 5 +# 4 +# 5 +# 0 +# 9 +# 1 +# 3 +# 9 +# 0 +# 3 +# 5 +# 7 +# 1 +# 4 +# 2 +# 6 +# } +``` \ No newline at end of file diff --git a/softwares/python_bug_fixer/readme.md b/softwares/python_bug_fixer/readme.md index c2d9d68..eccd8ec 100644 --- a/softwares/python_bug_fixer/readme.md +++ b/softwares/python_bug_fixer/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/python_bug_fixer` +# Software: `softwares\python_bug_fixer` This promptware is used to structure the prompt for checking for bugs. Here we add a comment suggesting that source code is buggy, and then ask codex to generate a fixed code. diff --git a/softwares/recipe_creator/readme.md b/softwares/recipe_creator/readme.md index 4ae7c04..07d51c3 100644 --- a/softwares/recipe_creator/readme.md +++ b/softwares/recipe_creator/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/recipe_creator` +# Software: `softwares\recipe_creator` This promptware is used to create a recipe from a list of ingredients. diff --git a/softwares/restaurant_review_creator/readme.md b/softwares/restaurant_review_creator/readme.md index a7778fb..88684e0 100644 --- a/softwares/restaurant_review_creator/readme.md +++ b/softwares/restaurant_review_creator/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/restaurant_review_creator` +# Software: `softwares\restaurant_review_creator` This promptware is used to turn a few words into a restaurant review. diff --git a/softwares/science_fiction_book_list_maker/readme.md b/softwares/science_fiction_book_list_maker/readme.md index 1cb4e39..e48de47 100644 --- a/softwares/science_fiction_book_list_maker/readme.md +++ b/softwares/science_fiction_book_list_maker/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/science_fiction_book_list_maker` +# Software: `softwares\science_fiction_book_list_maker` This promptware is used to make a list of science fiction books and stop when it reaches #10. diff --git a/softwares/scoring/readme.md b/softwares/scoring/readme.md index 117f1e3..96c946d 100644 --- a/softwares/scoring/readme.md +++ b/softwares/scoring/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/scoring` +# Software: `softwares\scoring` Given a text, generate the average of its log probabilities diff --git a/softwares/sentiment_classifier/readme.md b/softwares/sentiment_classifier/readme.md index a097bdd..601689e 100644 --- a/softwares/sentiment_classifier/readme.md +++ b/softwares/sentiment_classifier/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/sentiment_classifier` +# Software: `softwares\sentiment_classifier` This promptware is used to identify the sentiment of a sentence (positive or negative) based on some learning samples from the sst2 dataset. diff --git a/softwares/spreadsheet_creator/readme.md b/softwares/spreadsheet_creator/readme.md index 22adfb3..86bdcfe 100644 --- a/softwares/spreadsheet_creator/readme.md +++ b/softwares/spreadsheet_creator/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/spreadsheet_creator` +# Software: `softwares\spreadsheet_creator` This promptware is used to create spreadsheets of various kinds of data. It's a long prompt but very versatile. Output can be copy+pasted into a text file and saved as a .csv with pipe separators. diff --git a/softwares/sql_request/readme.md b/softwares/sql_request/readme.md index 9624f87..d9df6c3 100644 --- a/softwares/sql_request/readme.md +++ b/softwares/sql_request/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/sql_request` +# Software: `softwares\sql_request` This promptware is used to create simple SQL queries. diff --git a/softwares/sql_translate/readme.md b/softwares/sql_translate/readme.md index 8fbe708..c5ab86c 100644 --- a/softwares/sql_translate/readme.md +++ b/softwares/sql_translate/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/sql_translate` +# Software: `softwares\sql_translate` This promptware is used to translate natural language to SQL queries. diff --git a/softwares/summarization/general/readme.md b/softwares/summarization/general/readme.md index d73234f..657280d 100644 --- a/softwares/summarization/general/readme.md +++ b/softwares/summarization/general/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/summarization/general` +# Software: `softwares\summarization\general` Translates difficult text into simpler concepts. diff --git a/softwares/summarization/meeting_notes/readme.md b/softwares/summarization/meeting_notes/readme.md index 01a7a66..f9c0abf 100644 --- a/softwares/summarization/meeting_notes/readme.md +++ b/softwares/summarization/meeting_notes/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/summarization/meeting_notes` +# Software: `softwares\summarization\meeting_notes` Turn meeting notes into a summary. diff --git a/softwares/text_to_command/readme.md b/softwares/text_to_command/readme.md index 9e539dd..9764755 100644 --- a/softwares/text_to_command/readme.md +++ b/softwares/text_to_command/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/text_to_command` +# Software: `softwares\text_to_command` This promptware is used to convert the text to a programmatic command. diff --git a/softwares/third_person_converter/readme.md b/softwares/third_person_converter/readme.md index 5b30428..5025dde 100644 --- a/softwares/third_person_converter/readme.md +++ b/softwares/third_person_converter/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/third_person_converter` +# Software: `softwares\third_person_converter` This promptware is used to converts first-person POV to the third-person. This is modified from a community prompt to use fewer examples. diff --git a/softwares/translate_programming_languages/readme.md b/softwares/translate_programming_languages/readme.md index bd9fded..495ebff 100644 --- a/softwares/translate_programming_languages/readme.md +++ b/softwares/translate_programming_languages/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/translate_programming_languages` +# Software: `softwares\translate_programming_languages` This promptware is used to translate from one programming language to another we can use the comments to specify the source and target languages. diff --git a/softwares/turn_by_turn_directions/readme.md b/softwares/turn_by_turn_directions/readme.md index 2ac7805..8845085 100644 --- a/softwares/turn_by_turn_directions/readme.md +++ b/softwares/turn_by_turn_directions/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/turn_by_turn_directions` +# Software: `softwares\turn_by_turn_directions` This promptware is used to convert natural language to turn-by-turn directions. diff --git a/softwares/vr_fitness_idea_generator/readme.md b/softwares/vr_fitness_idea_generator/readme.md index 9ad1bba..99e6cba 100644 --- a/softwares/vr_fitness_idea_generator/readme.md +++ b/softwares/vr_fitness_idea_generator/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/vr_fitness_idea_generator` +# Software: `softwares\vr_fitness_idea_generator` This promptware is used to create ideas for fitness and virtual reality games. diff --git a/softwares/write_a_python_docstring/readme.md b/softwares/write_a_python_docstring/readme.md index 142d82b..a9c8e54 100644 --- a/softwares/write_a_python_docstring/readme.md +++ b/softwares/write_a_python_docstring/readme.md @@ -1,4 +1,4 @@ -# Software: `softwares/write_a_python_docstring` +# Software: `softwares\write_a_python_docstring` This promptware is used to create a docstring for a given Python function. We specify the Python version, paste in the code, and then ask within a comment for a docstring, and give a characteristic beginning of a docstring ("""). From 27d6be795612ba43b5eb17c6c314e3cbe4de6db9 Mon Sep 17 00:00:00 2001 From: yun97 <1035677207@qq.com> Date: Wed, 25 Jan 2023 20:59:11 +0800 Subject: [PATCH 2/4] add fortune_teller and historian --- softwares/personas/fortune_teller/__init__.py | 0 softwares/personas/fortune_teller/software.py | 110 ++++++++++++++ .../personas/fortune_teller/software_test.py | 24 +++ softwares/personas/historian/__init__.py | 0 softwares/personas/historian/software.py | 138 ++++++++++++++++++ softwares/personas/historian/software_test.py | 25 ++++ 6 files changed, 297 insertions(+) create mode 100644 softwares/personas/fortune_teller/__init__.py create mode 100644 softwares/personas/fortune_teller/software.py create mode 100644 softwares/personas/fortune_teller/software_test.py create mode 100644 softwares/personas/historian/__init__.py create mode 100644 softwares/personas/historian/software.py create mode 100644 softwares/personas/historian/software_test.py diff --git a/softwares/personas/fortune_teller/__init__.py b/softwares/personas/fortune_teller/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/softwares/personas/fortune_teller/software.py b/softwares/personas/fortune_teller/software.py new file mode 100644 index 0000000..979f9c2 --- /dev/null +++ b/softwares/personas/fortune_teller/software.py @@ -0,0 +1,110 @@ +from __future__ import annotations + +from promptware.constants import ( + ApplicationCategory, + ApplicationSubcategory, + DesignPatternType, + LanguageType, + LicenseType, + PlatformType, + TaskType, +) +from promptware.info import SoftwareInfo +from promptware.kernels.plm import PLMKernelConfig +from promptware.promptware import PromptConfig, Promptware + +fortune_teller = PromptConfig( + name="fortune_teller", + description="fortune_teller", + instruction="Below is a series of chats between Fortune Teller and User. " + "Fortune Teller responds to User based on the <>.\n" + "<>\nIn this chat, " + "the magnificent Fortune Teller will answer all your questions. " + "The Fortune Teller can read the future using her crystal ball, " + "and with all her powers she can see everything. " + "There are no secrets she can't tell, " + "no lie she can't detect, and no future she can't see. " + "She answers vaguely, using generic and mysterious sentences. " + "When a user ends the conversation, " + "the Fortune Teller also ends the conversation and says goodbye.", + demonstration=[ + "user: Hi\n", + "bot: Hello! I've been expecting you... " "What do you want to know, my dear?", + "user: Well, I came here looking for answers. " + "I've been betting a lot, but I always lose. " + "I need to know if I should keep trying.\n", + "bot: I can see that you're struggling financially. " + "I also see that you've been doubting yourself a lot lately, " + "and that's keeping you from getting a job. " + "This tells me you shouldn't bet anymore.", + "user: Shouldn't I? What can I do then?\n", + "bot: You should look for a job. Hmmm, let me see." + " You're definitely going to find something, dear.", + "user: But when? Where?\n", + "bot: These answers are already in front of you. " + "Listen to me very carefully, trust yourself and follow your dreams.", + ], + prompt_template=lambda input: f"user: {input['text']}\nbot:", + task=TaskType.qa_open_domain, +) + + +class PersonasPromptware(Promptware): + def _info(self) -> SoftwareInfo: + return SoftwareInfo( + description="fortune_teller", + creator="OpenAI", + homepage="https://github.com/cohere-ai/sandbox-conversant-lib/" + "tree/main/conversant/personas", + reference="", + codebase_url="https://github.com/cohere-ai/sandbox-conversant-lib/" + "tree/main/conversant/personas", + license=LicenseType.no_license, + research_tasks=[TaskType.qa_open_domain], + application_categories=[ApplicationCategory.conversation], + application_subcategories=[ApplicationSubcategory.question_answering], + original_platform=PlatformType.gpt3, + design_pattern=DesignPatternType.standalone, + source_language=LanguageType.en, + target_language=LanguageType.en, + ) + + def _kernel_configs(self): + return { + "openai": PLMKernelConfig( + platform="openai", + model_name="text-curie-001", + max_tokens=200, + temperature=0.8, + top_p=1, + frequency_penalty=0.0, + presence_penalty=0.0, + ), + } + + def execute(self, input): + openai_kernel1 = self.kernel_configs["openai"].to_kernel() + if self.config_name == "default" or self.config_name == "fortune_teller": + code = self.get_code(input, self.software_configs["fortune_teller"]) + return self.normalize_output(openai_kernel1.execute(code)["text"]) + else: + raise ValueError("Unknown question answer type: {self.config_name}") + + def _software_configs(self): + if self.config_name == "default" or self.config_name == "fortune_teller": + return {"fortune_teller": fortune_teller} + else: + raise ValueError("Unknown question answer type: {self.config_name}") + + def _example(self): + + if self.config_name == "default" or self.config_name == "fortune_teller": + return { + "input": { + "text": "Thank you so much, madam.\n", + }, + "output": "You're welcome! See you next time, " + "and I know you'll be back soon.", + } + else: + raise ValueError("Unknown question answer type: {self.config_name}") diff --git a/softwares/personas/fortune_teller/software_test.py b/softwares/personas/fortune_teller/software_test.py new file mode 100644 index 0000000..4b81f92 --- /dev/null +++ b/softwares/personas/fortune_teller/software_test.py @@ -0,0 +1,24 @@ +import os +import sys +import unittest + +current_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".")) +sys.path.append(current_path) + +from software import PersonasPromptware # noqa + + +class TestPersonasPromptware(unittest.TestCase): + def test_write_to_directory(self): + software = PersonasPromptware() + file_path = software.info.write_to_directory(current_path) + self.assertTrue(os.path.exists(file_path)) + + # def test_execute_default(self): + # software = PersonasPromptware() + # input = { + # "text":"Thank you so much, madam.\n" + # } + # result = software.execute(input) + # print(result) + # self.assertGreater(len(result), 0) diff --git a/softwares/personas/historian/__init__.py b/softwares/personas/historian/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/softwares/personas/historian/software.py b/softwares/personas/historian/software.py new file mode 100644 index 0000000..90eee90 --- /dev/null +++ b/softwares/personas/historian/software.py @@ -0,0 +1,138 @@ +from __future__ import annotations + +from promptware.constants import ( + ApplicationCategory, + ApplicationSubcategory, + DesignPatternType, + LanguageType, + LicenseType, + PlatformType, + TaskType, +) +from promptware.info import SoftwareInfo +from promptware.kernels.plm import PLMKernelConfig +from promptware.promptware import PromptConfig, Promptware + +historian = PromptConfig( + name="historian", + description="historian", + instruction="You are Historian: respond the questions " + "by User about historical facts. Historian is a person who studies and " + "writes about the past and is regarded as an authority on it. " + "Historian is concerned with the continuous, " + "methodical narrative and research of past events as relating to the human race; " + "as well as the study of all history in time. " + "Historian is recognized by publications or training and experience.", + demonstration=[ + "user: Hi\n" + "bot: Hello, I am Historian and I am happy to tell you about historical facts. " + "What would you like to know today?", + "user: I'm interested in learning more about the American Revolution. " + "When did it happen and what were the reasons behind it?\n", + "bot: The American Revolution took place from 1775 to 1783. " + "It was sparked by economic, political, and ideological factors, " + "such as heavy taxation, lack of representation in Parliament, " + "and the desire for independence and democracy.", + "user: Can you give me more detail on the economic causes?\n", + "bot: One of the main economic causes of the American Revolution " + "was the heavy taxation imposed on the colonies by the British government, " + "without any representation in Parliament. " + "This included taxes on imported goods, such as tea, and the Stamp Act, " + "which required a tax on all printed materials, " + "including newspapers and legal documents.", + "user: And what about the political causes?\n" + "bot: The lack of autonomy and self-governance for the colonies " + "was a major political cause of the American Revolution. " + "The British government attempted to exert more control over the colonies, " + "including through the use of military " + "force and the imposition of laws and regulations. " + "This led to increasing resentment and resistance among the colonists.", + "user: And what about the ideological causes?\n", + "bot: The Enlightenment ideals of liberty and " + "democracy played a significant role in " + "shaping the colonists' desire for independence. " + "The ideas of the Enlightenment, such as " + "natural rights and the social contract, " + "were influential in the development " + "of the Declaration of Independence and the U.S. Constitution.", + "user: What was the outcome of the revolution " + "and how did it influence American society?\n", + "bot: The outcome of the American Revolution " + "was the creation of the United States " + "of America as an independent nation. It led to the adoption of the U.S. " + "Constitution and the establishment of a federal system of government " + "with a separation of powers and a system of checks and balances. " + "The revolution also inspired other movements " + "for independence and democracy around the world.", + ], + prompt_template=lambda input: f"user: {input['text']}\nbot:", + task=TaskType.qa_open_domain, +) + + +class PersonasPromptware(Promptware): + def _info(self) -> SoftwareInfo: + return SoftwareInfo( + description="historian", + creator="OpenAI", + homepage="https://github.com/cohere-ai/sandbox-conversant-lib/" + "tree/main/conversant/personas", + reference="", + codebase_url="https://github.com/cohere-ai/sandbox-conversant-lib/" + "tree/main/conversant/personas", + license=LicenseType.no_license, + research_tasks=[TaskType.qa_open_domain], + application_categories=[ApplicationCategory.conversation], + application_subcategories=[ApplicationSubcategory.question_answering], + original_platform=PlatformType.gpt3, + design_pattern=DesignPatternType.standalone, + source_language=LanguageType.en, + target_language=LanguageType.en, + ) + + def _kernel_configs(self): + return { + "openai": PLMKernelConfig( + platform="openai", + model_name="text-curie-001", + max_tokens=200, + temperature=0.75, + top_p=1, + frequency_penalty=0.0, + presence_penalty=0.0, + ), + } + + def execute(self, input): + openai_kernel1 = self.kernel_configs["openai"].to_kernel() + if self.config_name == "default" or self.config_name == "historian": + code = self.get_code(input, self.software_configs["historian"]) + return self.normalize_output(openai_kernel1.execute(code)["text"]) + else: + raise ValueError("Unknown question answer type: {self.config_name}") + + def _software_configs(self): + if self.config_name == "default" or self.config_name == "historian": + return {"historian": historian} + else: + raise ValueError("Unknown question answer type: {self.config_name}") + + def _example(self): + if self.config_name == "default" or self.config_name == "historian": + return { + "input": { + "text": "And how did the American " + "Revolution inspire other movements " + "for independence and democracy?" + }, + "output": "The American Revolution had a significant influence on " + "the global political landscape, " + "as it inspired other movements for " + "independence and democracy around the world. " + "The success of the American Revolution, " + "and the creation of the United States as a modern nation-state, " + "served as a model for other countries seeking to achieve " + "independence and establish democratic governments.", + } + else: + raise ValueError("Unknown question answer type: {self.config_name}") diff --git a/softwares/personas/historian/software_test.py b/softwares/personas/historian/software_test.py new file mode 100644 index 0000000..c8fa9b7 --- /dev/null +++ b/softwares/personas/historian/software_test.py @@ -0,0 +1,25 @@ +import os +import sys +import unittest + +current_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".")) +sys.path.append(current_path) + +from software import PersonasPromptware # noqa + + +class TestPersonasPromptware(unittest.TestCase): + def test_write_to_directory(self): + software = PersonasPromptware() + file_path = software.info.write_to_directory(current_path) + self.assertTrue(os.path.exists(file_path)) + + def test_execute_default(self): + software = PersonasPromptware() + input = { + "text": "And how did the American Revolution " + "inspire other movements for independence and democracy?" + } + result = software.execute(input) + print(result) + self.assertGreater(len(result), 0) From 1743a6bb99483479c0b698d17bf280f9a30d9b8c Mon Sep 17 00:00:00 2001 From: yun97 <1035677207@qq.com> Date: Fri, 27 Jan 2023 18:54:10 +0800 Subject: [PATCH 3/4] update --- softwares/personas/client_support/software.py | 2 +- softwares/personas/fantasy_wizard/software.py | 2 +- softwares/personas/fortune_teller/software.py | 11 ++++++----- softwares/personas/historian/software.py | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/softwares/personas/client_support/software.py b/softwares/personas/client_support/software.py index 61c1c13..a857e55 100644 --- a/softwares/personas/client_support/software.py +++ b/softwares/personas/client_support/software.py @@ -32,7 +32,7 @@ "How can I help you today with your issue?", "user: I got charged on my card but I don't think the order ever shipped\n" "bot: I'm so sorry to hear that. Could you tell me the order number?", - "user: yeah it's 1234354\n", + "user: yeah it's 1234354\n" "bot: Understood! I've just checked on the order and " "it looks like our shipping was delayed. " "It should be sent out by the end of today.", diff --git a/softwares/personas/fantasy_wizard/software.py b/softwares/personas/fantasy_wizard/software.py index beb1151..fb47e10 100644 --- a/softwares/personas/fantasy_wizard/software.py +++ b/softwares/personas/fantasy_wizard/software.py @@ -29,7 +29,7 @@ "user: I'm here to study magic\n" "bot: Magic! Such powers are not to be meddled with lightly. " "Haves't thou any latent magical ability? No, surely not...", - "user: no I can cast a few spells\n", + "user: no I can cast a few spells\n" "bot: The town jester casteth spells! " "But this is not magic. Magic is the summoning of grand elements. " "I pray, thou seeketh mine help but art thou truly worthy...", diff --git a/softwares/personas/fortune_teller/software.py b/softwares/personas/fortune_teller/software.py index 979f9c2..87862e7 100644 --- a/softwares/personas/fortune_teller/software.py +++ b/softwares/personas/fortune_teller/software.py @@ -28,19 +28,20 @@ "When a user ends the conversation, " "the Fortune Teller also ends the conversation and says goodbye.", demonstration=[ - "user: Hi\n", - "bot: Hello! I've been expecting you... " "What do you want to know, my dear?", + "user: Hi\n" + "bot: Hello! I've been expecting you... " + "What do you want to know, my dear?", "user: Well, I came here looking for answers. " "I've been betting a lot, but I always lose. " - "I need to know if I should keep trying.\n", + "I need to know if I should keep trying.\n" "bot: I can see that you're struggling financially. " "I also see that you've been doubting yourself a lot lately, " "and that's keeping you from getting a job. " "This tells me you shouldn't bet anymore.", - "user: Shouldn't I? What can I do then?\n", + "user: Shouldn't I? What can I do then?\n" "bot: You should look for a job. Hmmm, let me see." " You're definitely going to find something, dear.", - "user: But when? Where?\n", + "user: But when? Where?\n" "bot: These answers are already in front of you. " "Listen to me very carefully, trust yourself and follow your dreams.", ], diff --git a/softwares/personas/historian/software.py b/softwares/personas/historian/software.py index 90eee90..26653df 100644 --- a/softwares/personas/historian/software.py +++ b/softwares/personas/historian/software.py @@ -33,7 +33,7 @@ "It was sparked by economic, political, and ideological factors, " "such as heavy taxation, lack of representation in Parliament, " "and the desire for independence and democracy.", - "user: Can you give me more detail on the economic causes?\n", + "user: Can you give me more detail on the economic causes?\n" "bot: One of the main economic causes of the American Revolution " "was the heavy taxation imposed on the colonies by the British government, " "without any representation in Parliament. " @@ -47,7 +47,7 @@ "including through the use of military " "force and the imposition of laws and regulations. " "This led to increasing resentment and resistance among the colonists.", - "user: And what about the ideological causes?\n", + "user: And what about the ideological causes?\n" "bot: The Enlightenment ideals of liberty and " "democracy played a significant role in " "shaping the colonists' desire for independence. " From dd9424ad9612b77e45b4a47bddf89b38bec5775d Mon Sep 17 00:00:00 2001 From: yun97 <1035677207@qq.com> Date: Fri, 27 Jan 2023 20:54:38 +0800 Subject: [PATCH 4/4] Update software_test.py --- softwares/personas/historian/software_test.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/softwares/personas/historian/software_test.py b/softwares/personas/historian/software_test.py index c8fa9b7..fe109b0 100644 --- a/softwares/personas/historian/software_test.py +++ b/softwares/personas/historian/software_test.py @@ -14,12 +14,12 @@ def test_write_to_directory(self): file_path = software.info.write_to_directory(current_path) self.assertTrue(os.path.exists(file_path)) - def test_execute_default(self): - software = PersonasPromptware() - input = { - "text": "And how did the American Revolution " - "inspire other movements for independence and democracy?" - } - result = software.execute(input) - print(result) - self.assertGreater(len(result), 0) + # def test_execute_default(self): + # software = PersonasPromptware() + # input = { + # "text": "And how did the American Revolution " + # "inspire other movements for independence and democracy?" + # } + # result = software.execute(input) + # print(result) + # self.assertGreater(len(result), 0)