-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds support for perplexity citations #34
Adds support for perplexity citations #34
Conversation
@regismesquita thank you for your PR. |
@Renset No problem, let me know if I can change this PR in any way. Having access to perplexity citations is something that I have been looking for for some time now. Most of the tools that I interact with (LiteLLM, Kerlig, Alter, and IDEs) don't offer proper support, even the ones that support perplexity, and it is such a nice feature to have :) |
@regismesquita good point about citation support, I see no reason not to implement it :)
and the quote array looks like this
then replace text [1] in the message with the link:
Still not the best solution, as it should be processed on the view layer IMO, but this better solution will involve a lot of changes in many files. Thus, the handler implementation as above suggests the best balance between effort and result. |
f2e1dbd
to
57fc236
Compare
@Renset updated the handler here, It will do the search and replace strategy for non streamed responses, it will add a source line at the end with the links with the requested format and it will not generate sources when doing chat name generation. |
unfortunately I couldn't figure out a way of doing the search and replace method when handling streamed responses without changing the view layer to allow me to edit it. |
@regismesquita Great. I've investigated data chunks via Proxyman and see that every stream chunk starting from the very first, already contains the complete
|
@Renset oh! you are correct! that made the implementation so much better. I have pushed the changes. |
@regismesquita for some reason it only works for the very first response in a chat. The other messages do not have clickable links (tested with stream responses)... |
I did some quick runs here and noticed a similar effect, but it wasn't really just for the first one. It occurred randomly. I suspect that in the partial responses, we might not be receiving the full [1] or [2], but a partial [1, and then on the next package, the closing ], but that is only a guess. I'm not sure if I'll be able to look into it over the next few days, but I will certainly be able to examine it over the weekend. |
Nevermind the above, lldb shows |
@Renset pushed a fix. Lunch time is over, but I will take another look later. This patch seems to fix the issue; however, I'm under the impression that I have seen it happening again after this change, but I'm not sure. Will investigate a bit more later. |
Feel free to push any fixes if the issue is now obvious to you, Swift is not my first language. |
@regismesquita I've done a bit of testing. |
@Renset done. |
Simple implementation, more reasonable than creating a whole new adapter
for perplexity since it's OpenAI-like. Doesn't affect other providers.
Open to changes if deemed necessary.