Coder Social home page Coder Social logo

simpleclients's Introduction

SimpleClients

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.

Features

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

Installation

To install SimpleClients, use Composer:

composer require bluefission/simpleclients

Usage

Each service client is implemented as a class under the BlueFission\SimpleClients namespace. Below are some examples of how to use these clients.

Example: WikipediaClient

<?php

require 'vendor/autoload.php';

use BlueFission\SimpleClients\WikipediaClient;

$wikipedia = new WikipediaClient();
$summary = $wikipedia->getSummary('Artificial Intelligence');

echo $summary;

Example: WikiHowClient

<?php

require 'vendor/autoload.php';

use BlueFission\SimpleClients\WikiHowClient;

$wikihow = new WikiHowClient();
$results = $wikihow->search('How to make coffee');

print_r($results);

Example: OpenAIClient

<?php

require 'vendor/autoload.php';

use BlueFission\SimpleClients\OpenAIClient;

$openai = new OpenAIClient();
$response = $openai->complete('What is the capital of France?');

print_r($response);

Further Examples

Below is a brief overview of more clients and their methods.

WikipediaClient

  • getSummary(string $topic): string
    • Retrieves the summary of a given topic from Wikipedia.

WikiHowClient

  • 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.

OpenAIClient

  • 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.

GoogleSearchClient

  • search(string $query): array
    • Searches Google using the Custom Search JSON API.

DuckDuckGoSearchClient

  • search(string $query): array
    • Searches DuckDuckGo and retrieves results.

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue to discuss what you would like to change.

License

This project is licensed under the MIT License.

simpleclients's People

Contributors

bluefission avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.