mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-01 04:29:09 +00:00
openai[patch]: Added annotations support to azure openai (#13704)
- **Description:** Added Azure OpenAI Annotations (content filtering results) to ChatResult - **Issue:** 13090 - **Twitter handle:** ElazarShay Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
parent
32c5be8b73
commit
84ebfb5b9d
@ -217,9 +217,19 @@ class AzureChatOpenAI(ChatOpenAI):
|
||||
if self.model_version:
|
||||
model = f"{model}-{self.model_version}"
|
||||
|
||||
if chat_result.llm_output is not None and isinstance(
|
||||
chat_result.llm_output, dict
|
||||
):
|
||||
chat_result.llm_output["model_name"] = model
|
||||
chat_result.llm_output = chat_result.llm_output or {}
|
||||
chat_result.llm_output["model_name"] = model
|
||||
if "prompt_filter_results" in response:
|
||||
chat_result.llm_output = chat_result.llm_output or {}
|
||||
chat_result.llm_output["prompt_filter_results"] = response[
|
||||
"prompt_filter_results"
|
||||
]
|
||||
for chat_gen, response_choice in zip(
|
||||
chat_result.generations, response["choices"]
|
||||
):
|
||||
chat_gen.generation_info = chat_gen.generation_info or {}
|
||||
chat_gen.generation_info["content_filter_results"] = response_choice.get(
|
||||
"content_filter_results", {}
|
||||
)
|
||||
|
||||
return chat_result
|
||||
|
Loading…
Reference in New Issue
Block a user