From d646732b8316a97923bec748900e0a9ba877a1e1 Mon Sep 17 00:00:00 2001 From: mmikita95 Date: Fri, 8 Nov 2024 17:34:02 +0400 Subject: [PATCH 01/26] chore: serialize tool calls messages with non-empty content --- src/writer/ai.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/writer/ai.py b/src/writer/ai.py index bb260a9ad..bfae63964 100644 --- a/src/writer/ai.py +++ b/src/writer/ai.py @@ -1824,7 +1824,18 @@ def _is_serialized(self, message: 'Conversation.Message') -> bool: elif message.get("tool_call_id") is not None: return False tool_calls = message.get("tool_calls") - if tool_calls is not None and tool_calls != []: + if ( + ( + tool_calls is not None + and + tool_calls != [] + ) + and + not message.get("content") + ): + # If tool call request message + # doesn't have meaningful content, + # we don't serialize it return False return True From 2f96977eb1270ae4a9d1bf6c33abbcefb2bb71db Mon Sep 17 00:00:00 2001 From: mmikita95 Date: Mon, 18 Nov 2024 10:51:13 +0300 Subject: [PATCH 02/26] chore: update `_is_serialized` --- src/writer/ai.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/writer/ai.py b/src/writer/ai.py index bfae63964..20a82d0a4 100644 --- a/src/writer/ai.py +++ b/src/writer/ai.py @@ -1820,22 +1820,12 @@ def _is_serialized(self, message: 'Conversation.Message') -> bool: :return: Boolean that indicates """ if message["role"] in ["system", "tool"]: + # Prevent serialization of messages + # not intended for user display return False - elif message.get("tool_call_id") is not None: - return False - tool_calls = message.get("tool_calls") - if ( - ( - tool_calls is not None - and - tool_calls != [] - ) - and - not message.get("content") - ): - # If tool call request message - # doesn't have meaningful content, - # we don't serialize it + elif message.get("content") is None: + # Prevent serialization for messages + # without meaningful content return False return True From bb3683a25c1063482990705a6a6c536bc0a897d3 Mon Sep 17 00:00:00 2001 From: Mikita Makiej <157150795+mmikita95@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:46:52 +0300 Subject: [PATCH 03/26] fix: unfinished docstring --- src/writer/ai.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/writer/ai.py b/src/writer/ai.py index 20a82d0a4..23192adb6 100644 --- a/src/writer/ai.py +++ b/src/writer/ai.py @@ -1817,7 +1817,8 @@ def _is_serialized(self, message: 'Conversation.Message') -> bool: """ Function to verify whether the message should be serializable. - :return: Boolean that indicates + :return: Boolean indicating if the message meets + the criteria for serialization. """ if message["role"] in ["system", "tool"]: # Prevent serialization of messages From 93a4f6ed024fae073f043e3be7f82cf10956352d Mon Sep 17 00:00:00 2001 From: Mikita Makiej <157150795+mmikita95@users.noreply.github.com> Date: Mon, 18 Nov 2024 12:47:27 +0300 Subject: [PATCH 04/26] fix: also include empty non-`None` content as failing condition --- src/writer/ai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/writer/ai.py b/src/writer/ai.py index 23192adb6..0e3c6a44c 100644 --- a/src/writer/ai.py +++ b/src/writer/ai.py @@ -1824,7 +1824,7 @@ def _is_serialized(self, message: 'Conversation.Message') -> bool: # Prevent serialization of messages # not intended for user display return False - elif message.get("content") is None: + elif not message.get("content"): # Prevent serialization for messages # without meaningful content return False From 8cf3151998bb3ff1995c5b4ad740722d7cc02035 Mon Sep 17 00:00:00 2001 From: Fabien Arcellier Date: Mon, 21 Oct 2024 17:36:24 +0200 Subject: [PATCH 05/26] feat: add metadata for social media sharing * feat: implement configure_page_head signature --- src/writer/serve.py | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/writer/serve.py b/src/writer/serve.py index c2b23e62d..38ad1636d 100644 --- a/src/writer/serve.py +++ b/src/writer/serve.py @@ -556,6 +556,70 @@ async def lifespan(app: FastAPI): async with _lifespan_invoke(writer_lifespans, app): yield +def configure_page_head( + title: Union[str, Callable[[], str]] = "Writer Framework", + meta: Optional[Union[Dict[str, Any], Callable[[], Dict[str, Any]]]] = None, + opengraph_tags: Optional[Union[Dict[str, Any], Callable[[], Dict[str, Any]]]] = None +): + """ + Configures the page header for SEO and social networks. + + >>> writer.serve.configure_page_head( + >>> title="my App", + >>> meta={ + >>> "description": "my amazing app", + >>> "keywords": "WF, Amazing, AI App", + >>> "author": "Amazing company" + >>> } + >>>) + + Meta will accept description, keywords, author. Other meta tags as view port won't be supported. + + Settings accept functions to adapt content based on application data. + + >>> def generated_title(): + >>> return "My App" # load title using info from database + + >>> def generated_meta_tags(): + >>> { + >>> "description": "my amazing app", + >>> "keywords": "WF, Amazing, AI App", + >>> "author": "Amazing company" + >>> } + + >>> writer.serve.configure_page_head( + >>> title=generated_title + >>> meta=generated_meta_tags + >>> ) + + OpenGraph tags are used by social networks to display information about the page. WF support them. + + >>> writer.serve.configure_page_head( + >>> title=generated_title + >>> opengraph_tags= { + >>> "og:title": "My App", + >>> "og:description": "My amazing app", + >>> "og:image": "https://myapp.com/logo.png", + >>> "og:url": "https://myapp.com" + >>> } + >>> ) + + >>> def generated_opengraph_tags(): + >>> return { + >>> "og:title": "My App", + >>> "og:description": "My amazing app", + >>> } + + >>> writer.serve.configure_page_head( + >>> title=generated_title + >>> opengraph_tags= generated_opengraph_tags + >>> ) + + :param title: The title of the page. + :param meta: A list of meta tags. + :param opengraph_tags: A dictionary of OpenGraph tags. + """ + pass @asynccontextmanager async def _lifespan_invoke(context: list, app: FastAPI): From 17ef41d7cc11eebb499ad590f724c3f987b56f1b Mon Sep 17 00:00:00 2001 From: Fabien Arcellier Date: Mon, 28 Oct 2024 10:41:31 +0100 Subject: [PATCH 06/26] feat: add metadata for social media sharing * feat: implement the settings --- src/ui/index.html | 2 ++ src/writer/serve.py | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/ui/index.html b/src/ui/index.html index ba5bd9749..f9b53bc63 100644 --- a/src/ui/index.html +++ b/src/ui/index.html @@ -5,6 +5,8 @@ Writer Framework + + diff --git a/src/ui/src/builder/BuilderSettingsHandlers.vue b/src/ui/src/builder/BuilderSettingsHandlers.vue index fa1a71af1..eca2728cd 100644 --- a/src/ui/src/builder/BuilderSettingsHandlers.vue +++ b/src/ui/src/builder/BuilderSettingsHandlers.vue @@ -13,48 +13,19 @@
{{ eventType }} - +
+ +