Navigating the Search Solution Maze: My Journey to Perplexity AI

Written in

by

Lost in Search

In my quest to refine the search capabilities of my AI applications, I’ve encountered a significant challenge: the GPT API’s limitations in conducting web searches directly. This limitation prompted me to seek alternative solutions to bridge the gap, leading me to experiment with combining the Google Search API with GPT API. My goal was to leverage Google’s vast search database to fetch results and then use GPT to reorder them for better readability and coherence. Despite the theoretical appeal of this approach, the reality fell short of expectations. The integration was cumbersome, and the results, while somewhat improved, still lacked the precision and clarity I aimed for. This experience underscored the need for a more seamless and effective solution.

Finding a Better Solution

Dissatisfied with the makeshift Google-GPT combo, I dedicated my free time to exploring other options. It was during one of these exploratory session that I stumbled upon Perplexity AI. Intrigued by its promise to offer a more intuitive and refined search experience, I decided to dive deeper. Perplexity AI stood out for its unique approach to handling search queries, leveraging advanced natural language processing to understand the context and nuance of user questions. This was a game-changer for me.

Perplexity AI’s output was a revelation—extensive, yet remarkably readable and well-ordered. This was in sharp contrast to the often disorganised and overwhelming results produced by the Google API. Where the latter required significant effort to sift through and extract value, Perplexity AI presented information in a manner that was both accessible and engaging. The responses felt tailored to the query, shedding light on the subject matter with clarity and precision. Its sophisticated algorithm isn’t just adept at general web searches; it excels in extracting content from social networks, including the professional landscapes of LinkedIn. This capability is not a minor improvement but a leap forward, offering a seamless bridge to the rich, dynamic content shared across professional networks.

Deepening Exploration: A Closer Look at Perplexity’s API

As I venture further into the capabilities of Perplexity.AI, my commitment to refining the search functionalities of my AI applications leads me into a phase of deeper exploration and study of Perplexity’s API. By dissecting how the API processes and interprets user questions, I can better tailor my applications to leverage these strengths, thereby enhancing the overall search experience. The API’s flexibility in adjusting to specific search requirements opens up avenues for optimising how search results are retrieved, processed, and presented.

Getting Started with Perplexity AI: Registration and Costs Overview

To start using Perplexity AI, users must register a credit card but won’t be charged immediately. They receive $5 in free credits monthly and can purchase additional credits for API access. An API key is generated upon credit purchase, used as a bearer token for authorization in requests. The “Automatic Top Up” feature ensures uninterrupted service by automatically purchasing credits when running low. For more details, please visit the Getting Started with pplx-api page.

For online models, there’s no charge for input tokens. Costs are incurred per thousand requests at a flat rate of $5, plus fees for output tokens. The “sonar-small-online” model costs $0.28 per million output tokens, and the “sonar-medium-online” model is $1.80 per million output tokens, both in addition to the $5 per thousand requests fee.

Self-Search with a Twist: My LinkedIn via API

What could be more testing than using the Perplexity API to search for myself on LinkedIn as my first Perplexity API attempt?
To create the app for searching myself on LinkedIn, I utilized Python, integrating the Perplexity API for its advanced search capabilities. This approach involved setting up the API with the necessary credentials, crafting a query specific to my LinkedIn profile, and processing the search results through Python code. The app aims to leverage Perplexity API’s nuanced understanding of natural language, ensuring a focused and relevant exploration of my professional presence on LinkedIn.

Here the code:

from openai import OpenAI

YOUR_API_KEY = "my-api-key-here"

messages = [
    {
        "role": "system",
        "content": (
            "You are an artificial intelligence assistant and you need to "
            "find professional infomation in Linkedin."
        ),
    },
    {
        "role": "user",
        "content": (
            "Who is Nicola Lazzari?"
        ),
    },
]

client = OpenAI(api_key=YOUR_API_KEY, base_url="https://api.perplexity.ai")

# chat completion without streaming
response = client.chat.completions.create(
    model="sonar-small-online",
    messages=messages,
)
print(response)

And here the result:

ChatCompletion(id='59546565-36b0-40f8-bfba-d9f5f98617b4', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content="Nicola Lazzari is a Senior Creative Technologist and AI specialist who is primarily based in London, United Kingdom, but maintains connections to both Milan in Italy and Lucca as well. Throughout his more than two-decade career, he has worked across various technology fields, starting as a freelancer specializing in SEO and brand packaging before transitioning into senior email design and development roles. He is recognised for his expertise in UI/UX design, web development, and AI-powered solutions such as Generative AI, which includes using a custom-configured version of OpenAI's GPT-4 for interactions related to his areas of interest. Lazzari creates tools and systems utilizing advanced technology, including an AI-generated FAQ system, a multilingual translation application employing sophisticated machine learning models, and a unique chatbot tailored to his domain knowledge, questions often pertaining to AI and technology exploration.", role='assistant', function_call=None, tool_calls=None), delta={'role': 'assistant', 'content': ''})], created=3538029, model='sonar-small-online', object='chat.completion', system_fingerprint=None, usage=CompletionUsage(completion_tokens=193, prompt_tokens=57, total_tokens=250))

The results from my app, as you can see, are impressively aligned with reality, edging on flatteringly precise. It seems the Perplexity API has a knack for capturing the essence of my LinkedIn profile with an accuracy that’s both gratifying and a tad generous 🙂 .

Note: For this specific exploration, the “sonar-small-online” model was utilised to conduct the online search, demonstrating its effective application in achieving accurate and relevant search results.

Conclusion

The exploration into Perplexity AI’s search capabilities reveals a high level of accuracy that often mirrors reality closely. This precision in retrieving and presenting information showcases the API’s advanced understanding and processing of queries, making it a valuable tool for a wide range of applications. Its consistent performance reinforces the potential of using sophisticated AI in enhancing search experiences, offering promising prospects for both developers and users seeking reliable and nuanced insights.

Leave a Reply

Your email address will not be published. Required fields are marked *