mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-01 02:50:47 +00:00
openai[patch]: propagate service_tier to response metadata (#31089)
This commit is contained in:
@@ -736,6 +736,8 @@ class BaseChatOpenAI(BaseChatModel):
|
||||
generation_info["model_name"] = model_name
|
||||
if system_fingerprint := chunk.get("system_fingerprint"):
|
||||
generation_info["system_fingerprint"] = system_fingerprint
|
||||
if service_tier := chunk.get("service_tier"):
|
||||
generation_info["service_tier"] = service_tier
|
||||
|
||||
logprobs = choice.get("logprobs")
|
||||
if logprobs:
|
||||
@@ -1020,6 +1022,8 @@ class BaseChatOpenAI(BaseChatModel):
|
||||
}
|
||||
if "id" in response_dict:
|
||||
llm_output["id"] = response_dict["id"]
|
||||
if "service_tier" in response_dict:
|
||||
llm_output["service_tier"] = response_dict["service_tier"]
|
||||
|
||||
if isinstance(response, openai.BaseModel) and getattr(
|
||||
response, "choices", None
|
||||
@@ -3243,6 +3247,7 @@ def _construct_lc_result_from_responses_api(
|
||||
"status",
|
||||
"user",
|
||||
"model",
|
||||
"service_tier",
|
||||
)
|
||||
}
|
||||
if metadata:
|
||||
|
Reference in New Issue
Block a user