feat: add AI API support#270
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #270 +/- ##
============================================
+ Coverage 93.30% 94.11% +0.81%
- Complexity 1840 2036 +196
============================================
Files 169 181 +12
Lines 4969 5515 +546
============================================
+ Hits 4636 5190 +554
+ Misses 333 325 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds first-class support for Crowdin’s new AI API surface (issue #179) by extending both the standard and Enterprise AI API clients with endpoints for AI prompts, providers, reports, fine-tuning, settings, and snippets/custom placeholders, along with corresponding models and test coverage.
Changes:
- Extended
AiApiandEnterprise\AiApiwith new AI endpoints (prompts, completions, fine-tuning datasets/jobs/events, providers/models/chat completions, reports, settings, snippets, and deprecated custom placeholders). - Introduced a set of new AI-related model classes to represent the new API resources.
- Expanded AI API test suites (standard + enterprise) to cover the new endpoints and updated request/response shapes.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/CrowdinApiClient/Api/AiApiTest.php | Adds/updates tests for the expanded (user-scoped) AI API endpoints. |
| tests/CrowdinApiClient/Api/Enterprise/AiApiTest.php | Adds/updates tests for the expanded Enterprise AI API endpoints. |
| src/CrowdinApiClient/Api/AiApi.php | Implements new AI endpoints for the standard API (user-scoped routes). |
| src/CrowdinApiClient/Api/Enterprise/AiApi.php | Implements new AI endpoints for the Enterprise API (org-scoped routes). |
| src/CrowdinApiClient/Model/AiPrompt.php | Adds model for AI Prompts. |
| src/CrowdinApiClient/Model/AiPromptCompletion.php | Adds model for AI Prompt Completions. |
| src/CrowdinApiClient/Model/AiFineTuningDataset.php | Adds model for fine-tuning dataset jobs. |
| src/CrowdinApiClient/Model/AiFineTuningJob.php | Adds model for fine-tuning jobs. |
| src/CrowdinApiClient/Model/AiFineTuningEvent.php | Adds model for fine-tuning job events. |
| src/CrowdinApiClient/Model/AiProvider.php | Adds model for AI Providers. |
| src/CrowdinApiClient/Model/AiProviderModel.php | Adds model for provider models list. |
| src/CrowdinApiClient/Model/AiProxyChatCompletion.php | Adds model wrapper for provider chat completion proxy responses. |
| src/CrowdinApiClient/Model/AiReport.php | Adds model for AI report generation jobs. |
| src/CrowdinApiClient/Model/AiSettings.php | Adds model for AI settings. |
| src/CrowdinApiClient/Model/AiSnippet.php | Adds model for AI snippets. |
| src/CrowdinApiClient/Model/AiCustomPlaceholder.php | Adds deprecated model for custom placeholders (superseded by snippets). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** @var string */ | ||
| protected $message; | ||
|
|
||
| /** @var array|null */ | ||
| protected $metrics; | ||
|
|
||
| /** @var string */ | ||
| protected $createdAt; | ||
|
|
||
| public function __construct(array $data = []) | ||
| { | ||
| parent::__construct($data); | ||
|
|
||
| $this->id = (string)$this->getDataProperty('id'); | ||
| $this->type = (string)$this->getDataProperty('type'); | ||
| $this->message = (string)$this->getDataProperty('message'); | ||
| $this->metrics = $this->getDataProperty('data'); | ||
| $this->createdAt = (string)$this->getDataProperty('createdAt'); | ||
| } |
| public function getMessage(): string | ||
| { | ||
| return $this->message; | ||
| } |
| /** | ||
| * List AI Custom Placeholders | ||
| * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.ai.settings.custom-placeholders.getMany API Documentation | ||
| * @deprecated Use listSnippets instead | ||
| * | ||
| * @param array $params | ||
| * integer $params[limit]<br> | ||
| * integer $params[offset] | ||
| * @return ModelCollection | ||
| */ | ||
| public function listCustomPlaceholders(array $params = []): ModelCollection |
There was a problem hiding this comment.
This method has been deprecated. We don't want to include it in the API Client. The same applies to other deprecated methods.
| /** | ||
| * List AI Prompt Fine-Tuning Job Events | ||
| * @link https://developer.crowdin.com/api/v2/#operation/api.users.ai.prompts.fine-tuning.jobs.events.getMany API Documentation | ||
| * | ||
| * @param int $userId | ||
| * @param int $aiPromptId | ||
| * @param string $jobIdentifier | ||
| * @param array $params | ||
| * integer $params[limit]<br> | ||
| * integer $params[offset] | ||
| * @return ModelCollection | ||
| */ |
There was a problem hiding this comment.
The Fine-Tuning feature is going to be retired soon. Please do not include these methods.
Closes #179