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

[FEAT]: showing citations when using Perplexity through OpenRouter #3581

@rudimichal

Description

@rudimichal

What would you like to see?

AnythingLLM already shows citations when Perplexity is used through its own api #2827 . When accessing Perplexity through OpenRouter the citations are not shown.

I checked that OpenRouter does return these citations:

import os

from openai import OpenAI


def main():
    client = OpenAI(
        base_url="https://openrouter.ai/api/v1/",
        api_key=os.getenv("OPENROUTER_API_KEY"),
    )
    response = client.chat.completions.create(
        model="perplexity/sonar",
        messages=[
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": "battle of waterloo"},
                ],
            },
        ],
    )

    print(response.citations)


if __name__ == "__main__":
    main()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions