Git Product home page Git Product logo

bard-sdk-php's Introduction

PHP SDK/API for Google Bard (experiment version) (unofficial)

Downloads Latest Stable Version PHP Version Require License composer.lock available workflows CI

Reverse engineering of Google's Bard chatbot.

Disclamer

  • ApiKeyCookie.php implemented only for easing the access to Google Bard, any legal responsibilities lie with the user.
  • Don't expose your __Secure-1PSID cookie value on the internet.

Install

$ composer require khaledalam/bard-sdk-php

Test

$ composer run test

Auth

  1. Navigate to https://bard.google.com/
  2. Open "Developer Tools" from browser settings or click [F12] shortcut for console.
  3. Go to Application tab => open "Cookies" from left tab => click "https://accounts.google.com" => Copy the value of __Secure-1PSID cookie.

Simple Usage

Change _YOUR_COOKIE_VALUE_

<?php

require_once('./vendor/autoload.php');

use Khaledalam\BardSdkPhp\ApiKey\ApiKeyCookie;
use Khaledalam\BardSdkPhp\Bard;

try {
    // __Secure-1PSID value
    $apiKey = '_YOUR_COOKIE_VALUE_';

    $question = "What is the recent stable version LTS of Ubuntu?";

    $bard = new Bard(new ApiKeyCookie($apiKey));

    $answer = $bard->ask($question);

    print_r($answer['content']);
    /*
    Output (May-2023):
    
    The most recent stable version of Ubuntu LTS is Ubuntu 22.04 LTS, codenamed "Jammy Jellyfish." It was released on April 21, 2022, and will be supported with free security and maintenance updates for five years, until April 2027.

    Ubuntu LTS releases are designed for use in enterprise and server environments, where reliability and stability are critical. They are also a good choice for home users who want a reliable and long-lasting operating system.
    */

} catch (Exception $e)
{
    die("Error: " . $e->getMessage());
}

Output (May-2023):

The most recent stable version of Ubuntu LTS is Ubuntu 22.04 LTS, codenamed "Jammy Jellyfish." It was released on April 21, 2022, and will be supported with free security and maintenance updates for five years, until April 2027.

Ubuntu LTS releases are designed for use in enterprise and server environments, where reliability and stability are critical. They are also a good choice for home users who want a reliable and long-lasting operating system.

Examples

Example1(world_datatime_ai):

php examples/world_datetime_ai/main.php

Example2(docker)

Technical

Diagram

TODOs:

  • Cookie
  • Api key
  • codecov
  • Testing
  • CI GitHub actions

License

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.