From 9ca4ff65ecffe7191f45acbf37f7d4b94ead1d77 Mon Sep 17 00:00:00 2001 From: David Wallace Date: Fri, 12 Dec 2025 13:50:22 +0100 Subject: [PATCH 1/7] Use timezone.utc instead of UTC Signed-off-by: David Wallace --- rdmo_chatbot/plugin/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rdmo_chatbot/plugin/utils.py b/rdmo_chatbot/plugin/utils.py index bbdeed3..26b46c2 100644 --- a/rdmo_chatbot/plugin/utils.py +++ b/rdmo_chatbot/plugin/utils.py @@ -1,4 +1,4 @@ -from datetime import UTC, datetime, timedelta +from datetime import datetime, timedelta, timezone from django import template from django.conf import settings @@ -15,7 +15,7 @@ def get_chatbot_token(user): "identifier": user.username, "display_name": get_full_name(user), "metadata": {}, - "exp": datetime.now(UTC) + timedelta(minutes=60 * 24), + "exp": datetime.now(timezone.utc) + timedelta(minutes=60 * 24), } return jwt.encode(token_data, settings.CHATBOT_AUTH_SECRET, algorithm="HS256") From c9facce52a37c9abb5179029da316718c0db3288 Mon Sep 17 00:00:00 2001 From: David Wallace Date: Fri, 12 Dec 2025 15:32:25 +0100 Subject: [PATCH 2/7] Prevent call copilot from returning None Signed-off-by: David Wallace --- rdmo_chatbot/chatbot/adapter.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/rdmo_chatbot/chatbot/adapter.py b/rdmo_chatbot/chatbot/adapter.py index 227106c..0d1f30e 100644 --- a/rdmo_chatbot/chatbot/adapter.py +++ b/rdmo_chatbot/chatbot/adapter.py @@ -11,11 +11,16 @@ class BaseAdapter: - async def call_copilot(self, name, args={}, default=None): - return_value = default - if cl.context.session.client_type == "copilot": - return_value = await cl.CopilotFunction(name=name, args=args).acall() - return return_value + async def call_copilot(self, name: str, fallback = None, **kwargs): + if cl.context.session.client_type != "copilot": + return fallback + + try: + result = await cl.CopilotFunction(name=name, args=kwargs).acall() + except Exception: + return fallback + + return fallback if result is None else result async def on_chat_start(self): pass @@ -62,7 +67,7 @@ async def on_chat_start(self): cl.user_session.set("project_id", project_id) # get lang_code from the copilot and store it in the session - lang_code = await self.call_copilot("getLangCode", default="en") + lang_code = await self.call_copilot("getLangCode", fallback="en") cl.user_session.set("lang_code", lang_code) # check if we have a history, yet @@ -93,7 +98,8 @@ async def on_user_message(self, message): user = cl.user_session.get("user") # get the full project from the copilot - project = await self.call_copilot("getProject", default={}) + project = await self.call_copilot("getProject") + project = project if isinstance(project, dict) else {} project_id = project.get("id") # get the history from the store @@ -153,7 +159,7 @@ async def on_system_message(self, message): store.reset_history(user.identifier, project_id) async def on_transfer(self, action): - await self.call_copilot("handleTransfer", args=action.payload) + await self.call_copilot("handleTransfer", **action.payload) async def on_contact(self, action): # get user and project_id from the session @@ -163,9 +169,7 @@ async def on_contact(self, action): # get the history from the store history = store.get_history(user.identifier, project_id) - await self.call_copilot("openContactModal", args={ - "history": messages_to_dicts(history) - }) + await self.call_copilot("openContactModal", history=messages_to_dicts(history)) class OpenAILangChainAdapter(LangChainAdapter): From 6127f027c725eeba7b336cb562ef1ef79ec3d75d Mon Sep 17 00:00:00 2001 From: David Wallace Date: Wed, 17 Dec 2025 11:12:08 +0100 Subject: [PATCH 3/7] Fix typo in readme Signed-off-by: David Wallace --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index caddf2d..3fd93ba 100644 --- a/README.md +++ b/README.md @@ -263,4 +263,4 @@ Acknowledgement We would like to thank the Federal Government and the Heads of Government of the Länder, as well as the Joint Science Conference (GWK), for their funding and support within the framework of the NFDI4ING consortium. -Funded by the German Research Foundation (DFG) - project number 442146713." +Funded by the German Research Foundation (DFG) - project number 442146713. From 9a5504cbab10c1d648574e4403d23da8e251cf00 Mon Sep 17 00:00:00 2001 From: David Wallace Date: Wed, 17 Dec 2025 15:32:33 +0100 Subject: [PATCH 4/7] js: fix chainlitServer as URL in project_interview Signed-off-by: David Wallace --- .../plugin/templates/projects/project_interview.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rdmo_chatbot/plugin/templates/projects/project_interview.html b/rdmo_chatbot/plugin/templates/projects/project_interview.html index 6f94d1c..826361f 100644 --- a/rdmo_chatbot/plugin/templates/projects/project_interview.html +++ b/rdmo_chatbot/plugin/templates/projects/project_interview.html @@ -37,9 +37,14 @@