File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
libs/rag-core-api/src/rag_core_api/impl Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,13 @@ async def ainvoke(
126126 - The method processes the chat history based on the settings defined in `_chat_history_settings`.
127127 - The history is formatted and included in the `AnswerGraphState`.
128128 """
129+ if not graph_input .message .strip ():
130+ return ChatResponse (
131+ answer = self ._error_messages .empty_message ,
132+ citations = [],
133+ finish_reason = self ._error_messages .empty_message ,
134+ )
135+
129136 history_of_interest = []
130137 if graph_input .history and graph_input .history .messages :
131138 history_of_interest = graph_input .history .messages [- self ._chat_history_settings .limit :]
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ class ErrorMessages(BaseSettings):
1818 Default message for harmful or inappropriate questions.
1919 no_answer_found : str
2020 Default message when no answer is found with the given context.
21+ empty_message : str
22+ Default message when an empty question is provided.
2123 """
2224
2325 class Config :
@@ -40,3 +42,5 @@ class Config:
4042 no_answer_found : str = Field (
4143 default = "Es tut mir leid, mit dem mir bereitgestellten Kontext konnte ich keine Antwort finden."
4244 )
45+
46+ empty_message : str = Field (default = "Es tut mir leid, ich kann keine leere Frage beantworten." )
You can’t perform that action at this time.
0 commit comments