Skip to content

Commit e7523ce

Browse files
committed
Initial Commit
0 parents  commit e7523ce

27 files changed

+662
-0
lines changed

.github/workflows/formatting.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Formatting
2+
3+
on:
4+
push:
5+
paths:
6+
- "**.php"
7+
- ".github/workflows/formatting.yml"
8+
9+
env:
10+
phpv: 8.3
11+
12+
jobs:
13+
formatting:
14+
name: Formatting
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 5
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ env.phpv }}
24+
coverage: none
25+
26+
- name: Install composer dependencies
27+
uses: ramsey/composer-install@v3
28+
29+
- name: Run Pint
30+
run: |
31+
vendor/bin/pint
32+
git diff --exit-code
33+
34+
- name: Run Rector
35+
run: |
36+
vendor/bin/rector
37+
git diff --exit-code

.github/workflows/phpstan.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: PHPStan
2+
3+
on:
4+
push:
5+
paths:
6+
- "**.php"
7+
- "phpstan.neon.dist"
8+
- ".github/workflows/phpstan.yml"
9+
10+
env:
11+
phpv: 8.3
12+
13+
jobs:
14+
phpstan:
15+
name: phpstan
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 5
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ env.phpv }}
25+
coverage: none
26+
27+
- name: Install composer dependencies
28+
uses: ramsey/composer-install@v3
29+
30+
- name: Run PHPStan
31+
run: ./vendor/bin/phpstan --error-format=github

.github/workflows/tests.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
paths:
6+
- "**.php"
7+
- ".github/workflows/tests.yml"
8+
- "phpunit.xml.dist"
9+
- "composer.json"
10+
- "composer.lock"
11+
12+
jobs:
13+
test:
14+
runs-on: ${{ matrix.os }}
15+
timeout-minutes: 5
16+
strategy:
17+
fail-fast: true
18+
matrix:
19+
os: [ubuntu-latest]
20+
php: [8.3]
21+
laravel: [11.*]
22+
stability: [prefer-lowest, prefer-stable]
23+
include:
24+
- laravel: 11.*
25+
testbench: 9.*
26+
carbon: ^2.63
27+
28+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
34+
- name: Setup PHP
35+
uses: shivammathur/setup-php@v2
36+
with:
37+
php-version: ${{ matrix.php }}
38+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
39+
coverage: none
40+
41+
- name: Setup problem matchers
42+
run: |
43+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
44+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
45+
46+
- name: Install dependencies
47+
run: |
48+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.os == 'windows-latest' && '^^^' || '' }}${{ matrix.carbon }}" --no-interaction --no-update
49+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
50+
51+
- name: List Installed Dependencies
52+
run: composer show -D
53+
54+
- name: Execute tests
55+
run: vendor/bin/pest --ci

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/vendor/
2+
composer.lock
3+
/build/
4+
task/
5+
.idea/

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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}}

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
![](docs/images/prism-banner.webp)
2+
3+
# Prism
4+
5+
Prism makes it easier to work with LLMs by offering a consistent integration
6+
method for your app. This way, you can focus on developing outstanding AI
7+
applications for your users without getting lost in the technical intricacies.
8+
9+
## Generating Text

Taskfile.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# https://taskfile.dev
2+
3+
version: "3"
4+
5+
tasks:
6+
setup:
7+
cmds:
8+
- composer install
9+
sources:
10+
- composer.json
11+
- composer.lock
12+
generates:
13+
- vendor/autoload.php
14+
15+
push:
16+
cmds:
17+
- git remote | xargs -I{} git push {{.CLI_ARGS}} {}
18+
19+
format:
20+
cmds:
21+
- vendor/bin/rector
22+
- vendor/bin/pint
23+
24+
validate:
25+
cmds:
26+
- vendor/bin/pest --compact
27+
- vendor/bin/phpstan

bin/git-hooks/formatting

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
_print() {
4+
printf "\e[38;5;4m%s\e[0m\n" "$1"
5+
}
6+
7+
main() {
8+
files_before_format=$(git diff --name-only --diff-filter=d)
9+
10+
_print "Running pint..."
11+
vendor/bin/pint --dirty
12+
13+
_print "Running rector..."
14+
vendor/bin/rector process --no-diffs
15+
16+
files_after_format=$(git diff --name-only --diff-filter=d)
17+
18+
# Find files fixed by pint by comparing file lists before and after pint run
19+
files_fixed_by_format=$(comm -13 <(sort <<<"$files_before_format") <(sort <<<"$files_after_format"))
20+
21+
# Re-stage files fixed by pint
22+
_print "Re-staging changed files..."
23+
for f in $files_fixed_by_format; do git add "$f"; done || exit
24+
}
25+
26+
main "$@"

composer.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "echolabs/prism",
3+
"description": "AI",
4+
"type": "library",
5+
"license": "MIT",
6+
"autoload": {
7+
"psr-4": {
8+
"EchoLabs\\Prism\\": "src/"
9+
}
10+
},
11+
"authors": [
12+
{
13+
"name": "TJ Miller",
14+
"email": "[email protected]"
15+
}
16+
],
17+
"require": {
18+
"laravel/framework": "^11.0"
19+
},
20+
"config": {
21+
"allow-plugins": {
22+
"php-http/discovery": true,
23+
"pestphp/pest-plugin": true,
24+
"phpstan/extension-installer": true
25+
}
26+
},
27+
"require-dev": {
28+
"pestphp/pest": "^2.34",
29+
"laravel/pint": "^1.14",
30+
"phpstan/phpstan": "^1.11",
31+
"pestphp/pest-plugin-arch": "^2.7",
32+
"pestphp/pest-plugin-laravel": "^2.4",
33+
"phpstan/extension-installer": "^1.3",
34+
"phpstan/phpstan-deprecation-rules": "^1.2",
35+
"rector/rector": "^1.1",
36+
"projektgopher/whisky": "^0.7.0"
37+
},
38+
"autoload-dev": {
39+
"psr-4": {
40+
"Tests\\": "tests/"
41+
}
42+
},
43+
"scripts": {
44+
"post-autoload-dump": [
45+
"@clear",
46+
"@prepare"
47+
],
48+
"phpstan": [
49+
"phpstan analyse -c phpstan.neon.dist"
50+
],
51+
"format": [
52+
"pint",
53+
"rector process --no-diffs"
54+
],
55+
"test": [
56+
"@php vendor/bin/pest"
57+
]
58+
}
59+
}

config/prism.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
return [
4+
'providers' => [
5+
'openai' => [
6+
'driver' => 'openai',
7+
'url' => env('OPENAI_URL', 'https://api.openai.com/v1'),
8+
'api_key' => env('OPENAI_API_KEY'),
9+
],
10+
'anthropic' => [
11+
'driver' => 'anthropic',
12+
'api_key' => env('ANTHROPIC_API_KEY'),
13+
'version' => env('ANTHROPIC_API_VERSION', '2023-06-01'),
14+
],
15+
],
16+
];

0 commit comments

Comments
 (0)