Files
crm.clientright.ru/ailist.php
Fedor ac7467f0b4 Major CRM updates: AI Assistant, Court Status API, S3 integration improvements, and extensive file storage system
- Added comprehensive AI Assistant system (aiassist/ directory):
  * Vector search and embedding capabilities
  * Typebot proxy integration
  * Elastic search functionality
  * Message classification and chat history
  * MCP proxy for external integrations

- Implemented Court Status API (GetCourtStatus.php):
  * Real-time court document status checking
  * Integration with external court systems
  * Comprehensive error handling and logging

- Enhanced S3 integration:
  * Improved file backup system with metadata
  * Batch processing capabilities
  * Enhanced error logging and recovery
  * Copy operations with URL fixing

- Added Telegram contact creation API
- Improved error logging across all modules
- Enhanced callback system for AI responses
- Extensive backup file storage with timestamps
- Updated documentation and README files

- File storage improvements:
  * Thousands of backup files with proper metadata
  * Fix operations for broken file references
  * Project-specific backup and recovery systems
  * Comprehensive file integrity checking

Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
2025-10-16 11:17:21 +03:00

98 lines
3.4 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// 🔹 Настройки OpenAI API
const OPENAI_API_KEY = 'sk-GS24OxHQYfq8ErW5CRLoN5F1CfJPxNsY'; // Укажи API-ключ
const OPENAI_ASSISTANT_API = 'https://api.proxyapi.ru/openai/v1/assistants';
const OPENAI_FILES_API = 'https://api.proxyapi.ru/openai/v1/files';
const LOG_FILE = 'logs/assistants.log'; // Файл логов
// 🔹 Функция логирования
function logMessage($message) {
file_put_contents(LOG_FILE, date('Y-m-d H:i:s') . " - " . $message . "\n", FILE_APPEND | LOCK_EX);
}
// 🔹 1⃣ Получение списка ассистентов
function listAssistants() {
logMessage("Запрос списка ассистентов...");
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => OPENAI_ASSISTANT_API,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer ' . OPENAI_API_KEY,
'OpenAI-Beta: assistants=v2'
]
]);
$response = curl_exec($curl);
curl_close($curl);
return json_decode($response, true)['data'] ?? [];
}
// 🔹 2⃣ Получение списка загруженных файлов
function listFilesForAssistant() {
logMessage("Запрос списка загруженных файлов...");
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => OPENAI_FILES_API,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer ' . OPENAI_API_KEY,
'OpenAI-Beta: assistants=v2'
]
]);
$response = curl_exec($curl);
curl_close($curl);
return json_decode($response, true)['data'] ?? [];
}
// 🔹 3⃣ Основной скрипт
logMessage("Запуск скрипта...");
$assistants = listAssistants();
$files = listFilesForAssistant();
$fileMap = [];
foreach ($files as $file) {
$fileMap[$file['id']] = $file['filename'] ?? 'Неизвестное имя';
}
if (!empty($assistants)) {
logMessage("Ассистенты получены. Вывод данных...");
foreach ($assistants as $assistant) {
echo "🆔 ID: " . $assistant['id'] . "\n";
echo "📌 Имя: " . $assistant['name'] . "\n";
echo "💡 Модель: " . $assistant['model'] . "\n";
echo "📖 Инструкции:\n" . $assistant['instructions'] . "\n";
echo "🕒 Создан: " . date('Y-m-d H:i:s', $assistant['created_at']) . "\n";
// 🔹 Выводим файлы, загруженные в ассистента
$fileList = [];
foreach ($assistant['tools'] ?? [] as $tool) {
if ($tool['type'] === 'file_search') {
foreach ($tool['file_ids'] ?? [] as $fileId) {
$fileList[] = $fileMap[$fileId] ?? "Неизвестный файл ($fileId)";
}
}
}
echo "📂 Файлы: " . (!empty($fileList) ? implode(", ", $fileList) : "Нет загруженных файлов") . "\n";
echo "----------------------------------\n";
}
} else {
logMessage("❌ Ошибка: список ассистентов пуст.");
echo "❌ Ошибка: список ассистентов пуст.\n";
}
logMessage("Завершение работы скрипта.");
?>