Skip to content

Commit d8f7441

Browse files
committed
send dummy request to load model
1 parent fa36181 commit d8f7441

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

backend/src/app/core/data/llm/ollama_service.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ def __new__(cls, *args, **kwargs):
7979
cls.__max_vlm_chat_sessions = 50
8080
cls.__max_vlm_chat_session_age = 7 * 24 * 60 * 60 # 7 days
8181

82+
# load the model with a dummy request to ensure that it is loaded and ready to use
83+
ollamac.chat(
84+
model=cls.__model["llm"],
85+
messages=[
86+
{
87+
"role": "system",
88+
"content": "You are kind and helpful.",
89+
},
90+
{
91+
"role": "user",
92+
"content": "Hi!",
93+
},
94+
],
95+
options=cls.__default_kwargs["llm"],
96+
)
97+
8298
except Exception as e:
8399
msg = f"Cannot instantiate OllamaService - Error '{e}'"
84100
logger.error(msg)

0 commit comments

Comments
 (0)