From 981360f5562f56525e6b602ba469dfa476498ea3 Mon Sep 17 00:00:00 2001 From: David Straub Date: Sat, 28 Dec 2024 11:18:05 +0100 Subject: [PATCH] Do not import LLM functions at top level --- gramps_webapi/api/resources/chat.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gramps_webapi/api/resources/chat.py b/gramps_webapi/api/resources/chat.py index 6e8a3ac7..09eec15f 100644 --- a/gramps_webapi/api/resources/chat.py +++ b/gramps_webapi/api/resources/chat.py @@ -22,7 +22,6 @@ from marshmallow import Schema from webargs import fields -from ..llm import answer_prompt_retrieve from ..util import ( get_tree_from_jwt, use_args, @@ -54,6 +53,9 @@ def post(self, args): """Create a chat response.""" require_permissions({PERM_USE_CHAT}) check_quota_ai(requested=1) + # import here to avoid error if OpenAI-Python is not installed + from gramps_webapi.api.llm import answer_prompt_retrieve + tree = get_tree_from_jwt() try: response = answer_prompt_retrieve(