PHP Classes

File: example/index.php

Recommend this page to a friend!
  Classes of Nahid Bin Azhar   Google Generative AI   example/index.php   Download  
File: example/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Google Generative AI
Get answers to prompts using Google Gemini AI
Author: By
Last change:
Date: 3 days ago
Size: 1,225 bytes
 

Contents

Class file image Download
<?php

require_once __DIR__ . '/../vendor/autoload.php';

use
Nahid\GoogleGenerativeAI\GoogleGenAI;
use
Nahid\GoogleGenerativeAI\Prompts\Concerns\Functions\Func;
use
Nahid\GoogleGenerativeAI\Prompts\Concerns\Functions\Parameter;



$client = GoogleGenAI::client(getenv('GEMINI_API_KEY'))
    ->
make();

try {
   
$resp = $client->prompt()
        ->
generate("Best shopify product reviews app");
} catch (
Exception $e) {
   
dd($e->getMessage());
}


//->withAudio('/Users/nahid/Downloads/record.ogg')

dd($resp->getBody()->getContents());

/*->withFunctions(
    Func::create('topSellingProducts', 'List of top selling products')
        ->addParameter(Parameter::create('limit', 'number', 'Limit of products to return', true))
        ->addParameter(Parameter::create('category', 'string', 'Category of products to return', false)),
    Func::create('getProduct', 'Get a product by title')
        ->addParameter(Parameter::create('title', 'string', 'Product title', true)),
    Func::create('offerProducts', 'List of offered products')
        ->addParameter(Parameter::create('percents', 'number', 'Discount percents', true))
        ->addParameter(Parameter::create('limit', 'number', 'Limit of products to return'))
)*/