承接 intelligent-intern/openai-bundle 相关项目开发

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

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

intelligent-intern/openai-bundle

最新稳定版本:1.0.0

Composer 安装命令:

composer require intelligent-intern/openai-bundle

包简介

Symfony bundle for OpenAI integration

README 文档

README

The intelligent-intern/openai-bundle integrates OpenAI with the Intelligent Intern Core Framework, allowing seamless AI functionality for embedding generation.

Installation

Install the bundle using Composer:

composer require intelligent-intern/openai-bundle

Configuration

Ensure the following secret is set in vault:

secret/data/data/openai:
  api_key: your_openai_api_key

To use the bundle, ensure the AI_PROVIDER is set to "openai".

Usage

Once the bundle is installed and configured, the Core framework will dynamically detect the OpenAI service via the ai.strategy tag.

The service will be available via the AIServiceFactory:

<?php

namespace App\Controller;

use App\Service\Api\AIServiceFactory;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;

class EmbeddingController extends AbstractController
{
    public function __construct(
        private AIServiceFactory $aiServiceFactory
    ) {}

    public function generateEmbedding(Request $request): JsonResponse
    {
        $input = $request->get('input', '');

        if (empty($input)) {
            return new JsonResponse(['error' => 'Input cannot be empty'], 400);
        }

        try {
            $aiService = $this->aiServiceFactory->create();
            $embedding = $aiService->generateEmbedding($input);

            return new JsonResponse(['embedding' => $embedding]);
        } catch (\Exception $e) {
            return new JsonResponse(['error' => $e->getMessage()], 500);
        }
    }
}

Extensibility

This bundle is specifically designed to integrate with intelligent-intern/core. It leverages the dynamic service discovery mechanism to ensure seamless compatibility.

If you'd like to add additional strategies, simply create a similar bundle that implements the AIServiceInterface and tag its service with ai.strategy.

For example:

services:
    Your\CustomBundle\Service\CustomAIService:
        tags: ['ai.strategy']

License

This bundle is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

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