定制 edgaras/azurellm 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

edgaras/azurellm

最新稳定版本:v1.4.1

Composer 安装命令:

composer require edgaras/azurellm

包简介

PHP package for integrating and interacting with deployed Azure LLM models

README 文档

README

PHP package for integrating and interacting with deployed Azure LLM models.

🚀 Changelog (v1.4.1)

New Features

  • Added DeepSeek model support.

📌 Documentation

Features

  • Simplifies managing Azure OpenAI API settings such as API keys, endpoints, deployments, and API versions.
  • Full support for Agents, Threads, and Vector Stores.
  • Integrated Azure AI Search functionalities.

Requirements

  • PHP 8.1+
  • Composer

Installation

  1. Use the library via Composer:
composer require edgaras/azurellm
  1. Include the Composer autoloader:
require __DIR__ . '/vendor/autoload.php';

Usage

1. Initialization

Set up your Azure OpenAI configuration:

use Edgaras\AzureLLM\LLM;

$config = new LLM([
    'apiKey' => '<YOUR-API-KEY>',
    'endpoint' => 'https://<DEPLOYMENT>.openai.azure.com',
    'deployment' => '<MODEL-DEPLOYMENT-ID>',
    'apiVersion' => '<API-VERSION>'
]); 
 

2. Basic usage

Send requests to your Azure OpenAI deployment:

use Edgaras\AzureLLM\LLM;
use Edgaras\AzureLLM\AzureOpenAI;

$config = new LLM([
    'apiKey' => '<YOUR-API-KEY>',
    'endpoint' => 'https://<DEPLOYMENT>.openai.azure.com',
    'deployment' => '<MODEL-DEPLOYMENT-ID>',
    'apiVersion' => '<API-VERSION>'
]); 

$azureLLM = new AzureOpenAI($config);

$inputMessages = [
    ['role' => 'system', 'content' => 'You are a helpful assistant.'],
    ['role' => 'user', 'content' => 'What is the capital of Lithuania?']
];

$options = [
    "temperature" => 0.7,
    "top_p" => 0.95,
    "max_tokens" => 150 
];

$response = $azureLLM->chatCompletions($inputMessages, $options);

3. Use with Azure AI Search

Combine the Azure OpenAI service with Azure Search for contextual completions:

use Edgaras\AzureLLM\LLM;
use Edgaras\AzureLLM\AzureOpenAI;

$config = new LLM([
    'apiKey' => '<YOUR-API-KEY>',
    'endpoint' => 'https://<DEPLOYMENT>.openai.azure.com',
    'deployment' => '<MODEL-DEPLOYMENT-ID>',
    'apiVersion' => '<API-VERSION>'
]); 

$azureLLM = new AzureOpenAI($config);

$inputMessages = [
    ['role' => 'system', 'content' => 'You are a helpful assistant.'],
    ['role' => 'user', 'content' => 'Summarize your knowledgebase']
];

$options = [
    "temperature" => 0.7,
    "top_p" => 0.95,
    "max_tokens" => 150 
];

$data_sources = [[
    "type" => "azure_search",
    "parameters" => [
        "filter" => null,
        "endpoint" => 'https://<SEARCH-DEPLOYMENT>.search.windows.net',
        "index_name" => '<SEARCH-INDEX-NAME>',
        "authentication" => [
            "type" => "api_key",
            "key" => '<SEARCH-API-KEY>'
        ],
    ],
]];

$response = $azureLLM->chatCompletions($inputMessages, $options, $data_sources);

4. Initialize AI Search Configuration

use Edgaras\AzureLLM\AISearch\Auth;

$config = new Auth([
    'apiKey' => '<YOUR-API-KEY>',
    'endpoint' => 'https://<YOUR-SEARCH-SERVICE>.search.windows.net',
    'apiVersion' => '2023-07-01-Preview'
]); 

5. Manage AI Search Indexes

use Edgaras\AzureLLM\AISearch\Index;

$indexService = new Index($config);

// Define Index Fields
$fields = [
    ['name' => 'id', 'type' => 'Edm.String', 'key' => true],
    ['name' => 'content', 'type' => 'Edm.String', 'searchable' => true, 'retrievable' => true]
];

// Create Index
$indexService->createIndex('test-index', $fields);

// List all indexes
$indexes = $indexService->listIndexes();
print_r($indexes);

6. Manage AI Search Indexers

use Edgaras\AzureLLM\AISearch\Indexer;

$indexerService = new Indexer($config);

// Define Indexer
$indexerConfig = [
    'dataSourceName' => 'test-data-source',
    'targetIndexName' => 'test-index',
    'schedule' => ['interval' => 'P1D']
];

// Create Indexer
$indexerService->createIndexer('test-indexer', $indexerConfig);

// Run Indexer Manually
$indexerService->runIndexer('test-indexer');

7. Manage AI Search Data Sources

use Edgaras\AzureLLM\AISearch\DataSource;

$dataSourceService = new DataSource($config);

// Define Data Source Configuration
$dataSourceConfig = [
    'type' => 'azureblob',
    'credentials' => ['connectionString' => '<YOUR-STORAGE-CONNECTION-STRING>'],
    'container' => ['name' => 'your-container']
];

// Create Data Source
$dataSourceService->createDataSource('test-data-source', $dataSourceConfig);

Full AI Search Docs

8. Agents & Threads

use Edgaras\AzureLLM\LLM; 
use Edgaras\AzureLLM\Agents\Agent;
use Edgaras\AzureLLM\Agents\Thread;

// Initialize
$config = new LLM([
    'apiKey' => '<API-KEY>',
    'endpoint' => 'https://<DEPLOYMENT-NAME>.openai.azure.com',
    'deployment' => '<MODEL>',
    'apiVersion' => '2024-05-01-preview'
]);

$agent = new Agent($config);
$thread = new Thread($config);

// Create an Agent
$agentResponse = $agent->createAgent("SupportBot", "Assist users with support queries.");
$agentId = $agentResponse['id'];

// Start a conversation thread
$threadResponse = $thread->createThread();
$threadId = $threadResponse['id'];

// Send a message
$thread->addMessageToThread($threadId, "user", "How do I reset my password?");

// Run the AI Assistant on the thread
$thread->runThread($threadId, $agentId);

Full AI Agents Docs

9. Basic usage (DeepSeek)

Send requests to your DeepSeek deployment:

use Edgaras\AzureLLM\LLM;
use Edgaras\AzureLLM\DeepSeek;

$config = new LLM([
    'apiKey' => '<YOUR-API-KEY>',
    'endpoint' => 'https://<DEPLOYMENT>.services.ai.azure.com',
    'deployment' => '<MODEL-DEPLOYMENT-ID>',
    'apiVersion' => '<API-VERSION>'
]); 

$deepSeek = new DeepSeek($config);

$inputMessages = [
    ['role' => 'system', 'content' => 'You are a helpful assistant.'],
    ['role' => 'user', 'content' => 'What is the capital of Lithuania?']
];

$options = [
    "temperature" => 0.7,
    "top_p" => 0.95,
    "max_tokens" => 150 
];

$response = $deepSeek->chatCompletions($inputMessages, $options);

Useful links

edgaras/azurellm 适用场景与选型建议

edgaras/azurellm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 52 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「azure」 「ai」 「openai」 「gpt」 「llm」 「deepseek」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 edgaras/azurellm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 edgaras/azurellm 我们能提供哪些服务?
定制开发 / 二次开发

基于 edgaras/azurellm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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