Skip to content

Commit

Permalink
revert app change
Browse files Browse the repository at this point in the history
  • Loading branch information
madeindjs committed Jan 21, 2025
1 parent c9bddf5 commit c9c7b61
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
{"id": "o1753ot0w2n4704o", "type": "tags", "content": {"tags": "@{tags}"}, "handlers": {}, "isCodeManaged": false, "parentId": "4k8f6ju68i8qej2s", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "ywzboz2fup220b1d", "type": "separator", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "4k8f6ju68i8qej2s", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "q237uluwl8idg8is", "type": "text", "content": {"text": "@{posts}", "useMarkdown": "yes"}, "handlers": {}, "isCodeManaged": false, "parentId": "4k8f6ju68i8qej2s", "position": 2, "visible": {"binding": "", "expression": "custom", "reversed": false}}
{"id": "dt27gdzirkvnbqw7", "type": "dataframe", "content": {"dataframe": "@{editable_df}", "enableRecordUpdate": "yes", "showIndex": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 2}
2 changes: 1 addition & 1 deletion apps/text-demo/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"writer_version": "0.8.3rc3"
"writer_version": "0.8.0rc1"
}
45 changes: 9 additions & 36 deletions apps/text-demo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,28 @@

import writer as wf
import writer.ai
import pandas as pd

wf.Config.feature_flags = ["dataframeEditor"]
# Welcome to Writer Framework!
# Welcome to Writer Framework!
# This is a simple app to get you started with text completion.
# More documentation is available at https://dev.writer.com

lorem = " Lorem ipsum dolor sit amet, consectetur adipiscing elit. In tellus neque, venenatis et dui in, rhoncus mattis dui. Donec auctor ante eget elit finibus scelerisque. Sed convallis, lorem ac porttitor dignissim, risus leo laoreet sapien, sed sagittis felis mauris in lectus. Fusce at condimentum erat. Proin in elit ultrices, tincidunt elit vitae, sollicitudin nisl. Vestibulum eu felis eu justo commodo sodales. Proin faucibus lorem at massa porta, quis ornare mauris fringilla. Nam volutpat rhoncus placerat. Fusce malesuada nunc a turpis dignissim maximus nec eget augue. Vivamus sed sem nec purus ultrices gravida in et lorem. "


def _get_editable_df():
size = 5
df = pd.DataFrame(
{
"number": [1, 2, 3] * size,
"boolean": [True, False, True] * size,
"object": [{"updatedAt": None}, {"updatedAt": None}, {"updatedAt": None}] * size,
"text1": ["one", "two", lorem] * size,
"text2": ["one", "two", "three"] * size,
"text3": ["one", "two", "three"] * size,
"text4": ["one", "two", "three"] * size,
"text5": ["one", "two", "three"] * size,
}
)
return wf.EditableDataFrame(df)


def handle_button_click(state):
state["message"] = "% Loading up expert social media posts..."

prompt = f"You are a social media expert. Generate 5 engaging social media posts about {state['topic']}. Include emojis."
state["posts"] = writer.ai.complete(prompt)

prompt = f"You are a social media expert. Generate 5 hashtags about {state['topic']}, delimited by spaces. For example, #dogs #cats #ducks #elephants #badgers"
pattern = r"#\w+"
pattern = r'#\w+'
hashtags = re.findall(pattern, writer.ai.complete(prompt))
state["tags"] = {item: item for item in hashtags}

state["message"] = ""


# Initialize state here

wf.init_state(
{
"posts": "",
"topic": "writing",
"message": "",
"editable_df": _get_editable_df(),
}
)

wf.init_state({
"posts": "",
"topic": "writing",
"message": ""
})

0 comments on commit c9c7b61

Please sign in to comment.