-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e7523ce
Showing
27 changed files
with
662 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Formatting | ||
|
||
on: | ||
push: | ||
paths: | ||
- "**.php" | ||
- ".github/workflows/formatting.yml" | ||
|
||
env: | ||
phpv: 8.3 | ||
|
||
jobs: | ||
formatting: | ||
name: Formatting | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ env.phpv }} | ||
coverage: none | ||
|
||
- name: Install composer dependencies | ||
uses: ramsey/composer-install@v3 | ||
|
||
- name: Run Pint | ||
run: | | ||
vendor/bin/pint | ||
git diff --exit-code | ||
- name: Run Rector | ||
run: | | ||
vendor/bin/rector | ||
git diff --exit-code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: PHPStan | ||
|
||
on: | ||
push: | ||
paths: | ||
- "**.php" | ||
- "phpstan.neon.dist" | ||
- ".github/workflows/phpstan.yml" | ||
|
||
env: | ||
phpv: 8.3 | ||
|
||
jobs: | ||
phpstan: | ||
name: phpstan | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ env.phpv }} | ||
coverage: none | ||
|
||
- name: Install composer dependencies | ||
uses: ramsey/composer-install@v3 | ||
|
||
- name: Run PHPStan | ||
run: ./vendor/bin/phpstan --error-format=github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
paths: | ||
- "**.php" | ||
- ".github/workflows/tests.yml" | ||
- "phpunit.xml.dist" | ||
- "composer.json" | ||
- "composer.lock" | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 5 | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ubuntu-latest] | ||
php: [8.3] | ||
laravel: [11.*] | ||
stability: [prefer-lowest, prefer-stable] | ||
include: | ||
- laravel: 11.* | ||
testbench: 9.* | ||
carbon: ^2.63 | ||
|
||
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo | ||
coverage: none | ||
|
||
- name: Setup problem matchers | ||
run: | | ||
echo "::add-matcher::${{ runner.tool_cache }}/php.json" | ||
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | ||
- name: Install dependencies | ||
run: | | ||
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.os == 'windows-latest' && '^^^' || '' }}${{ matrix.carbon }}" --no-interaction --no-update | ||
composer update --${{ matrix.stability }} --prefer-dist --no-interaction | ||
- name: List Installed Dependencies | ||
run: composer show -D | ||
|
||
- name: Execute tests | ||
run: vendor/bin/pest --ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/vendor/ | ||
composer.lock | ||
/build/ | ||
task/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":"pest_2.34.7","defects":[],"times":{"P\\Tests\\MessageTest::__pest_evaluable_it_can_be_created_for_a_each_role#(EchoLabs\\Sparkle\\Enums\\Role Enum (USER, 'user'))":0.001,"P\\Tests\\MessageTest::__pest_evaluable_it_can_be_created_for_a_each_role#(EchoLabs\\Sparkle\\Enums\\Role Enum (SYSTEM, 'system'))":0,"P\\Tests\\MessageTest::__pest_evaluable_it_can_be_created_for_a_each_role#(EchoLabs\\Sparkle\\Enums\\Role Enum (ASSISTANT, 'assistant'))":0}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
![](docs/images/prism-banner.webp) | ||
|
||
# Prism | ||
|
||
Prism makes it easier to work with LLMs by offering a consistent integration | ||
method for your app. This way, you can focus on developing outstanding AI | ||
applications for your users without getting lost in the technical intricacies. | ||
|
||
## Generating Text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# https://taskfile.dev | ||
|
||
version: "3" | ||
|
||
tasks: | ||
setup: | ||
cmds: | ||
- composer install | ||
sources: | ||
- composer.json | ||
- composer.lock | ||
generates: | ||
- vendor/autoload.php | ||
|
||
push: | ||
cmds: | ||
- git remote | xargs -I{} git push {{.CLI_ARGS}} {} | ||
|
||
format: | ||
cmds: | ||
- vendor/bin/rector | ||
- vendor/bin/pint | ||
|
||
validate: | ||
cmds: | ||
- vendor/bin/pest --compact | ||
- vendor/bin/phpstan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
_print() { | ||
printf "\e[38;5;4m%s\e[0m\n" "$1" | ||
} | ||
|
||
main() { | ||
files_before_format=$(git diff --name-only --diff-filter=d) | ||
|
||
_print "Running pint..." | ||
vendor/bin/pint --dirty | ||
|
||
_print "Running rector..." | ||
vendor/bin/rector process --no-diffs | ||
|
||
files_after_format=$(git diff --name-only --diff-filter=d) | ||
|
||
# Find files fixed by pint by comparing file lists before and after pint run | ||
files_fixed_by_format=$(comm -13 <(sort <<<"$files_before_format") <(sort <<<"$files_after_format")) | ||
|
||
# Re-stage files fixed by pint | ||
_print "Re-staging changed files..." | ||
for f in $files_fixed_by_format; do git add "$f"; done || exit | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"name": "echolabs/prism", | ||
"description": "AI", | ||
"type": "library", | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"EchoLabs\\Prism\\": "src/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "TJ Miller", | ||
"email": "hello@echolabs.dev" | ||
} | ||
], | ||
"require": { | ||
"laravel/framework": "^11.0" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"php-http/discovery": true, | ||
"pestphp/pest-plugin": true, | ||
"phpstan/extension-installer": true | ||
} | ||
}, | ||
"require-dev": { | ||
"pestphp/pest": "^2.34", | ||
"laravel/pint": "^1.14", | ||
"phpstan/phpstan": "^1.11", | ||
"pestphp/pest-plugin-arch": "^2.7", | ||
"pestphp/pest-plugin-laravel": "^2.4", | ||
"phpstan/extension-installer": "^1.3", | ||
"phpstan/phpstan-deprecation-rules": "^1.2", | ||
"rector/rector": "^1.1", | ||
"projektgopher/whisky": "^0.7.0" | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Tests\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"post-autoload-dump": [ | ||
"@clear", | ||
"@prepare" | ||
], | ||
"phpstan": [ | ||
"phpstan analyse -c phpstan.neon.dist" | ||
], | ||
"format": [ | ||
"pint", | ||
"rector process --no-diffs" | ||
], | ||
"test": [ | ||
"@php vendor/bin/pest" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
return [ | ||
'providers' => [ | ||
'openai' => [ | ||
'driver' => 'openai', | ||
'url' => env('OPENAI_URL', 'https://api.openai.com/v1'), | ||
'api_key' => env('OPENAI_API_KEY'), | ||
], | ||
'anthropic' => [ | ||
'driver' => 'anthropic', | ||
'api_key' => env('ANTHROPIC_API_KEY'), | ||
'version' => env('ANTHROPIC_API_VERSION', '2023-06-01'), | ||
], | ||
], | ||
]; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
parameters: | ||
level: 8 | ||
paths: | ||
- src | ||
tmpDir: build/phpstan | ||
reportUnmatchedIgnoredErrors: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./app</directory> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
return [ | ||
/* | ||
* This settings controls whether data should be sent to Ray. | ||
*/ | ||
'enable' => $_ENV['RAY_ENABLED'] ?? false, | ||
|
||
/* | ||
* The host used to communicate with the Ray app. | ||
*/ | ||
'host' => 'localhost', | ||
|
||
/* | ||
* The port number used to communicate with the Ray app. | ||
*/ | ||
// 'port' => 23517, | ||
// Buggerator config | ||
'port' => 8000, | ||
|
||
/* | ||
* Absolute base path for your sites or projects in Homestead, Vagrant, Docker, or another remote development server. | ||
*/ | ||
'remote_path' => null, | ||
|
||
/* | ||
* Absolute base path for your sites or projects on your local computer where your IDE or code editor is running on. | ||
*/ | ||
'local_path' => null, | ||
|
||
/* | ||
* When this setting is enabled, the package will not try to format values sent to Ray. | ||
*/ | ||
'always_send_raw_values' => false, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; | ||
use Rector\Config\RectorConfig; | ||
use Rector\Set\ValueObject\LevelSetList; | ||
use Rector\Set\ValueObject\SetList; | ||
|
||
return RectorConfig::configure() | ||
->withParallel() | ||
->withPaths([ | ||
__DIR__.'/src', | ||
__DIR__.'/tests', | ||
]) | ||
->withRules([ | ||
InlineConstructorDefaultToPropertyRector::class, | ||
]) | ||
->withSets([ | ||
LevelSetList::UP_TO_PHP_83, | ||
SetList::CODE_QUALITY, | ||
SetList::DEAD_CODE, | ||
SetList::EARLY_RETURN, | ||
SetList::TYPE_DECLARATION, | ||
SetList::PRIVATIZATION, | ||
]); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace EchoLabs\Prism\Contracts; | ||
|
||
interface Provider {} |
Oops, something went wrong.