From 7582613f30041349d88a25dbdf9fffa3981abb68 Mon Sep 17 00:00:00 2001 From: Johannes Date: Mon, 30 Dec 2024 11:48:06 +0100 Subject: [PATCH 1/3] fix: finance-content-checker logic repair --- ...c0f99a9e-5004-4e75-a6c6-36f17490b134.jsonl | 47 ++ .../.wf/components-root.jsonl | 1 + .../.wf/components-workflows_root.jsonl | 1 + finance-content-checker/.wf/metadata.json | 3 + finance-content-checker/main.py | 51 +- finance-content-checker/prompts.py | 298 ++------- finance-content-checker/pyproject.toml | 3 +- finance-content-checker/ui.json | 624 ------------------ finance-content-checker/utils.py | 8 +- 9 files changed, 144 insertions(+), 892 deletions(-) create mode 100644 finance-content-checker/.wf/components-page-0-c0f99a9e-5004-4e75-a6c6-36f17490b134.jsonl create mode 100644 finance-content-checker/.wf/components-root.jsonl create mode 100644 finance-content-checker/.wf/components-workflows_root.jsonl create mode 100644 finance-content-checker/.wf/metadata.json delete mode 100644 finance-content-checker/ui.json diff --git a/finance-content-checker/.wf/components-page-0-c0f99a9e-5004-4e75-a6c6-36f17490b134.jsonl b/finance-content-checker/.wf/components-page-0-c0f99a9e-5004-4e75-a6c6-36f17490b134.jsonl new file mode 100644 index 0000000..3f730cf --- /dev/null +++ b/finance-content-checker/.wf/components-page-0-c0f99a9e-5004-4e75-a6c6-36f17490b134.jsonl @@ -0,0 +1,47 @@ +{"id": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "type": "page", "content": {"pageMode": "compact"}, "handlers": {}, "isCodeManaged": false, "parentId": "root", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "bebc5fe9-63a7-46a7-b0fa-62303555cfaf", "type": "header", "content": {"text": "@{my_app.title}"}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "oifvuxkfgni30c04", "type": "image", "content": {"caption": "", "maxHeight": "30", "maxWidth": "", "src": "@{img_path}"}, "handlers": {}, "isCodeManaged": false, "parentId": "bebc5fe9-63a7-46a7-b0fa-62303555cfaf", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "cfdn0lwtc3bc2e1i", "type": "message", "content": {"message": "@{message}"}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "3emssu3oapg9aaeb", "type": "columns", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 2, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "0r3y4groykgktb1l", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "3emssu3oapg9aaeb", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "hjtxdwb3aeylsfh6", "type": "section", "content": {"title": "Input content to check"}, "handlers": {}, "isCodeManaged": false, "parentId": "0r3y4groykgktb1l", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "f82m2sdbhhgfgbb1", "type": "textareainput", "binding": {"eventType": "wf-change", "stateRef": "content"}, "content": {"label": "Paste in some content to check (<500 words)", "placeholder": "", "rows": "5"}, "handlers": {"wf-change": "content_to_HMTL"}, "isCodeManaged": false, "parentId": "hjtxdwb3aeylsfh6", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "3wckjuynvz0od6w9", "type": "section", "content": {"title": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "0r3y4groykgktb1l", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "c30ch4pibyw5juug", "type": "html", "content": {"htmlInside": "@{html_content}", "styles": "{\n \"padding\": \"16px\",\n\"padding-top\":\"20px\",\n \"min-height\": \"64px\",\n\"max-height\": \"420px\",\n\"overflow\":\"auto\",\n \"min-width\": \"64px\",\n \"border-radius\": \"8px\"\n}"}, "handlers": {}, "isCodeManaged": false, "parentId": "3wckjuynvz0od6w9", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "43cp015ju9156xvo", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "3emssu3oapg9aaeb", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "z4toz7gq7kpdhbvs", "type": "multiselectinput", "binding": {"eventType": "wf-options-change", "stateRef": "suggestion_flags_selected"}, "content": {"accentColor": "gray", "chipTextColor": "", "label": "Select one or more Suggestion Flags", "maximumCount": "5", "options": "@{suggestion_flags}", "placeholder": "Select up to 3 options..."}, "handlers": {"wf-options-change": "enable_suggestion_tabs"}, "isCodeManaged": false, "parentId": "43cp015ju9156xvo", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "e9re4hpngsrtszns", "type": "button", "content": {"icon": "arrow_forward", "isDisabled": "@{generate_btn_disabled}", "text": "Generate suggestions"}, "handlers": {"wf-click": "handle_generate_button_click"}, "isCodeManaged": false, "parentId": "43cp015ju9156xvo", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "amo4m8mssxwfztng", "type": "tabs", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "43cp015ju9156xvo", "position": 2, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "y2co003xc2z7ckld", "type": "tab", "content": {"name": "Outcome language"}, "handlers": {"click": "get_current_tab"}, "isCodeManaged": false, "parentId": "amo4m8mssxwfztng", "position": 0, "visible": {"binding": "tab_enabled.outcome_language", "expression": "custom", "reversed": false}} +{"id": "8cgl5i0vbhppyh4i", "type": "columns", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "y2co003xc2z7ckld", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "p8jduqivbny7bdxy", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "8cgl5i0vbhppyh4i", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "hyfos0bkdr3v50nb", "type": "section", "content": {"title": "Original text"}, "handlers": {"click": "highlight_string"}, "isCodeManaged": false, "parentId": "p8jduqivbny7bdxy", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "h4k2l0kghizi1osw", "type": "message", "content": {"message": "@{output.outcome_language.text}"}, "handlers": {"change": "highlight_string"}, "isCodeManaged": false, "parentId": "hyfos0bkdr3v50nb", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "atmnc5edtlm52idp", "type": "section", "content": {"title": "Suggestion"}, "handlers": {}, "isCodeManaged": false, "parentId": "p8jduqivbny7bdxy", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "fli8kybxrmqrrfaw", "type": "message", "content": {"message": "+@{output.outcome_language.suggestion}"}, "handlers": {}, "isCodeManaged": false, "parentId": "atmnc5edtlm52idp", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "shhxankpkgzxdp6o", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "8cgl5i0vbhppyh4i", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "v41sm3g27nf7qxsx", "type": "tags", "content": {"tags": "{\n \"outcome_language\": \"outcome language\"\n}"}, "handlers": {}, "isCodeManaged": false, "parentId": "shhxankpkgzxdp6o", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "ijghkvhd8yxwxboq", "type": "message", "content": {"message": "!@{output.outcome_language.description}"}, "handlers": {}, "isCodeManaged": false, "parentId": "shhxankpkgzxdp6o", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "1h3fup2ixqij4zzl", "type": "pagination", "content": {"page": "@{pagination.outcome_language.current_page}", "pageSize": "1", "pageSizeOptions": "", "totalItems": "@{pagination.outcome_language.data_size}"}, "handlers": {"wf-change-page": "set_page"}, "isCodeManaged": false, "parentId": "y2co003xc2z7ckld", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "kdx0s5tf0t6t272y", "type": "tab", "content": {"name": "Hyperbole"}, "handlers": {"click": "get_current_tab"}, "isCodeManaged": false, "parentId": "amo4m8mssxwfztng", "position": 1, "visible": {"binding": "tab_enabled.hyperbole", "expression": "custom", "reversed": false}} +{"id": "4ut5mwq967zm0049", "type": "columns", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "kdx0s5tf0t6t272y", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "p6hezc459yfkcvrb", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "4ut5mwq967zm0049", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "9n7r2yllx9h6d9vh", "type": "section", "content": {"title": "Original text"}, "handlers": {}, "isCodeManaged": false, "parentId": "p6hezc459yfkcvrb", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "giyebjqjd4tuojwy", "type": "message", "content": {"message": "@{output.hyperbole.text}"}, "handlers": {}, "isCodeManaged": false, "parentId": "9n7r2yllx9h6d9vh", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "8avbiu3lz7hzk4u4", "type": "section", "content": {"title": "Suggestion"}, "handlers": {}, "isCodeManaged": false, "parentId": "p6hezc459yfkcvrb", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "cumxx6s29p0kf3p1", "type": "message", "content": {"message": "+@{output.hyperbole.suggestion}"}, "handlers": {}, "isCodeManaged": false, "parentId": "8avbiu3lz7hzk4u4", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "jdjc5g79v7qffben", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "4ut5mwq967zm0049", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "smuxxei8eqmzd3i5", "type": "tags", "content": {"tags": "{\n \"Hyperbole\": \"hyperbole\"\n}"}, "handlers": {}, "isCodeManaged": false, "parentId": "jdjc5g79v7qffben", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "fhomxd6iobyhvq22", "type": "message", "content": {"message": "!@{output.hyperbole.description}"}, "handlers": {}, "isCodeManaged": false, "parentId": "jdjc5g79v7qffben", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "br9ri32d6dwg6btf", "type": "pagination", "content": {"page": "@{pagination.hyperbole.current_page}", "pageSize": "1", "pageSizeOptions": "", "totalItems": "@{pagination.hyperbole.data_size}"}, "handlers": {"wf-change-page": "set_page"}, "isCodeManaged": false, "parentId": "kdx0s5tf0t6t272y", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "1ntjnjorgokmrksh", "type": "tab", "content": {"name": "We pronoun"}, "handlers": {"click": "get_current_tab"}, "isCodeManaged": false, "parentId": "amo4m8mssxwfztng", "position": 2, "visible": {"binding": "tab_enabled.we_pronoun", "expression": "custom", "reversed": false}} +{"id": "220abedg02oxr0df", "type": "columns", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "1ntjnjorgokmrksh", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "ash4sqj4675xby5u", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "220abedg02oxr0df", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "pz1uzfd2sgvj35wf", "type": "section", "content": {"title": "Original text"}, "handlers": {}, "isCodeManaged": false, "parentId": "ash4sqj4675xby5u", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "wufcwgrrybpweoc2", "type": "message", "content": {"message": "@{output.we_pronoun.text}"}, "handlers": {}, "isCodeManaged": false, "parentId": "pz1uzfd2sgvj35wf", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "4euoiqzlcfgkrd51", "type": "section", "content": {"title": "Suggestion"}, "handlers": {}, "isCodeManaged": false, "parentId": "ash4sqj4675xby5u", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "gg5gv7ukdcbp0ys7", "type": "message", "content": {"message": "+@{output.we_pronoun.suggestion}"}, "handlers": {}, "isCodeManaged": false, "parentId": "4euoiqzlcfgkrd51", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "0jydi26cfk0lj4zg", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "220abedg02oxr0df", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "hddj4kf5pbu7nltg", "type": "tags", "content": {"tags": "{\n \"we_pronoun\": \"we pronoun\"\n}"}, "handlers": {}, "isCodeManaged": false, "parentId": "0jydi26cfk0lj4zg", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "tbherv4idvftfhr5", "type": "message", "content": {"message": "!@{output.we_pronoun.description}"}, "handlers": {}, "isCodeManaged": false, "parentId": "0jydi26cfk0lj4zg", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} +{"id": "tu8ujfgmwm1cviiu", "type": "pagination", "content": {"page": "@{pagination.we_pronoun.current_page}", "pageSize": "1", "pageSizeOptions": "", "totalItems": "@{pagination.we_pronoun.data_size}"}, "handlers": {"wf-change-page": "set_page"}, "isCodeManaged": false, "parentId": "1ntjnjorgokmrksh", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}} diff --git a/finance-content-checker/.wf/components-root.jsonl b/finance-content-checker/.wf/components-root.jsonl new file mode 100644 index 0000000..cc769f6 --- /dev/null +++ b/finance-content-checker/.wf/components-root.jsonl @@ -0,0 +1 @@ +{"id": "root", "type": "root", "content": {"appName": "Finance Copy Compliance Checker"}, "handlers": {}, "isCodeManaged": false, "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} \ No newline at end of file diff --git a/finance-content-checker/.wf/components-workflows_root.jsonl b/finance-content-checker/.wf/components-workflows_root.jsonl new file mode 100644 index 0000000..e6067e9 --- /dev/null +++ b/finance-content-checker/.wf/components-workflows_root.jsonl @@ -0,0 +1 @@ +{"id": "workflows_root", "type": "workflows_root", "content": {}, "handlers": {}, "isCodeManaged": false, "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}} \ No newline at end of file diff --git a/finance-content-checker/.wf/metadata.json b/finance-content-checker/.wf/metadata.json new file mode 100644 index 0000000..8813979 --- /dev/null +++ b/finance-content-checker/.wf/metadata.json @@ -0,0 +1,3 @@ +{ + "writer_version": "0.8.2" +} \ No newline at end of file diff --git a/finance-content-checker/main.py b/finance-content-checker/main.py index 26c3cad..8d1d99c 100644 --- a/finance-content-checker/main.py +++ b/finance-content-checker/main.py @@ -1,25 +1,33 @@ +import asyncio + import writer as wf +from writerai import AsyncWriter +from dotenv import load_dotenv import utils as ut from prompts import _hyperbole_prompt, _outcome_language_prompt, _we_pronoun_prompt, input_text, initial_output +load_dotenv() + class Rule: def __init__(self, name, prompt_function, state): self.name = name self.prompt_function = prompt_function self.state = state - def fetch_data(self): + async def fetch_data(self): formatted_content = self.state["content"].replace('\n\n', ' ') prompt = self.prompt_function(formatted_content) - output = wf.ai.complete(prompt) - data = ut.convert_string_to_dict_list(output) + output = await AsyncWriter().completions.create( + model="palmyra-x-004", prompt=prompt + ) + data = ut.convert_string_to_dict_list(output.choices[0].text) if data: first_entry = data[0] ut.set_page_output(first_entry, self.state, self.name) self.state[self.name] = data self.state["pagination"][self.name]["data_size"] = len(data) -def process_rules(state): +async def process_rules(state): """Process all rules and update the state accordingly.""" # Define rules @@ -29,12 +37,16 @@ def process_rules(state): Rule("we_pronoun", _we_pronoun_prompt, state) ] + tasks = [] + # Fetch data for each rule for rule in rules: if(rule.name in state["suggestion_flags_selected"]): formatted_name = rule.name.replace("_", " ") state["message"] = f"Processing {formatted_name}..." - rule.fetch_data() + tasks.append(rule.fetch_data()) + + await asyncio.gather(*tasks) @@ -42,7 +54,9 @@ def process_rules(state): # Handler to add/remove tabs from being displayed when suggestion flags are selected. Called by change event on multiselect suggestion flags UI component. def enable_suggestion_tabs(state,context): """ - Handler to add/remove tabs from being displayed when suggestion flags are selected. Called by change event on multiselect suggestion flags UI component. + Handler to add/remove tabs from being displayed when suggestion + flags are selected. Called by change event on multiselect suggestion + flags UI component. """ all_options = list(flags.values()) @@ -53,13 +67,19 @@ def enable_suggestion_tabs(state,context): def set_page(state,payload): - """This is a handler called by the pagination component when a page is clicked ("wf-change-page event). The payload returns the number of the current page " + """This is a handler called by the pagination component when + a page is clicked ("wf-change-page event). The payload returns + the number of the current page " """ index = payload - 1 curr_tab = state["current_tab"] state["pagination"][curr_tab]["current_page"] = payload - """The tab name of the current tab is used to determine which suggestion rule is in focus. This means that the tab names need to line up with the rules. The logic here is that based on the page clicked on in the active tab, we index that data dictionary and set the page output accordingly, as well as highlight the text in the html output.""" + """The tab name of the current tab is used to determine which suggestion rule is in focus. + This means that the tab names need to line up with the rules. The logic here is that based + on the page clicked on in the active tab, we index that data dictionary and set the page + output accordingly, as well as highlight the text in the html output. + """ rule = state["current_tab"] data = state[rule] ut.set_page_output(data=data[index],state=state,rule=rule) @@ -68,7 +88,8 @@ def set_page(state,payload): def content_to_HMTL(state): - """handler to set up the input text as html for the html element. Called whenever there is a change in the input text.""" + """handler to set up the input text as html for the html element. + Called whenever there is a change in the input text.""" formatted_content = state["content"].replace('\n\n', '

') print(formatted_content) html = """

{content}

""".format(content=formatted_content) @@ -76,7 +97,7 @@ def content_to_HMTL(state): return html # Generate button click handler -def handle_generate_button_click(state): +async def handle_generate_button_click(state): # Disable button when clicked to prevent double clicking state["generate_btn_disabled"] = "yes" @@ -85,7 +106,7 @@ def handle_generate_button_click(state): # This collection is stored in the state[rule] field and the # number of pages is set based on the number of items in the collection. - process_rules(state) + await process_rules(state) # Re-enable button once processing is completed. state["message"] = "" @@ -93,7 +114,11 @@ def handle_generate_button_click(state): ut.highlight_string(state,state["current_tab"]) def get_current_tab(state,context :dict): - """This is a handler that is tied to the tab click event. Return the current tab: this uses an approach that will eventually be deprecated where we look at the context and grab the target from it which gives the component id of the UI component""" + """This is a handler that is tied to the tab click event. + Return the current tab: this uses an approach that will + eventually be deprecated where we look at the context and + grab the target from it which gives the component id of + the UI component""" # mapping of component ids to tab names. tabs = {"y2co003xc2z7ckld": "outcome_language", "kdx0s5tf0t6t272y": "hyperbole", "1ntjnjorgokmrksh": "we_pronoun"} @@ -123,7 +148,7 @@ def get_current_tab(state,context :dict): }, "message": "", "content": input_text(), - "html_content":f"""

{input_text().replace('\n\n', '

')}

""", + "html_content":'

{text}

'.format(text=input_text().replace("\n\n", "

")), "outcome_language": "", "we_pronoun":"", "hyperbole":"", diff --git a/finance-content-checker/prompts.py b/finance-content-checker/prompts.py index 491af04..40afbab 100644 --- a/finance-content-checker/prompts.py +++ b/finance-content-checker/prompts.py @@ -4,326 +4,124 @@ def _we_pronoun_prompt(Content): prompt = f""" {Content} - - - - - - - You are an expert copywriter for Writer Asset Management, a large asset manager. Writer Asset Management is known for being a prominent advocate for sustainable finance, leveraging its global influence to address critical challenges like climate change and economic inequality. That being said, Writer Asset Management's content is heavily scrutinized for using the right language and nuances. - - - + You are an expert copywriter for Writer Asset Management, a large asset manager. Writer Asset Management is known for being a prominent advocate for sustainable finance, leveraging its global influence to address critical challenges like climate change and economic inequality. That being said, Writer Asset Management's content is heavily scrutinized for using the right language and nuances. Take a deep breath and follow these instructions closely: - - - 1. Your responsibility is to review above against Writer Asset Management content guidelines. - - - 2. Review the following guidelines and internalize them: - - - - - - Be mindful of the "royal we". When intentionally representing the Writer Asset Management firm view, use specific firmwide language. Where representing a specific investment team view, be sure to specify as such. For views on projections on the future state of sustainability / transition, specify whether it is the firm view or a specific investor team view - - - - - - 3. You will be given JSON examples that your output should mimic -- pay attention to the format and style closely. These JSON examples consist of the following fields - - - 3a. "text" -- this is the specific portion of the content that violates the content guidelines - - - 3c. "guideline" -- this is the general category of why the specific text was flagged as potentially violating the content guidelines - - - 3b. "description" -- this provides a more specific reason as to why the specific text was flagged as potentially violating the content guidelines - - - 3d. "suggestion" -- this is a suggested rewrite of the "text" in 3a. This is an optional field -- in some cases there might not be a suggestion at all. - - - - 4. Look at the following examples and internalize the content guidelines that are described by the "text", "flag", and "suggestion" fields. Make sure your output format is similar to the examples -- don't put it in JSON format. If there are no examples, give it your best shot. - - - + 4. Look at the following examples and internalize the content guidelines that are described by the "text", "flag", and "suggestion" fields. Make sure your output format is similar to the examples -- put it in JSON format. If there are no examples, give it your best shot. 5. Only apply this guideline if the "we" used in the paragraph has an ambiguous antecedent or it's not clear who it is referring to. If it is clear who the "we" is or a person/organization is clearly referring to themselves, you don't have to flag it as an issue. - - - - - - - text: In this new era, we don't just analyze macroeconomic trends; we use them to our advantage. The volatility and diverse return profiles are not challenges but opportunities that we are uniquely positioned to capitalize on. Our dynamic investment strategies are not just plans; they are blueprints for financial dominance.. - - guideline: Be mindful of the "royal we". When intentionally representing the firm view, use specific firmwide language. Where representing a specific investment team view, be sure to specify as such. For views on projections on the future state of sustainability, specify whether it is the firm view or a specific investor team view. - - description: This guideline advises on the use of the pronoun "we" in communications to ensure clarity about whether the perspective is that of the entire firm or a specific team within the firm, especially when discussing sustainability in investment strategies. - - suggestion: Clarify who "we" refers to. - - - + {{ + "text": "In this new era, we don't just analyze macroeconomic trends; we use them to our advantage. The volatility and diverse return profiles are not challenges but opportunities that we are uniquely positioned to capitalize on. Our dynamic investment strategies are not just plans; they are blueprints for financial dominance.", + "guideline": "Be mindful of the 'royal we'. When intentionally representing the firm view, use specific firmwide language. Where representing a specific investment team view, be sure to specify as such. For views on projections on the future state of sustainability, specify whether it is the firm view or a specific investor team view.", + "description": "This guideline advises on the use of the pronoun 'we' in communications to ensure clarity about whether the perspective is that of the entire firm or a specific team within the firm, especially when discussing sustainability in investment strategies.", + "suggestion": "Clarify who 'we' refers to." + }} - - - 5. Now look at and identify any text snippets that will be flagged against the content guidelines. Do not be overly aggressive with reviewing the content for violations. There is a possibility that you receive a pristine piece of text and you have nothing to output. In that case, return "". Be extra careful NOT to flag this as an issue if it is not relevant, especially if the word "we" is not even being used. Only output the top 3 suggestions. - - - Output: - - - - """ return prompt def _outcome_language_prompt(Content): prompt = f""" - - - - {Content} - - - + {Content} - - - You are an expert copywriter for Writer Asset Management, the world's largest asset manager. Writer Asset Management is known for being a prominent advocate for sustainable finance, leveraging its global influence to address critical challenges like climate change and economic inequality. That being said, Writer Asset Management's content is heavily scrutinized for using the right language and nuances. - - - Take a deep breath and follow these instructions closely: - - - 1. Your responsibility to is to review above against Writer Asset Management content guidelines. - - - 2. Review the following guidelines and internalize them: - - - - - - Be mindful not to use language that could create the misconception that Writer Asset Management is driving a specific outcome in the real economy. As a fiduciary, Writer Asset Management does not engineer real world outcomes, but for those clients who choose, we’ve developed impact strategies that allow them to target and measure specific sustainability outcomes in line with their objectives. - - - - - - 3. You will be given JSON examples that your output should mimic -- pay attention to the format and style closely. These JSON examples consist of the following fields - - - 3a. "text" -- this is the specific portion of the content that violates the content guidelines - - - 3c. "guideline" -- this is the general category of why the specific text was flagged as potentially violating the content guidelines - - - 3b. "description" -- this provides a more specific reason as to why the specific text was flagged as potentially violating the content guidelines - - - 3d. "suggestion" -- this is a suggested rewrite of the "text" in 3a. This is an optional field -- in some cases there might not be a suggestion at all. - - - - 4. Look at the following examples and internalize the content guidelines that are described by the "text", "flag", and "suggestion" fields. Make sure your output format is similar to the examples -- don't put it in JSON format. If there are no examples, give it your best shot. - - - + 4. Look at the following examples and internalize the content guidelines that are described by the "text", "flag", and "suggestion" fields. Make sure your output format is similar to the examples -- put it in JSON format. If there are no examples, give it your best shot. - - text: Mastering Macro Challenges We are driving robust U.S. economic growth, which is not merely a bounce back from the pandemic lows but a testament to our strategic prowess. Expect us to continue steering through high interest rates and stringent financial conditions, as we redefine market stability. ​ - - guideline: Outcome Language - - description: This guideline cautions against suggesting that the firm is driving specific outcomes in the real economy. Instead, it emphasizes Writer Asset Management's role as a fiduciary that offers clients impact strategies to target and measure specific sustainability outcomes. - - suggestion: Addressing Macro Challenges While U.S. economic growth appears robust, it primarily reflects recovery from the pandemic-induced downturn. The implication is a likely continuation of higher interest rates and tougher financial conditions. Financial markets are still adjusting to these changes, underscoring the importance of adept macroeconomic risk management.​ - + {{ + "text": "Mastering Macro Challenges We are driving robust U.S. economic growth, which is not merely a bounce back from the pandemic lows but a testament to our strategic prowess. Expect us to continue steering through high interest rates and stringent financial conditions, as we redefine market stability.", + "guideline": "Outcome Language", + "description": "This guideline cautions against suggesting that the firm is driving specific outcomes in the real economy. Instead, it emphasizes Writer Asset Management's role as a fiduciary that offers clients impact strategies to target and measure specific sustainability outcomes.", + "suggestion": "Addressing Macro Challenges While U.S. economic growth appears robust, it primarily reflects recovery from the pandemic-induced downturn. The implication is a likely continuation of higher interest rates and tougher financial conditions. Financial markets are still adjusting to these changes, underscoring the importance of adept macroeconomic risk management." + }} - - - text: Sustainability is Writer Asset Management's investment standard - - guideline: Outcome Language - - description: This guideline advises careful language use to avoid the impression that the firm engineers real-world outcomes, highlighting its role as a fiduciary that provides clients with strategies to achieve specific sustainability goals. - - suggestion: Our fiduciary approach to sustainability and the low-carbon transition - + {{ + "text": "Sustainability is Writer Asset Management's investment standard", + "guideline": "Outcome Language", + "description": "This guideline advises careful language use to avoid the impression that the firm engineers real-world outcomes, highlighting its role as a fiduciary that provides clients with strategies to achieve specific sustainability goals.", + "suggestion": "Our fiduciary approach to sustainability and the low-carbon transition" + }} - - - text: Revolutionizing Portfolio Management In this new era, we don't just analyze macroeconomic trends; we use them to our advantage. The volatility and diverse return profiles are not challenges but opportunities that we are uniquely positioned to capitalize on. Our dynamic investment strategies are not just plans; they are blueprints for financial dominance. - - guideline: Outcome Language - - description: This guideline stresses the importance of not implying that Writer Asset Management is driving specific real-world outcomes, focusing instead on providing information and strategies for clients to make informed decisions. - - suggestion: Strategic Portfolio Management In this new economic era, deriving value from macroeconomic analysis is increasingly crucial. The heightened volatility and varied return profiles present opportunities for astute investment strategies to thrive. This necessitates a dynamic investment approach, focusing on selective opportunities and the identification of undervalued assets. - + {{ + "text": "Revolutionizing Portfolio Management In this new era, we don't just analyze macroeconomic trends; we use them to our advantage. The volatility and diverse return profiles are not challenges but opportunities that we are uniquely positioned to capitalize on. Our dynamic investment strategies are not just plans; they are blueprints for financial dominance.", + "guideline": "Outcome Language", + "description": "This guideline stresses the importance of not implying that Writer Asset Management is driving specific real-world outcomes, focusing instead on providing information and strategies for clients to make informed decisions.", + "suggestion": "Strategic Portfolio Management In this new economic era, deriving value from macroeconomic analysis is increasingly crucial. The heightened volatility and varied return profiles present opportunities for astute investment strategies to thrive. This necessitates a dynamic investment approach, focusing on selective opportunities and the identification of undervalued assets." + }} - - - text: Since 2022, we have not just participated in the market; we have led it with job growth figures that shatter historical records. It's clear that we are not just recovering; we are building a new economic reality. - - guideline: Outcome Language - - description: This guideline reminds to avoid language that could be interpreted as the firm driving specific outcomes in the real economy, focusing instead on how Writer Asset Management assists clients in navigating the complex landscape of sustainability. - - suggestion: As a fiduciary, we create a viable strategy for robust portfolio performance that involves capitalizing on key structural dynamics anticipated to influence future returns. These elements are now vital for contemporary portfolio strategies. - + {{ + "text": "Since 2022, we have not just participated in the market; we have led it with job growth figures that shatter historical records. It's clear that we are not just recovering; we are building a new economic reality.", + "guideline": "Outcome Language", + "description": "This guideline reminds to avoid language that could be interpreted as the firm driving specific outcomes in the real economy, focusing instead on how Writer Asset Management assists clients in navigating the complex landscape of sustainability.", + "suggestion": "As a fiduciary, we create a viable strategy for robust portfolio performance that involves capitalizing on key structural dynamics anticipated to influence future returns. These elements are now vital for contemporary portfolio strategies." + }} - - - - 5. Now look at and identify any text snippets that will be flagged against the content guidelines. Do not be overly aggressive with reviewing the content for violations. There is a possibility that you receive a pristine piece of text and you have nothing to output. In that case, return "". Only output the top 3 suggestions. Your output should be in the format of a JSON object with the specificed fields, but in plain text format. - - + 5. Now look at and identify any text snippets that will be flagged against the content guidelines. Do not be overly aggressive with reviewing the content for violations. There is a possibility that you receive a pristine piece of text and you have nothing to output. In that case, return "". Only output the top 3 suggestions. Your output should be in the format of a JSON object with the specificed fields. Output: - - - """ return prompt def _hyperbole_prompt(Content): prompt = f""" - - - {Content} - - - - - - You are an expert copywriter for Writer Asset Management, the world's largest asset manager. Writer Asset Management is known for being a prominent advocate for sustainable finance, leveraging its global influence to address critical challenges like climate change and economic inequality. That being said, Writer Asset Management's content is heavily scrutinized for using the right language and nuances. - - - Take a deep breath and follow these instructions closely: - - - 1. Your responsibility to is to review above against Writer Asset Management content guidelines. - - - 2. Review the following guidelines and internalize them: - - - - - - Avoid hyperbole or particularly strong declarative language. Language that is hyperbolic/not specific should be toned down and/or replaced with specific, factual language. - - - - - - 3. You will be given JSON examples that your output should mimic -- pay attention to the format and style closely. These JSON examples consist of the following fields - - - 3a. "text" -- this is the specific portion of the content that violates the content guidelines - - - 3c. "guideline" -- this is the general category of why the specific text was flagged as potentially violating the content guidelines - - - 3b. "description" -- this provides a more specific reason as to why the specific text was flagged as potentially violating the content guidelines - - - 3d. "suggestion" -- this is a suggested rewrite of the "text" in 3a. This is an optional field -- in some cases there might not be a suggestion at all. - - - - 4. Look at the following examples and internalize the content guidelines that are described by the "text", "flag", and "suggestion" fields. Make sure your output format is similar to the examples -- don't put it in JSON format. If there are no examples, give it your best shot. - - - + 4. Look at the following examples and internalize the content guidelines that are described by the "text", "flag", and "suggestion" fields. Make sure your output format is similar to the examples -- put it in JSON format. If there are no examples, give it your best shot. - - text: We are at the forefront, turning structural dynamics into powerful levers for portfolio performance. These are not just factors; they are the tools we wield to craft the future of investing. - - guideline: Hyperbole - - description: This guideline advises against the use of hyperbolic or overly strong language. It encourages the use of specific, factual language instead of exaggerated terms to maintain clarity and precision. - - suggestion: A viable strategy for robust portfolio performance involves capitalizing on key structural dynamics anticipated to influence future returns. These elements are now vital for contemporary portfolio strategies. - + {{ + "text": "We are at the forefront, turning structural dynamics into powerful levers for portfolio performance. These are not just factors; they are the tools we wield to craft the future of investing.", + "guideline": "Hyperbole", + "description": "This guideline advises against the use of hyperbolic or overly strong language. It encourages the use of specific, factual language instead of exaggerated terms to maintain clarity and precision.", + "suggestion": "A viable strategy for robust portfolio performance involves capitalizing on key structural dynamics anticipated to influence future returns. These elements are now vital for contemporary portfolio strategies." + }} - - - text: We are witnessing an unprecedented era of financial transformation, marked by skyrocketing interest rates and dramatic market shifts. Gone are the days of predictable returns from traditional asset allocations. Now, we must navigate through the stormy waters of global economic upheaval. - - guideline: Hyperbole - - description: This guideline cautions against using dramatic or overly strong language that might exaggerate or misrepresent facts. It promotes the use of more measured and factual language. - - suggestion: The current financial landscape is characterized by rising interest rates and significant market fluctuations, a notable departure from the stability seen after the global financial crisis. Previously, investors could depend on simple, broad asset class allocations to yield returns without deep macroeconomic scrutiny. - - Today, however, the scenario demands a revamped approach. Supply constraints are common, and central banks are navigating complex decisions to control inflation, with reduced effectiveness in stimulating growth. This scenario leads to a wider array of possible outcomes, heightening uncertainty for both central banks and market participants. - + {{ + "text": "We are witnessing an unprecedented era of financial transformation, marked by skyrocketing interest rates and dramatic market shifts. Gone are the days of predictable returns from traditional asset allocations. Now, we must navigate through the stormy waters of global economic upheaval.", + "guideline": "Hyperbole", + "description": "This guideline cautions against using dramatic or overly strong language that might exaggerate or misrepresent facts. It promotes the use of more measured and factual language.", + "suggestion": "The current financial landscape is characterized by rising interest rates and significant market fluctuations, a notable departure from the stability seen after the global financial crisis. Previously, investors could depend on simple, broad asset class allocations to yield returns without deep macroeconomic scrutiny. Today, however, the scenario demands a revamped approach. Supply constraints are common, and central banks are navigating complex decisions to control inflation, with reduced effectiveness in stimulating growth. This scenario leads to a wider array of possible outcomes, heightening uncertainty for both central banks and market participants." + }} - - - 5. Now look at and identify any text snippets that will be flagged against the content guidelines. Hyperbole should specifically only be flagged when speaking about sustainable and transition-related topics. Do not be overly aggressive with reviewing the content for violations. There is a possibility that you receive a pristine piece of text and you have nothing to output. In that case, return "". At most output the top 3 review outputs. - - Output: - - - - """ return prompt diff --git a/finance-content-checker/pyproject.toml b/finance-content-checker/pyproject.toml index cc093aa..bde8b56 100644 --- a/finance-content-checker/pyproject.toml +++ b/finance-content-checker/pyproject.toml @@ -7,7 +7,8 @@ readme = "README.md" [tool.poetry.dependencies] python = "^3.10.0" -writer = {version = "^0.6.0"} +writer = "0.8.2" +python-dotenv = "^1.0.1" [build-system] diff --git a/finance-content-checker/ui.json b/finance-content-checker/ui.json deleted file mode 100644 index 89c4a84..0000000 --- a/finance-content-checker/ui.json +++ /dev/null @@ -1,624 +0,0 @@ -{ - "metadata": { - "writer_version": "0.6.2rc2" - }, - "components": { - "root": { - "id": "root", - "type": "root", - "content": { - "appName": "Finance Copy Compliance Checker" - }, - "isCodeManaged": false, - "position": 0, - "handlers": {}, - "visible": true - }, - "c0f99a9e-5004-4e75-a6c6-36f17490b134": { - "id": "c0f99a9e-5004-4e75-a6c6-36f17490b134", - "type": "page", - "content": { - "pageMode": "compact" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "root", - "handlers": {}, - "visible": true - }, - "bebc5fe9-63a7-46a7-b0fa-62303555cfaf": { - "id": "bebc5fe9-63a7-46a7-b0fa-62303555cfaf", - "type": "header", - "content": { - "text": "@{my_app.title}" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", - "handlers": {}, - "visible": true - }, - "f82m2sdbhhgfgbb1": { - "id": "f82m2sdbhhgfgbb1", - "type": "textareainput", - "content": { - "label": "Paste in some content to check (<500 words)", - "rows": "5", - "placeholder": "" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "hjtxdwb3aeylsfh6", - "handlers": { - "wf-change": "content_to_HMTL" - }, - "visible": true, - "binding": { - "eventType": "wf-change", - "stateRef": "content" - } - }, - "z4toz7gq7kpdhbvs": { - "id": "z4toz7gq7kpdhbvs", - "type": "multiselectinput", - "content": { - "label": "Select one or more Suggestion Flags", - "options": "@{suggestion_flags}", - "maximumCount": "5", - "chipTextColor": "", - "accentColor": "gray", - "placeholder": "Select up to 3 options..." - }, - "isCodeManaged": false, - "position": 0, - "parentId": "43cp015ju9156xvo", - "handlers": { - "wf-options-change": "enable_suggestion_tabs" - }, - "visible": true, - "binding": { - "eventType": "wf-options-change", - "stateRef": "suggestion_flags_selected" - } - }, - "3emssu3oapg9aaeb": { - "id": "3emssu3oapg9aaeb", - "type": "columns", - "content": {}, - "isCodeManaged": false, - "position": 2, - "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", - "handlers": {}, - "visible": true - }, - "0r3y4groykgktb1l": { - "id": "0r3y4groykgktb1l", - "type": "column", - "content": { - "width": "1" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "3emssu3oapg9aaeb", - "handlers": {}, - "visible": true - }, - "43cp015ju9156xvo": { - "id": "43cp015ju9156xvo", - "type": "column", - "content": { - "width": "1" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "3emssu3oapg9aaeb", - "handlers": {}, - "visible": true - }, - "v41sm3g27nf7qxsx": { - "id": "v41sm3g27nf7qxsx", - "type": "tags", - "content": { - "tags": "{\n \"outcome_language\": \"outcome language\"\n}" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "shhxankpkgzxdp6o", - "handlers": {}, - "visible": true - }, - "8cgl5i0vbhppyh4i": { - "id": "8cgl5i0vbhppyh4i", - "type": "columns", - "content": {}, - "isCodeManaged": false, - "position": 0, - "parentId": "y2co003xc2z7ckld", - "handlers": {}, - "visible": true - }, - "p8jduqivbny7bdxy": { - "id": "p8jduqivbny7bdxy", - "type": "column", - "content": { - "width": "1" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "8cgl5i0vbhppyh4i", - "handlers": {}, - "visible": true - }, - "shhxankpkgzxdp6o": { - "id": "shhxankpkgzxdp6o", - "type": "column", - "content": { - "width": "1" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "8cgl5i0vbhppyh4i", - "handlers": {}, - "visible": true - }, - "ijghkvhd8yxwxboq": { - "id": "ijghkvhd8yxwxboq", - "type": "message", - "content": { - "message": "!@{output.outcome_language.description}" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "shhxankpkgzxdp6o", - "handlers": {}, - "visible": true - }, - "h4k2l0kghizi1osw": { - "id": "h4k2l0kghizi1osw", - "type": "message", - "content": { - "message": "@{output.outcome_language.text}" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "hyfos0bkdr3v50nb", - "handlers": { - "change": "highlight_string" - }, - "visible": true - }, - "hyfos0bkdr3v50nb": { - "id": "hyfos0bkdr3v50nb", - "type": "section", - "content": { - "title": "Original text" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "p8jduqivbny7bdxy", - "handlers": { - "click": "highlight_string" - }, - "visible": true - }, - "atmnc5edtlm52idp": { - "id": "atmnc5edtlm52idp", - "type": "section", - "content": { - "title": "Suggestion" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "p8jduqivbny7bdxy", - "handlers": {}, - "visible": true - }, - "fli8kybxrmqrrfaw": { - "id": "fli8kybxrmqrrfaw", - "type": "message", - "content": { - "message": "+@{output.outcome_language.suggestion}" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "atmnc5edtlm52idp", - "handlers": {}, - "visible": true - }, - "amo4m8mssxwfztng": { - "id": "amo4m8mssxwfztng", - "type": "tabs", - "content": {}, - "isCodeManaged": false, - "position": 2, - "parentId": "43cp015ju9156xvo", - "handlers": {}, - "visible": true - }, - "y2co003xc2z7ckld": { - "id": "y2co003xc2z7ckld", - "type": "tab", - "content": { - "name": "Outcome language" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "amo4m8mssxwfztng", - "handlers": { - "click": "get_current_tab" - }, - "visible": "tab_enabled.outcome_language" - }, - "1ntjnjorgokmrksh": { - "id": "1ntjnjorgokmrksh", - "type": "tab", - "content": { - "name": "We pronoun" - }, - "isCodeManaged": false, - "position": 2, - "parentId": "amo4m8mssxwfztng", - "handlers": { - "click": "get_current_tab" - }, - "visible": "tab_enabled.we_pronoun" - }, - "1h3fup2ixqij4zzl": { - "id": "1h3fup2ixqij4zzl", - "type": "pagination", - "content": { - "page": "@{pagination.outcome_language.current_page}", - "pageSizeOptions": "", - "totalItems": "@{pagination.outcome_language.data_size}", - "pageSize": "1" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "y2co003xc2z7ckld", - "handlers": { - "wf-change-page": "set_page" - }, - "visible": true - }, - "hjtxdwb3aeylsfh6": { - "id": "hjtxdwb3aeylsfh6", - "type": "section", - "content": { - "title": "Input content to check" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "0r3y4groykgktb1l", - "handlers": {}, - "visible": true - }, - "e9re4hpngsrtszns": { - "id": "e9re4hpngsrtszns", - "type": "button", - "content": { - "text": "Generate suggestions", - "icon": "arrow_forward", - "isDisabled": "@{generate_btn_disabled}" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "43cp015ju9156xvo", - "handlers": { - "wf-click": "handle_generate_button_click" - }, - "visible": true - }, - "kdx0s5tf0t6t272y": { - "id": "kdx0s5tf0t6t272y", - "type": "tab", - "content": { - "name": "Hyperbole" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "amo4m8mssxwfztng", - "handlers": { - "click": "get_current_tab" - }, - "visible": "tab_enabled.hyperbole" - }, - "4ut5mwq967zm0049": { - "id": "4ut5mwq967zm0049", - "type": "columns", - "content": {}, - "isCodeManaged": false, - "position": 0, - "parentId": "kdx0s5tf0t6t272y", - "handlers": {}, - "visible": true - }, - "p6hezc459yfkcvrb": { - "id": "p6hezc459yfkcvrb", - "type": "column", - "content": { - "width": "1" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "4ut5mwq967zm0049", - "handlers": {}, - "visible": true - }, - "9n7r2yllx9h6d9vh": { - "id": "9n7r2yllx9h6d9vh", - "type": "section", - "content": { - "title": "Original text" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "p6hezc459yfkcvrb", - "handlers": {}, - "visible": true - }, - "giyebjqjd4tuojwy": { - "id": "giyebjqjd4tuojwy", - "type": "message", - "content": { - "message": "@{output.hyperbole.text}" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "9n7r2yllx9h6d9vh", - "handlers": {}, - "visible": true - }, - "8avbiu3lz7hzk4u4": { - "id": "8avbiu3lz7hzk4u4", - "type": "section", - "content": { - "title": "Suggestion" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "p6hezc459yfkcvrb", - "handlers": {}, - "visible": true - }, - "cumxx6s29p0kf3p1": { - "id": "cumxx6s29p0kf3p1", - "type": "message", - "content": { - "message": "+@{output.hyperbole.suggestion}" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "8avbiu3lz7hzk4u4", - "handlers": {}, - "visible": true - }, - "jdjc5g79v7qffben": { - "id": "jdjc5g79v7qffben", - "type": "column", - "content": { - "width": "1" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "4ut5mwq967zm0049", - "handlers": {}, - "visible": true - }, - "smuxxei8eqmzd3i5": { - "id": "smuxxei8eqmzd3i5", - "type": "tags", - "content": { - "tags": "{\n \"Hyperbole\": \"hyperbole\"\n}" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "jdjc5g79v7qffben", - "handlers": {}, - "visible": true - }, - "fhomxd6iobyhvq22": { - "id": "fhomxd6iobyhvq22", - "type": "message", - "content": { - "message": "!@{output.hyperbole.description}" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "jdjc5g79v7qffben", - "handlers": {}, - "visible": true - }, - "br9ri32d6dwg6btf": { - "id": "br9ri32d6dwg6btf", - "type": "pagination", - "content": { - "page": "@{pagination.hyperbole.current_page}", - "pageSizeOptions": "", - "totalItems": "@{pagination.hyperbole.data_size}", - "pageSize": "1" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "kdx0s5tf0t6t272y", - "handlers": { - "wf-change-page": "set_page" - }, - "visible": true - }, - "220abedg02oxr0df": { - "id": "220abedg02oxr0df", - "type": "columns", - "content": {}, - "isCodeManaged": false, - "position": 0, - "parentId": "1ntjnjorgokmrksh", - "handlers": {}, - "visible": true - }, - "ash4sqj4675xby5u": { - "id": "ash4sqj4675xby5u", - "type": "column", - "content": { - "width": "1" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "220abedg02oxr0df", - "handlers": {}, - "visible": true - }, - "pz1uzfd2sgvj35wf": { - "id": "pz1uzfd2sgvj35wf", - "type": "section", - "content": { - "title": "Original text" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "ash4sqj4675xby5u", - "handlers": {}, - "visible": true - }, - "wufcwgrrybpweoc2": { - "id": "wufcwgrrybpweoc2", - "type": "message", - "content": { - "message": "@{output.we_pronoun.text}" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "pz1uzfd2sgvj35wf", - "handlers": {}, - "visible": true - }, - "4euoiqzlcfgkrd51": { - "id": "4euoiqzlcfgkrd51", - "type": "section", - "content": { - "title": "Suggestion" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "ash4sqj4675xby5u", - "handlers": {}, - "visible": true - }, - "gg5gv7ukdcbp0ys7": { - "id": "gg5gv7ukdcbp0ys7", - "type": "message", - "content": { - "message": "+@{output.we_pronoun.suggestion}" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "4euoiqzlcfgkrd51", - "handlers": {}, - "visible": true - }, - "0jydi26cfk0lj4zg": { - "id": "0jydi26cfk0lj4zg", - "type": "column", - "content": { - "width": "1" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "220abedg02oxr0df", - "handlers": {}, - "visible": true - }, - "hddj4kf5pbu7nltg": { - "id": "hddj4kf5pbu7nltg", - "type": "tags", - "content": { - "tags": "{\n \"we_pronoun\": \"we pronoun\"\n}" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "0jydi26cfk0lj4zg", - "handlers": {}, - "visible": true - }, - "tbherv4idvftfhr5": { - "id": "tbherv4idvftfhr5", - "type": "message", - "content": { - "message": "!@{output.we_pronoun.description}" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "0jydi26cfk0lj4zg", - "handlers": {}, - "visible": true - }, - "tu8ujfgmwm1cviiu": { - "id": "tu8ujfgmwm1cviiu", - "type": "pagination", - "content": { - "page": "@{pagination.we_pronoun.current_page}", - "pageSizeOptions": "", - "totalItems": "@{pagination.we_pronoun.data_size}", - "pageSize": "1" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "1ntjnjorgokmrksh", - "handlers": { - "wf-change-page": "set_page" - }, - "visible": true - }, - "oifvuxkfgni30c04": { - "id": "oifvuxkfgni30c04", - "type": "image", - "content": { - "src": "@{img_path}", - "caption": "", - "maxHeight": "30", - "maxWidth": "" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "bebc5fe9-63a7-46a7-b0fa-62303555cfaf", - "handlers": {}, - "visible": true - }, - "c30ch4pibyw5juug": { - "id": "c30ch4pibyw5juug", - "type": "html", - "content": { - "styles": "{\n \"padding\": \"16px\",\n\"padding-top\":\"20px\",\n \"min-height\": \"64px\",\n\"max-height\": \"420px\",\n\"overflow\":\"auto\",\n \"min-width\": \"64px\",\n \"border-radius\": \"8px\"\n}", - "htmlInside": "@{html_content}" - }, - "isCodeManaged": false, - "position": 0, - "parentId": "3wckjuynvz0od6w9", - "handlers": {}, - "visible": true - }, - "3wckjuynvz0od6w9": { - "id": "3wckjuynvz0od6w9", - "type": "section", - "content": { - "title": "" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "0r3y4groykgktb1l", - "handlers": {}, - "visible": true - }, - "cfdn0lwtc3bc2e1i": { - "id": "cfdn0lwtc3bc2e1i", - "type": "message", - "content": { - "message": "@{message}" - }, - "isCodeManaged": false, - "position": 1, - "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", - "handlers": {}, - "visible": true - } - } -} \ No newline at end of file diff --git a/finance-content-checker/utils.py b/finance-content-checker/utils.py index 111736c..f20eae9 100644 --- a/finance-content-checker/utils.py +++ b/finance-content-checker/utils.py @@ -20,13 +20,13 @@ def highlight_string(state,rule): def convert_string_to_dict_list(input_string): try: - # Properly format the string to make it a valid JSON array - formatted_string = '[' + input_string.replace('}\n {', '},\n {') + ']' + # # Properly format the string to make it a valid JSON array + input_string = input_string.replace("```json", "").replace("```", "") # Convert the formatted string into a list of dictionaries - data_list = json.loads(formatted_string) + data_list = json.loads(input_string) return data_list except json.JSONDecodeError as e: - print(f"Error decoding JSON: {e}") + print(e) return [] From 88663a5001119f83bb571cde0778237a24d01d3d Mon Sep 17 00:00:00 2001 From: Johannes Date: Fri, 3 Jan 2025 08:26:39 +0100 Subject: [PATCH 2/3] fix: change info message --- finance-content-checker/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/finance-content-checker/main.py b/finance-content-checker/main.py index 8d1d99c..fd2bf62 100644 --- a/finance-content-checker/main.py +++ b/finance-content-checker/main.py @@ -39,11 +39,12 @@ async def process_rules(state): tasks = [] + state["message"] = "Performing analysis..." + # Fetch data for each rule for rule in rules: if(rule.name in state["suggestion_flags_selected"]): formatted_name = rule.name.replace("_", " ") - state["message"] = f"Processing {formatted_name}..." tasks.append(rule.fetch_data()) await asyncio.gather(*tasks) From eee626fcf9f63a1287649284095c7ab9ae287acb Mon Sep 17 00:00:00 2001 From: Johannes Date: Thu, 9 Jan 2025 08:16:03 +0100 Subject: [PATCH 3/3] fix: change model type for PI summary drafting --- prescribing-info-app/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/prescribing-info-app/main.py b/prescribing-info-app/main.py index c31205c..713f97f 100644 --- a/prescribing-info-app/main.py +++ b/prescribing-info-app/main.py @@ -37,9 +37,10 @@ def update_drug_data(state: WriterState, drug_name: str) -> None: state["prescribing_info_summary"] = "" for chunk in stream_complete( - prescribing_summary_prompt.format( + initial_text=prescribing_summary_prompt.format( prescribing_details=state["raw_prescribing_info"] - ) + ), + config={"model": "palmyra-med"} ): state["prescribing_info_summary"] += chunk @@ -174,4 +175,4 @@ def contributing_sources_change_vis(state: WriterState) -> None: } ) -initial_state.import_stylesheet("style", "/static/custom.css?1") +initial_state.import_stylesheet("style", "/static/custom.css")