Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPIB-496: AI Feature integrations. #1

Merged
merged 24 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at https://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.bat]
end_of_line = crlf
31 changes: 31 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* eol=lf
* text=auto

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.gif binary
*.jpeg binary
*.zip binary
*.phar binary
*.ttf binary
*.woff binary
*.woff2 binary
*.eot binary
*.ico binary
*.mo binary
*.pdf binary
*.xsd binary
*.ts binary
*.exe binary

# Remove files for archives generated using `git archive`
dependency.json export-ignore
.coveralls.yml export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
architecture-baseline.json export-ignore
psalm-report.json export-ignore linguist-generated=true
58 changes: 58 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI

on:
push:
branches:
- 'master'
pull_request:
workflow_dispatch:

jobs:
validation:
name: Validation
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, bcmath
coverage: none

- name: Composer Install
run: composer install --prefer-dist --no-interaction --profile

- name: Run validation
run: composer validate

- name: Syntax check
run: find ./src -path src -prune -o -type f -name '*.php' -print0 | xargs -0 -n1 -P4 php -l -n | (! grep -v "No syntax errors detected" )

- name: Run CodeStyle checks
run: composer cs-check

- name: Run PHPStan
run: composer stan

lowest:
name: Prefer Lowest
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, intl, bcmath
coverage: none

- name: Composer Install
run: composer install --prefer-dist --no-interaction --profile

- name: Composer Update
run: composer update --prefer-lowest --prefer-dist --no-interaction --profile -vvv
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# IDEs
/.idea
/.project
/nbproject
/.buildpath
/.settings
*.sublime-*
*.AppleDouble
*.AppleDB
*.AppleDesktop

# built client resources
/src/*/Zed/*/Static/Public
/src/*/Zed/*/Static/Assets/sprite

# propel classes
/src/*/Zed/*/Persistence/Propel/Base/*
/src/*/Zed/*/Persistence/Propel/Map/*

# OS
.DS_Store

# grunt stuff
.grunt
.sass-cache
/node_modules/
/tests/_output/*
!/tests/_output/.gitkeep
vendor
composer.lock
4 changes: 4 additions & 0 deletions .license
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# OpenAi Changelog

[Release Changelog](https://github.com/spryker-eco/open-ai/releases)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)
dmiseev marked this conversation as resolved.
Show resolved Hide resolved

Copyright (c) 2016-present Spryker Systems GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# OpenAi Module

OpenAi module provides integration with OpenAI API.

## Installation

```
composer require spryker-eco/open-ai
```
1 change: 1 addition & 0 deletions architecture-baseline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
40 changes: 40 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "spryker-eco/open-ai",
"type": "library",
"description": "OpenAi module",
"license": "MIT",
"require": {
"openai-php/client": "^0.8.4",
"php": ">=8.1",
"spryker/kernel": "^3.33.0",
"spryker/transfer": "^3.27.0"
},
"require-dev": {
"phpstan/phpstan": "*",
"spryker/code-sniffer": "*"
},
"autoload": {
"psr-4": {
"SprykerEco\\": "src/SprykerEco/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"cs-check": "phpcs -p -s --standard=vendor/spryker/code-sniffer/SprykerStrict/ruleset.xml src/",
"cs-fix": "phpcbf -p --standard=vendor/spryker/code-sniffer/SprykerStrict/ruleset.xml src/",
"stan": "phpstan analyse -c phpstan.neon -l 8 src/"
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"php-http/discovery": false
}
}
}
5 changes: 5 additions & 0 deletions dependency.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"include": {
"spryker/transfer": "Provides transfer objects definition with strict types."
}
}
9 changes: 9 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
parameters:
level: 8
paths:
- src/
ignoreErrors:
- '#Call to method .+ on an unknown class .+Transfer#'
- '#Instantiated class .+Transfer not found#'
- '#Method .+ has invalid return type .+Transfer#'
- '#Parameter .+Transfer of method .+ has invalid type .+Transfer.#'
5 changes: 5 additions & 0 deletions psalm-report.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace SprykerEco\Client\OpenAi\Dependency\External;

use OpenAI;
use OpenAI\Client;

class OpenAiToOpenAiPhpClientAdapter implements OpenAiToOpenAiPhpClientInterface
{
/**
* @param string $apiKey
* @param string|null $organization
*
* @return \OpenAI\Client
*/
public function createOpenAiClient(string $apiKey, ?string $organization = null): Client
{
return OpenAi::client($apiKey, $organization);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace SprykerEco\Client\OpenAi\Dependency\External;

use OpenAI\Client;

interface OpenAiToOpenAiPhpClientInterface
{
/**
* @param string $apiKey
* @param string|null $organization
*
* @return \OpenAI\Client
*/
public function createOpenAiClient(string $apiKey, ?string $organization = null): Client;
}
Loading
Loading