langchain icon indicating copy to clipboard operation
langchain copied to clipboard

partners: Add the additonnal kward 'context' for openai

Open lucasiscovici opened this issue 2 months ago • 2 comments

Description

Add the additonnal kward 'context' for openai into convert_dict_to_message and convert_message_to_dict functions.

Details

In recent versions of the Azure OpenAI Chat With Your Data, a significant enhancement has been introduced with the addition of the "context" property into the response chat message.

The "context" property is added to the assistant's messages to provide extra information about the steps taken by Azure OpenAI while processing a request. This includes retrieved documents, citations, and other relevant metadata.

Chat message

The response assistant message schema inherits from the chat completions assistant chat message, and is extended with the property context.

Name Type Required Description
context Context False Represents the incremental steps performed by the Azure OpenAI On Your Data while processing the request, including the retrieved documents.

Context

Name Type Required Description
citations Citation[] False The data source retrieval result, used to generate the assistant message in the response. Clients can render references from the citations.
intent string False The detected intent from the chat history. Passing back the previous intent is no longer needed. Ignore this property.
all_retrieved_documents Retrieved documents[] False All the retrieved documents.

Citation

Name Type Required Description
content string True The content of the citation.
title string False The title of the citation.
url string False The URL of the citation.
filepath string False The file path of the citation.
chunk_id string False The chunk ID of the citation.

Retrieved documents

Name Type Required Description
search_queries string[] True The search queries used to retrieve the document.
data_source_index integer True The index of the data source.
original_search_score double True The original search score of the retrieved document.
rerank_score double False The rerank score of the retrieved document.
filter_reason string False Represents the rationale for filtering the document. If the document does not undergo filtering, this field will remain unset. Will be score if the document is filtered by original search score threshold defined by strictness. Will be rerank if the document is not filtered by original search score threshold, but is filtered by rerank score and top_n_documents.

@ccurme

lucasiscovici avatar Dec 03 '24 09:12 lucasiscovici