Skip to content

Commit 8d41ac9

Browse files
committed
Propagate config loading errors to the chat in server mode.
This will allow the user to see messages that for example ask the user to install openai.
1 parent 2375d4b commit 8d41ac9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

nemoguardrails/server/api.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ async def chat_completion(body: RequestBody):
103103
config_id = body.config_id
104104
try:
105105
llm_rails = _get_rails(config_id)
106-
except ValueError:
106+
except ValueError as ex:
107107
return {
108108
"messages": [
109-
{"role": "assistant", "content": "Invalid guardrails configuration."}
109+
{
110+
"role": "assistant",
111+
"content": f"Could not load the {config_id} guardrails configuration: {str(ex)}",
112+
}
110113
]
111114
}
112115

0 commit comments

Comments
 (0)