SimpleClients is a collection of simple PHP clients for connecting to various third-party services that are frequently used across multiple projects. It leverages the DevElation library (bluefission/develation
) to utilize as many custom classes, methods, and patterns from that library as possible. The main purpose of SimpleClients is to provide common connectors to the custom framework Blue Fission Opus (bluefission/opus
) and the PHP-based Workspace Intelligence Shell Environment (WISE) (bluefission/wise
) without having repeated code or having to maintain the connectors within the respective projects. However, these connectors are generic enough to be used anywhere.
SimpleClients currently offers connectors to the following services:
- DuckDuckGo Search
- Google Search
- IP API Geo Location
- Hugging Face
- MurfAI
- OpenAI
- Open Weather
- Trello
- WikiHow
- Wikipedia
- Wiki News
To install SimpleClients, use Composer:
composer require bluefission/simpleclients
Each service client is implemented as a class under the BlueFission\SimpleClients
namespace. Below are some examples of how to use these clients.
<?php
require 'vendor/autoload.php';
use BlueFission\SimpleClients\WikipediaClient;
$wikipedia = new WikipediaClient();
$summary = $wikipedia->getSummary('Artificial Intelligence');
echo $summary;
<?php
require 'vendor/autoload.php';
use BlueFission\SimpleClients\WikiHowClient;
$wikihow = new WikiHowClient();
$results = $wikihow->search('How to make coffee');
print_r($results);
<?php
require 'vendor/autoload.php';
use BlueFission\SimpleClients\OpenAIClient;
$openai = new OpenAIClient();
$response = $openai->complete('What is the capital of France?');
print_r($response);
Below is a brief overview of more clients and their methods.
getSummary(string $topic): string
- Retrieves the summary of a given topic from Wikipedia.
search(string $query): array
- Searches for articles on WikiHow based on the given query.
extractRating($searchResult): float
- Extracts the rating from a search result.
getSteps(string $url): array
- Retrieves the steps from a WikiHow article.
getStepsAsString(string $url): string
- Retrieves the steps from a WikiHow article as a formatted string.
generate($input, $config = [], callable $callback = null)
- Generates a response from OpenAI based on the input.
complete(string $input, $config = []): array
- Retrieves GPT-3 completion based on the input.
chat(string $input, $config = []): array
- Retrieves GPT-3.5 chat completion based on the input.
image(string $prompt, string $width = '256', string $height = '256'): array
- Retrieves an image generated by OpenAI based on the prompt.
embeddings(string $input): array
- Retrieves embeddings from the Ada model based on the input.
search(string $query): array
- Searches Google using the Custom Search JSON API.
search(string $query): array
- Searches DuckDuckGo and retrieves results.
Contributions are welcome! Please feel free to submit a pull request or open an issue to discuss what you would like to change.
This project is licensed under the MIT License.