Skip to content

Commit 9fa0c47

Browse files
move from LLPhant
0 parents  commit 9fa0c47

File tree

134 files changed

+23161
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+23161
-0
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at http://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 4
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[*.yml]
18+
indent_size = 2

.gitattributes

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/art export-ignore
2+
/tests export-ignore
3+
/.github export-ignore
4+
.editorconfig export-ignore
5+
.gitattributes export-ignore
6+
.gitignore export-ignore
7+
CHANGELOG.md export-ignore
8+
CONTRIBUTING.md export-ignore
9+
phpstan.neon.dist export-ignore
10+
phpunit.xml.dist export-ignore
11+
README.md export-ignore
12+
rector.php export-ignore
13+
devx export-ignore
14+
examples export-ignore
15+
docusaurus export-ignore

.github/workflows/formats.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Formats
2+
3+
on: ['pull_request']
4+
5+
jobs:
6+
ci:
7+
runs-on: ${{ matrix.os }}
8+
9+
strategy:
10+
fail-fast: true
11+
matrix:
12+
os: [ubuntu-latest]
13+
php: [8.2]
14+
dependency-version: [prefer-lowest, prefer-stable]
15+
16+
name: Formats P${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}
17+
18+
steps:
19+
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Cache dependencies
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.composer/cache/files
27+
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
28+
29+
- name: Setup PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: ${{ matrix.php }}
33+
extensions: dom, mbstring, zip
34+
tools: prestissimo
35+
coverage: pcov
36+
37+
- name: Install Composer dependencies
38+
run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist
39+
40+
- name: Coding Style Checks
41+
run: composer test:lint
42+
43+
- name: Refactor Checks
44+
run: composer test:refactor
45+
46+
- name: Type Checks
47+
run: composer test:types
48+
49+
- name: Type Coverage
50+
run: composer test:type-coverage min=100

.github/workflows/tests.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Tests
2+
3+
on: ['pull_request']
4+
5+
jobs:
6+
ci:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
os: [ubuntu-latest]
12+
php: [8.2]
13+
dependency-version: [prefer-lowest, prefer-stable]
14+
15+
name: Tests P${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}
16+
17+
steps:
18+
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Cache dependencies
23+
uses: actions/cache@v4
24+
with:
25+
path: ~/.composer/cache/files
26+
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
27+
28+
- name: Setup PHP
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: ${{ matrix.php }}
32+
extensions: dom, mbstring, zip
33+
coverage: none
34+
35+
- name: Install Composer dependencies
36+
run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist
37+
38+
- name: Unit Tests
39+
run: composer test:unit
40+
41+
- name: Composer Audit
42+
run: composer audit

.github/workflows/trufflehog.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: TruffleHog
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- name: Secret Scanning
17+
uses: trufflesecurity/trufflehog@main
18+
with:
19+
extra_args: --only-verified

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/.phpunit.cache
2+
/.php-cs-fixer.cache
3+
/.php-cs-fixer.php
4+
/composer.lock
5+
/phpunit.xml
6+
/vendor/
7+
*.swp
8+
*.swo
9+
playground/*
10+
.idea
11+
script.php
12+
/docusaurus/.yarn
13+
/docusaurus/yarn.lock
14+
/docusaurus/.pnp.cjs
15+
/docusaurus/.pnp.loader.mjs

CONTRIBUTING.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# CONTRIBUTING
2+
3+
Contributions are welcome, and are accepted via pull requests.
4+
Please review these guidelines before submitting any pull requests.
5+
6+
7+
## Setup
8+
Clone your fork, then install the dev dependencies:
9+
```bash
10+
composer install
11+
```
12+
13+
You can use the `devx/docker-compose.yml` file to run a local postgresql database with the pgvector extension available.
14+
```bash
15+
docker-compose up -d
16+
```
17+
18+
## Process
19+
20+
1. Fork the project
21+
1. Create a new branch
22+
1. Code, test, commit and push
23+
1. Open a pull request detailing your changes.
24+
25+
## Guidelines
26+
27+
* Please ensure the coding style running `composer lint`.
28+
* Send a coherent commit history, making sure each individual commit in your pull request is meaningful.
29+
* You may need to [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) to avoid merge conflicts.
30+
* Please remember that we follow [SemVer](http://semver.org/).
31+
32+
## Refactor
33+
34+
Refactor your code:
35+
```bash
36+
composer refactor
37+
```
38+
39+
## Lint
40+
41+
Lint your code:
42+
```bash
43+
composer lint
44+
```
45+
46+
## Tests
47+
48+
Run all tests:
49+
```bash
50+
composer test
51+
```
52+
53+
Check code quality:
54+
```bash
55+
composer test:refactor
56+
```
57+
58+
Check types:
59+
```bash
60+
composer test:types
61+
```
62+
63+
Unit tests:
64+
```bash
65+
composer test:unit
66+
```
67+
68+
### Integration tests
69+
70+
You'll need a API key from OPENAI and export it as a env var.
71+
You also need to have a postgresql database running with the same parameters
72+
as in the `docker-compose.yaml` file from `devx` folder.
73+
74+
Then run this sql query to create the table for the tests:
75+
76+
```postgresql
77+
CREATE EXTENSION vector;
78+
79+
CREATE TABLE IF NOT EXISTS test_place (
80+
id SERIAL PRIMARY KEY,
81+
content text,
82+
type text,
83+
sourcetype text,
84+
sourcename text,
85+
embedding vector
86+
);
87+
CREATE TABLE IF NOT EXISTS test_doc (
88+
id SERIAL PRIMARY KEY,
89+
content text,
90+
type text,
91+
sourcetype text,
92+
sourcename text,
93+
embedding vector,
94+
chunknumber int
95+
);
96+
```
97+
98+
Then run:
99+
```bash
100+
composer test:int
101+
```
102+
103+
You can set host names and keys for the various services involved in integration tests using these environment variables:
104+
```
105+
OPENAI_API_KEY
106+
MISTRAL_API_KEY
107+
ANTHROPIC_API_KEY
108+
ASTRADB_ENDPOINT
109+
ASTRADB_TOKEN
110+
ELASTIC_URL
111+
PGVECTOR_HOST
112+
REDIS_HOST
113+
MILVUS_HOST
114+
QDRANT_HOST
115+
CHROMADB_HOST
116+
OLLAMA_URL
117+
LAKERA_ENDPOINT
118+
LAKERA_API_KEY
119+
TYPESENSE_API_KEY
120+
TYPESENSE_NODE
121+
```
122+

LICENSE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
The MIT License (MIT)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# AutoPHP - An agent PHP framework
2+
3+
You can now make your [AutoGPT](https://github.com/Significant-Gravitas/Auto-GPT) clone in PHP using LLPhant.
4+
5+
Here is a simple example using the SerpApiSearch tool to create an autonomous PHP agent.
6+
You just need to describe the objective and add the tools you want to use.
7+
We will add more tools in the future.
8+
9+
```php
10+
use LLPhant\AutoPHP;
11+
use LLPhant\Chat\FunctionInfo\FunctionBuilder;
12+
use LLPhant\Tool\SerpApiSearch;
13+
14+
require_once 'vendor/autoload.php';
15+
16+
// You describe the objective
17+
$objective = 'Find the names of the wives or girlfriends of at least 2 players from the 2023 male French football team.';
18+
19+
// You can add tools to the agent, so it can use them. You need an API key to use SerpApiSearch
20+
// Have a look here: https://serpapi.com
21+
$searchApi = new SerpApiSearch();
22+
$function = FunctionBuilder::buildFunctionInfo($searchApi, 'search');
23+
24+
$autoPHP = new AutoPHP($objective, [$function]);
25+
$autoPHP->run();
26+
```
27+
28+
29+
## Sponsor
30+
31+
AutoPHP is sponsored by :
32+
- [AGO](https://useago.com). Generative AI customer support solutions.

0 commit comments

Comments
 (0)