Giter Site home page Giter Site logo

adityadees / laravel-google-bard Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 2.0 26 KB

A Laravel Package for Google Bard AI Chatbot

Home Page: https://packagist.org/packages/adityadees/laravel-google-bard

License: MIT License

PHP 100.00%
bard chatbot google-bard googlebard laravel

laravel-google-bard's Introduction

laravel-bard

A Laravel Package for Google Bard AI Chatbot

INSTALATION

  • composer require adityadees/laravel-google-bard
  • php artisan vendor:publish --tag=laravel-bard
  • New file laravel-bard.php will created under config folder
  • Fill the bard_token with your token

BARD TOKEN

Visit https://bard.google.com/ Go to Developer tools or press F12 Application → Cookies → Copy the value of __Secure-1PSID cookie.

image

RUN

$bard = (new LaravelBard())->get_answer('type_your_text_here');

# to get the reply just access this array
$bard["content"];

# you can access others array like this
$bard["conversation_id"];
$bard["response_id"];
$bard["factualityQueries"];
$bard["textQuery"];
$bard["choices"];

Example

$bard = (new LaravelBard())->get_answer('hello whats your name');
dd($bard["content"]);
image

Feel free to help improve this package

Note: The package contain resources from repository https://github.com/dsdanielpark/Bard-API

laravel-google-bard's People

Contributors

adityadees avatar giorgibaghashvili avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

juzepe xwiz

laravel-google-bard's Issues

SNlM0e value not found in response. Check __Secure-1PSID value.

Hello.
First of all, it is a very interesting project.

I have taken the bard's cockie I can do it as in your explanation but I get this. I am in local development.
And I don't understand why it fails me. Also I have created BARD_TOKEN in env.

thank you
'bard_token' => env('BARD_TOKEN', 'YQi-AJS0hL5mzOyzUgoCodbqRIIQlzUq2J5jdEMO4TgDkoFJktYhVYt_NOTREALTOKEN.'),

Cant Retrieve data

Got this error on my View

"""
Response Error: )]}'

38
[["wrb.fr",null,null,null,null,[9]]]
56
[["di",122],["af.httprm",122,"6907126464418719828",0]]
25
[["e",4,null,null,131]]
.
""" // app/Http/Controllers/BardController.php:14

.env
BARD_TOKEN=My __Secure-1PSID

Controller


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use AdityaDees\LaravelBard\LaravelBard; // Corrected Namespace

class BardController extends Controller
{
    public function index()
    {
        $bard = (new LaravelBard())->get_answer('what is your name');
        dd($bard["content"]);
        // $response = $bard["content"];
        // return view('bard', ['response' => $response]);
    }
}```

Class "LaravelBard" not found

Hi

I tried setting up your Bard package but it fails with the eror "Class "LaravelBard" not found"
i've tried importing it via

use LaravelBard;
or
use Bard;

but those aren't right :)
Here's my controller
*<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
//use LaravelBard;

class testController extends Controller
{
public function __invoke()
{
dump('test');

	$bard = (new LaravelBard())->get_answer('hoe laat is het');
	dd($bard);
	
	
	# to get the reply just access this array
	$bard["content"];

	# you can access others array like this
	$bard["conversation_id"];
	$bard["response_id"];
	$bard["factualityQueries"];
	$bard["textQuery"];
	$bard["choices"];
}

}`**

Please advice

Class "LaravelBard" not found

Hi thanks for the package, I tried: use AdityaDees\LaravelBard; and a few others but can't get it to work, maybe it would be cool to put it in the readme

Thanks

Trying to access array offset on value of type null

Hi,

I get the following error when I run a very simple get_answer() function:

ErrorException

 Trying to access array offset on value of type null

 at vendor/adityadees/laravel-google-bard/src/LaravelBard.php:135
   131▕             return ["content" => "Response Error: " . $resp . "."];
   132▕         }
   133▕         $parsed_answer = json_decode($resp_dict, true);
   134▕         $bard_answer = [
 ➜ 135▕             "content" => $parsed_answer[0][0],
   136▕             "conversation_id" => $parsed_answer[1][0],
   137▕             "response_id" => $parsed_answer[1][1],
   138▕             "factualityQueries" => $parsed_answer[3],
   139▕             "textQuery" => $parsed_answer[2][0] ?? "",

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.