承接 faiznurullah/gemini-php-unofficial 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

faiznurullah/gemini-php-unofficial

Composer 安装命令:

composer require faiznurullah/gemini-php-unofficial

包简介

package for integrated gemini AI with php projects

README 文档

README

this package is unofficial Gemini written in PHP.

Official documentation

For Documentation please check Gemini docs

Installation

Install this package with composer by following command:

composer require faiznurullah/gemini-php-unofficial

or add manually in your Composer.json file.

Usage

Laravel

on file .env you can add this configuration:

API_KEY_GEMINI = "GEMINI_API_KEY";
GEMINI_DEFAULT_MODEL = "gemini-1.5-flash";
GEMINI_TIMEOUT = 30;

on file config/app.php you can add this configuration.

'providers' => [ 
    Faiznurullah\Gemini\GeminiServiceProvider::class,
],

Native

Initialize some required credentials. You can get credentials on your ai studio google account dashboard.

<?php

require_once __DIR__ . '/vendor/autoload.php';
// API Key
$apikey = 'GEMINI_API_KEY';

Multi model selection

$gemini = new Faiznurullah\Gemini\Gemini($apikey);

// use default model from env/config
$textResponse = $gemini->generateFromText('Jelaskan teori relativitas secara singkat.');

// choose model per request
$proResponse = $gemini->generateFromText('Buat analisa mendalam.', 'gemini-1.5-pro');

Multi file request (image/pdf/dll)

$filesResponse = $gemini->generateFromFiles(
    'Ringkas isi semua berkas ini dalam 5 poin.',
    [
        __DIR__ . '/files/photo.png',
        __DIR__ . '/files/report.pdf',
        __DIR__ . '/files/data.csv',
    ],
    'gemini-1.5-flash'
);

Error handling

use Faiznurullah\Gemini\Exceptions\GeminiException;

try {
    $response = $gemini->generateFromText('Halo Gemini!');
} catch (GeminiException $e) {
    $context = $e->getContext();
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
    if (isset($context['response_body'])) {
        echo 'API response: ' . $context['response_body'] . PHP_EOL;
    }
}

Contributing

For any requests, bugs, or comments, please open an issue.

Installing Packages

Before you start to code, run this command to install all of the required packages. Make sure you have composer installed in your computer.

composer install

I hope you can enjoy and contribute to future development.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固