adachsoft/internet-search-perplexity 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

adachsoft/internet-search-perplexity

最新稳定版本:v0.1.0

Composer 安装命令:

composer require adachsoft/internet-search-perplexity

包简介

Perplexity internet search client implementation for adachsoft/internet-search-contract.

README 文档

README

Perplexity internet search client implementation for the adachsoft/internet-search-contract.

This library provides a thin adapter around the Perplexity AI HTTP API using Guzzle and exposes it via the shared InternetSearchClientInterface.

Requirements

  • PHP 8.3 or higher
  • adachsoft/internet-search-contract
  • guzzlehttp/guzzle 7.10.0

Installation

composer require adachsoft/internet-search-perplexity

This will also install adachsoft/internet-search-contract and guzzlehttp/guzzle as required dependencies.

Usage

<?php

declare(strict_types=1);

use AdachSoft\InternetSearchContract\InternetSearchClientInterface;
use AdachSoft\InternetSearchPerplexity\Adapter\GuzzleHttpClientAdapter;
use AdachSoft\InternetSearchPerplexity\InternetSearchApiClient;
use GuzzleHttp\Client as GuzzleClient;

$guzzleClient = new GuzzleClient();
$httpAdapter = new GuzzleHttpClientAdapter($guzzleClient);

$apiKey = getenv('PERPLEXITY_KEY') ?: '';

/** @var InternetSearchClientInterface $client */
$client = new InternetSearchApiClient($httpAdapter, $apiKey, 'sonar');

$result = $client->search('What is the capital of France?');

echo $result . PHP_EOL;

Custom options

The search() method accepts an optional second argument with options:

  • model (string) c�b4 Perplexity model name (e.g. sonar, sonar-pro).
  • system_prompt (string) c�b4 custom system message to control the answer style.

Example:

$result = $client->search('Explain quantum computing in simple terms', [
    'model' => 'sonar-pro',
    'system_prompt' => 'You are a programming expert. Provide technical but concise answers.',
]);

Testing

This library ships with a full PHPUnit test suite:

  • unit tests for the HTTP adapter and exception classes,
  • unit tests for the Perplexity API client,
  • an optional production test that can call the real Perplexity API when PERPLEXITY_KEY is set.

Run tests with:

composer test

(Or directly via vendor/bin/phpunit if you prefer.)

Code style and static analysis

The project uses adachsoft/php-code-style as a shared configuration for:

  • PHP-CS-Fixer,
  • PHPStan,
  • Rector.

You can run the tools using your local Composer scripts, for example:

composer cs:check
composer cs:fix
composer stan
composer rector

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固