Skip to content

Conversation

welcoMattic
Copy link
Member

@welcoMattic welcoMattic commented Aug 31, 2025

Q A
Bug fix? no
New feature? yes
Docs? no
Issues Fix #...
License MIT

This PR adds Perplexity as a supported Platform.

Models are: sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro, and sonar-deep-research

API is similar to OpenAI API, with additional features I will take care of in coming days.

Perplexity docs:

@carsonbot carsonbot added Feature New feature Platform Issues & PRs about the AI Platform component Status: Needs Review labels Aug 31, 2025
@chr-hertel
Copy link
Member

Looks a bit like you started off with an old base branch?

@welcoMattic
Copy link
Member Author

While working on Perplexity specific features integration, I'm wondering how could we handle search_results and citations response keys?

Related Perplexity API reference: https://docs.perplexity.ai/api-reference/chat-completions-post#response-search-results

It's very specific to Perplexity platform, as they perform real web search internally (without leveraging MCP tools).

I see 2 possible solutions:

  • Adding a new SearchResult class, extending BaseResult with content, search_results and citations properties.
  • Adding a new SearchResultProcessor, implementing OutputProcessorInterface to "store" search_results and citations in Metadata object.

I'd prefer the 1st one.

WDYT @chr-hertel @OskarStark

@welcoMattic welcoMattic force-pushed the perplexity branch 2 times, most recently from 80fae92 to 6e9b56d Compare September 1, 2025 20:12
@chr-hertel
Copy link
Member

Let's go with Metadata first and see if there are similar things in other platforms before creating a new kind of result. It is still text right, but they add the search_results and citations to provide some extra information to the text that was generated, right?

@OskarStark
Copy link
Contributor

Yes I would prefer the metadata option too in the first version

@welcoMattic
Copy link
Member Author

welcoMattic commented Sep 2, 2025

It looks like this:

"citations" => array:5 [
    0 => "https://www.esa-gnc.eu/paper?paper_id=23186"
    1 => "http://link.springer.com/10.1007/s11367-017-1261-7"
    2 => "https://www.semanticscholar.org/paper/b11d3453077a784bb5f4b1314b00900d3c177989"
    3 => "https://www.semanticscholar.org/paper/774c12d06cb39fdc4a92433c5148424aa65f62e0"
    4 => "https://www.semanticscholar.org/paper/85dd93d2d37850c7d90d76a0fadd99dc217ed6db"
  ]
  "search_results" => array:5 [
    0 => array:5 [
      "title" => "Evaluating differential GNSS techniques for landing the 1st stage of an RLV – with a skydiver experiment"
      "url" => "https://www.esa-gnc.eu/paper?paper_id=23186"
      "date" => "2023-07-31"
      "last_updated" => null
      "snippet" => ""
    ]
    1 => array:5 [
      "title" => "A perspective for reducing environmental impacts of mussel culture in Algeria"
      "url" => "http://link.springer.com/10.1007/s11367-017-1261-7"
      "date" => "2017-01-27"
      "last_updated" => null
      "snippet" => ""
    ]
    2 => array:5 [
      "title" => "Sterculia urens Roxb. a Promising Gum Secreting Tree Used in Worldwide Food Industries"
      "url" => "https://www.semanticscholar.org/paper/b11d3453077a784bb5f4b1314b00900d3c177989"
      "date" => null
      "last_updated" => null
      "snippet" => ""
    ]
    3 => array:5 [
      "title" => "Sustainable production of microbial polysaccharide xanthan gum from supplemental subststrate."
      "url" => "https://www.semanticscholar.org/paper/774c12d06cb39fdc4a92433c5148424aa65f62e0"
      "date" => null
      "last_updated" => null
      "snippet" => ""
    ]
    4 => array:5 [
      "title" => "28-THE PHYSICAL FITNESS OF A GROUP OF ELDERLY WOMEN"
      "url" => "https://www.semanticscholar.org/paper/85dd93d2d37850c7d90d76a0fadd99dc217ed6db"
      "date" => null
      "last_updated" => null
      "snippet" => ""
    ]
  ]
  "object" => "chat.completion"
  "choices" => array:1 [
    0 => array:4 [
      "index" => 0
      "finish_reason" => "stop"
      "message" => array:2 [
        "role" => "assistant"
        "content" => """
          The search results provided do not contain relevant information about the best French cheese of the first quarter-century of the 21st century.\n
          \n
          Based on general knowledge, determining the "best" French cheese of this period is subjective and depends on criteria such as taste, popularity, awards, and expert opinions. However, some French cheeses have gained international acclaim and continued to be highly regarded in the early 21st century, including:\n
          \n
          - **Comté**: A firm cheese from the Jura region, often praised for its complex nutty and fruity flavors. It has won many awards and is considered one of France’s finest cheeses.\n
          - **Roquefort**: A famous blue cheese made from sheep's milk, known for its strong flavor and creamy texture.\n
          - **Brie de Meaux**: A soft cheese with a rich, buttery taste, often called the "king of cheeses."\n
          - **Époisses**: A washed-rind cheese with a powerful aroma and creamy interior, highly regarded by cheese connoisseurs.\n
          \n
          Cheese competitions such as the World Cheese Awards and guides like the "Guide des Meilleurs Fromages de France" often highlight these cheeses.\n
          \n
          If you are looking for a specific award-winning cheese or expert ranking from the early 21st century, specialized cheese competitions and gastronomic guides would provide the most authoritative information.
          """
      ]
      "delta" => array:2 [
        "role" => "assistant"
        "content" => ""
      ]
    ]
  ]

@welcoMattic welcoMattic force-pushed the perplexity branch 5 times, most recently from c4af78a to fe54779 Compare September 2, 2025 08:44
@welcoMattic welcoMattic force-pushed the perplexity branch 2 times, most recently from bac56dc to 0595bc0 Compare September 5, 2025 13:23
Copy link
Contributor

@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but we are lacking tests

@chr-hertel
Copy link
Member

From a functional point of view this looks good:
image

After addressing Oskar's comments we're good to merge here - finally Perplexity - thanks already @welcoMattic!

@welcoMattic
Copy link
Member Author

@OskarStark @chr-hertel comments addressed, tests added, ready for a final review and merge!

@OskarStark
Copy link
Contributor

Just some minor, afterwards good to merge

@welcoMattic welcoMattic force-pushed the perplexity branch 2 times, most recently from cc7f142 to f431dcc Compare September 11, 2025 12:25
@OskarStark
Copy link
Contributor

Thanks Mathieu for working on this feature, this is much appreciated.

@OskarStark OskarStark merged commit ff08204 into symfony:main Sep 11, 2025
12 checks passed
@welcoMattic welcoMattic deleted the perplexity branch September 11, 2025 13:40
chr-hertel added a commit that referenced this pull request Sep 26, 2025
This PR was merged into the main branch.

Discussion
----------

[Platform] Remove unnecessary import aliases

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| Docs?         | no
| Issues        |
| License       | MIT

Follows #394 & #388

Commits
-------

b5033cd Remove unnecessary import aliases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature Platform Issues & PRs about the AI Platform component Status: Needs Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants