Community: Adding citations in AIMessage for ChatPerplexity (#28321)

**Description**: Adding Citation in response payload of ChatPerplexity
**Issue**: #28108
This commit is contained in:
Mohammad Mohtashim 2024-11-26 19:45:47 +05:00 committed by GitHub
parent aa2c17b56c
commit 195ae7baa3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -261,7 +261,10 @@ class ChatPerplexity(BaseChatModel):
response = self.client.chat.completions.create( response = self.client.chat.completions.create(
model=params["model"], messages=message_dicts model=params["model"], messages=message_dicts
) )
message = AIMessage(content=response.choices[0].message.content) message = AIMessage(
content=response.choices[0].message.content,
additional_kwargs={"citations": response.citations},
)
return ChatResult(generations=[ChatGeneration(message=message)]) return ChatResult(generations=[ChatGeneration(message=message)])
@property @property