承接 adachsoft/embedding-openai 相关项目开发

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

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

adachsoft/embedding-openai

最新稳定版本:v0.1.0

Composer 安装命令:

composer require adachsoft/embedding-openai

包简介

OpenAI Embeddings provider implementation for adachsoft/embedding-contracts.

README 文档

README

Provider-specific implementation of adachsoft/embedding-contracts for the OpenAI Embeddings API.

This library provides a production-ready implementation of EmbedderInterface that talks to the official OpenAI HTTP API using Guzzle and exposes a simple, DTO-based contract for generating text embeddings.

Installation

composer require adachsoft/embedding-openai

This will also install adachsoft/embedding-contracts and guzzlehttp/guzzle as dependencies.

Usage

<?php declare(strict_types=1);

use AdachSoft\EmbeddingContracts\Dto\EmbeddingRequestDto;
use AdachSoft\EmbeddingContracts\Enum\EmbeddingEncodingFormatEnum;
use AdachSoft\EmbeddingContracts\Enum\EmbeddingInputTypeEnum;
use AdachSoft\EmbeddingOpenai\OpenAiEmbedder;
use GuzzleHttp\Client;

$client = new Client();
$apiKey = $_ENV['OPENAI_API_KEY'] ?? getenv('OPENAI_API_KEY');

$embedder = new OpenAiEmbedder($client, (string) $apiKey);

$request = new EmbeddingRequestDto(
    input: 'hello world',
    model: 'text-embedding-3-small',
    inputType: EmbeddingInputTypeEnum::Query,
    encodingFormat: EmbeddingEncodingFormatEnum::Float,
);

$response = $embedder->embed($request);

// $response->vector now contains the embedding for "hello world".

Testing

The project ships with a production integration test that talks to the real OpenAI API.

To run it, you must provide a valid API key via OPENAI_API_KEY in your environment (or .env file) and then execute:

vendor/bin/phpunit --group production

By default, this production test group is excluded from the regular test suite.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固