Skip to content

Conversation

@charvimehradu
Copy link
Collaborator

@charvimehradu charvimehradu commented Jun 7, 2025

Pull Request for AI Framework Feature.

Summary of Changes

  • Response.php is the foundational file for the AI framework that standardizes how responses are handled across all AI providers.
  • It represents the results of an AI operation and will hold all the data returned from AI providers.
  • Each AI provider creates a response object using constructor and users interact with the response objects using methods.
  • __get() method allows property-style access ($response->content).

09 June 2025

  • ProviderInterface.php: All AI providers must implement these methods.
  • AbstractProvider.php: All providers share this code. It contains shared functionalities for all providers.

11 June 2025

  • 'OpenAIProvider.php': Implementing OpenAIProvider core functionality
  • The Tests folder contains basic php tests.

Testing Instructions

Documentation Changes Required

@charvimehradu charvimehradu changed the title Response.php and README.md file AI Framework Foundation Jun 10, 2025
/**
* Part of the Joomla Framework AI Package
*
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the headers Joomla is using

Copy link
Collaborator Author

@charvimehradu charvimehradu Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed them with commit#4. Please check. I am not sure what should be the copyright for 2025, could you please confirm and I will update it in my next commit

*/
protected function validateResponse($response): bool
{
if ($response->code !== 200) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is only a 200 a valid response?

@charvimehradu
Copy link
Collaborator Author

charvimehradu commented Jun 11, 2025

With the latest commit, the following changes have been made:

  • Changed file headers to follow Joomla standards - Updated copyright notices and licensing information to match Joomla Framework conventions.
  • Implemented OpenAIProvider core functionality - OpenAI provider implementation with default endpoint v1/chat/completions and default model gpt-4o-mini. Provider support is determined by checking for API key availability in environment variables. The prompt() and ask() methods build request payloads that convert user prompts into OpenAI's expected message format. It also implements determineAIStatusCode() method that maps OpenAI's finish_reason responses to status codes.
  • HTTP errors are handled by AbstractProvider's validateResponse() method, while OpenAI-specific API errors are processed in OpenAIProvider's parseOpenAIResponse() method.
  • composer.json created to handle Http framework dependency and testing purposes.
  • Created three basic tests:
  1. HTTP Integration Test (http_test.php) - Verifies Joomla HttpFactory integration, tests both static and instance method call. Instance method call passes the test.
  2. Response Object Test (response_test.php) - Tests custom Response class creation.
  3. OpenAI API Integration Test (api_test.php) - Tests API connectivity verification.

@charvimehradu charvimehradu requested a review from bembelimen June 12, 2025 17:35
"require": {
"php": "^8.1.0",
"joomla/http": "dev-4.x-dev",
"joomla/filesystem": "~3.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use version 4.x now for both (they're released)

@charvimehradu charvimehradu merged commit 4ed24fe into main Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants