这是indexloc提供的服务,不要输入任何密码
Skip to content

handling of citations in openRouter provider #3581 #3620

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

Merged

Conversation

rudimichal
Copy link
Contributor

Pull Request Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

Relevant Issues

resolves #3581

What is in this change?

If OpenRouter returns citations they are used to enrich tokens with urls (just like it's already implemented in Perplexity provider). Additionally, all citations are appended to model response.

Screenshot 2025-04-09 at 11 40 55 AM

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

@timothycarambat timothycarambat self-assigned this Apr 15, 2025
@timothycarambat timothycarambat added the PR:needs review Needs review by core team label Apr 15, 2025
Modify OR enrichToken to be generic handler function with optional params
handle _just_ Perplexity in-line citations since no other models support this functionality
@timothycarambat
Copy link
Member

Modified the PR since the code paths were assuming that the OR model would always be perplexity, and we should short-circuit any PPLX logic since most models on OR are not PPLX models.

  • Modified the enrichToken to be more generic so we can extend it in the future if any other handling cases arise
  • Removed text added to the end of the response of all the links. We don't do this in the native perplexity provider, and they should function the same. That being said, I think this can be extended into sources so they can be seen in the response like what you did have previously

Tested:

  • PPLX reasoning and non-reasoning in-line citations
  • Reasoning only models like Deepseek
  • Normal models like Llama 4 Scout with no reasoning or citations

@timothycarambat timothycarambat merged commit be27299 into Mintplex-Labs:master Apr 15, 2025
cabwds pushed a commit to cabwds/anything-llm that referenced this pull request Jul 3, 2025
…plex-Labs#3620)

* handling of citations in openRouter provider Mintplex-Labs#3581

* Update pplx enrichToken function comment
Modify OR enrichToken to be generic handler function with optional params
handle _just_ Perplexity in-line citations since no other models support this functionality

* remove console log

---------

Co-authored-by: timothycarambat <rambat1010@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR:needs review Needs review by core team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT]: showing citations when using Perplexity through OpenRouter
2 participants