Open jdubois opened 1 month ago
/cc @agoncal (azure)
Please note that this is related to general error-handling, not only for responsible AI case
Perharps we could add "refusal" field to AiMessage
with details about refusal. Similar to what OpenAI did for Structured Outputs.
Currently when we have a "Responsible AI" error (=violence, sexual content, etc), we return a message with the error:
https://github.com/langchain4j/langchain4j/blob/29299124489179aca7391209ec3b8ae0b9cce28e/langchain4j-azure-open-ai/src/main/java/dev/langchain4j/model/azure/AzureOpenAiChatModel.java#L318
There is feedback to throw an exception instead of returning an error message in the field where user would expect LLM generated text to be.
This was noted in #1807 for GitHub Models, which work the same way: let's discuss this in the general ticket, and then apply it to Azure OpenAI, GitHub Models, and maybe more.