承接 mateffy/huggingface 相关项目开发

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

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

mateffy/huggingface

最新稳定版本:1.0.5

Composer 安装命令:

composer require mateffy/huggingface

包简介

An unofficial Huggingface Inference API client for PHP

README 文档

README

A PHP SDK to interact with the HuggingFace API using just a few lines of code.

🧑‍💻 Step 1: Installation

composer require mateffy/huggingface

🚀 Step 2: Usage

use Mateffy\HuggingFace;

$token = 'API_TOKEN';

$client = new HuggingFace($token);

$emotions = $client->run(
    model: 'j-hartmann/emotion-english-distilroberta-base',
    input: 'I am happy',
);
/* -> [['label' => 'happy', 'score' => 0.9999], ...] */



/*
 * Shorthand version:
 */

$emotions = HuggingFace::inference(
    token: $token,
    model: 'j-hartmann/emotion-english-distilroberta-base',
    /* Passing a single input will make the response also be a single value */
    input: 'I am happy',
);
/* -> [['label' => 'happy', 'score' => 0.9999], ...] */


/* 
 * or with multiple inputs
 */

$result = $client->run(
    model: 'j-hartmann/emotion-english-distilroberta-base',
    /* Multiple inputs will return an array of results */
    inputs: [
        'I am happy',
        'I am sad',
    ]
);
/*
 * -> [
 *      [['label' => 'happy', 'score' => 0.9999], ...]],
 *      [['label' => 'sad', 'score' => 0.9999], ...]],
 * ]
 */

Changelog

1.0.5

  • feat: better error handling

1.0.4

  • feat: better API for single/multiple inputs

1.0.3

  • fix: added response data as return value

1.0.2

  • fix: added autoload to composer.json

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-25