Skip to content

Commit f54efd0

Browse files
committed
feature #35: integrate demo application
* integrate-demo: (31 commits) refactor: restructure into demo folder chore: update to llm-chain 0.22 (#27) refactor: more error handling in vidoe example chore: symfony 7.3 update fix: pin chroma db version and clean up (#26) feat: add demo of GPT vision capabilities based on video stream (#22) chore: dependecy update (#23) feat: extend wikipedia system prompt by tools (#21) chore: update to lib v0.19 (#20) refactor: optimize audio chat ui (#19) feat: audio example (#18) chore: updating dependencies (#17) chore: composer update incl twig cve patch (#16) chore: llm chain update with system_prompt support (#15) chore: install bundle 0.12 (#14) chore: update to llm-chain 0.11.0 (#13) chore: library update (#12) refactor: follow up on example structure to have them cleaner and more separated (#11) fix: typed animation only on xhr responses (#10) refactor: moving classes to a more component like structure (#9) ...
2 parents cec23dc + 03dcf05 commit f54efd0

File tree

103 files changed

+13217
-1
lines changed

Some content is hidden

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

103 files changed

+13217
-1
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
->setRiskyAllowed(true)
4343
->setFinder(
4444
(new PhpCsFixer\Finder())
45-
->in([__DIR__.'/src', __DIR__.'/examples', __DIR__.'/fixtures'])
45+
->in([__DIR__.'/demo', __DIR__.'/examples', __DIR__.'/fixtures', __DIR__.'/src'])
4646
->append([__FILE__])
4747
->notPath('#/Fixtures/#')
4848
)

demo/.env

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# In all environments, the following files are loaded if they exist,
2+
# the latter taking precedence over the former:
3+
#
4+
# * .env contains default values for the environment variables needed by the app
5+
# * .env.local uncommitted file with local overrides
6+
# * .env.$APP_ENV committed environment-specific defaults
7+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
8+
#
9+
# Real environment variables win over .env files.
10+
#
11+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
# https://symfony.com/doc/current/configuration/secrets.html
13+
#
14+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
15+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
16+
17+
###> symfony/framework-bundle ###
18+
APP_ENV=dev
19+
APP_SECRET=ccb9dca72dce53c683eaaf775bfdb253
20+
###< symfony/framework-bundle ###
21+
22+
CHROMADB_HOST=chromadb
23+
OPENAI_API_KEY=sk-...

demo/.env.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# define your env variables for the test env here
2+
KERNEL_CLASS='App\Kernel'
3+
APP_SECRET='$ecretf0rt3st'
4+
SYMFONY_DEPRECATIONS_HELPER=999999
5+
PANTHER_APP_ENV=panther
6+
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
7+
OPENAI_API_KEY=sk-proj-testing1234

demo/.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Please do not submit any Pull Requests here. They will be closed.
2+
---
3+
4+
Please submit your PR here instead:
5+
https://github.com/symfony/ai
6+
7+
This repository is what we call a "subtree split": a read-only subset of that main repository.
8+
We're looking forward to your PR there!
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Close Pull Request
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
jobs:
8+
run:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: superbrothers/close-pull-request@v3
12+
with:
13+
comment: |
14+
Thanks for your Pull Request! We love contributions.
15+
16+
However, you should instead open your PR on the main repository:
17+
https://github.com/symfony/ai
18+
19+
This repository is what we call a "subtree split": a read-only subset of that main repository.
20+
We're looking forward to your PR there!

demo/.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
###> symfony/framework-bundle ###
2+
/.env.local
3+
/.env.local.php
4+
/.env.*.local
5+
/config/secrets/dev/dev.decrypt.private.php
6+
/config/secrets/prod/prod.decrypt.private.php
7+
/public/bundles/
8+
/var/
9+
/vendor/
10+
###< symfony/framework-bundle ###
11+
###> symfony/asset-mapper ###
12+
/public/assets/
13+
/assets/vendor/
14+
###< symfony/asset-mapper ###
15+
16+
###> php-cs-fixer/shim ###
17+
/.php-cs-fixer.php
18+
/.php-cs-fixer.cache
19+
###< php-cs-fixer/shim ###
20+
21+
###> phpstan/phpstan ###
22+
phpstan.neon
23+
###< phpstan/phpstan ###
24+
25+
###> phpunit/phpunit ###
26+
.phpunit.cache
27+
###< phpunit/phpunit ###
28+
29+
chromadb
30+
coverage

demo/LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2025-present Fabien Potencier
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 furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
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.

demo/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Symfony AI - Demo Application
2+
3+
Symfony application demoing Symfony AI components.
4+
5+
## Examples
6+
7+
![demo.png](demo.png)
8+
9+
## Requirements
10+
11+
What you need to run this demo:
12+
13+
* Internet Connection
14+
* Terminal & Browser
15+
* [Git](https://git-scm.com/) & [GitHub Account](https://github.com)
16+
* [Docker](https://www.docker.com/) with [Docker Compose Plugin](https://docs.docker.com/compose/)
17+
* Your Favorite IDE or Editor
18+
* An [OpenAI API Key](https://platform.openai.com/docs/api-reference/create-and-export-an-api-key)
19+
20+
## Technology
21+
22+
This small demo sits on top of following technologies:
23+
24+
* [PHP >= 8.4](https://www.php.net/releases/8.4/en.php)
25+
* [Symfony 7.3 incl. Twig, Asset Mapper & UX](https://symfony.com/)
26+
* [Bootstrap 5](https://getbootstrap.com/docs/5.0/getting-started/introduction/)
27+
* [OpenAI's GPT & Embeddings](https://platform.openai.com/docs/overview)
28+
* [ChromaDB Vector Store](https://www.trychroma.com/)
29+
* [FrankenPHP](https://frankenphp.dev/)
30+
31+
## Setup
32+
33+
The setup is split into three parts, the Symfony application, the OpenAI configuration, and initializing the Chroma DB.
34+
35+
### 1. Symfony App
36+
37+
Checkout the repository, start the docker environment and install dependencies:
38+
39+
```shell
40+
git clone [email protected]:symfony/ai-demo.git
41+
cd ai-demo
42+
docker compose up -d
43+
docker compose run composer install
44+
```
45+
46+
Now you should be able to open https://localhost/ in your browser,
47+
and the chatbot UI should be available for you to start chatting.
48+
49+
> [!NOTE]
50+
> You might have to bypass the security warning of your browser with regard to self-signed certificates.
51+
52+
### 2. OpenAI Configuration
53+
54+
For using GPT and embedding models from OpenAI, you need to configure an OpenAI API key as environment variable.
55+
This requires you to have an OpenAI account, create a valid API key and set it as `OPENAI_API_KEY` in `.env.local` file.
56+
57+
```shell
58+
echo "OPENAI_API_KEY='sk-...'" > .env.local
59+
```
60+
61+
Verify the success of this step by running the following command:
62+
63+
```shell
64+
docker compose exec app bin/console debug:dotenv
65+
```
66+
67+
You should be able to see the `OPENAI_API_KEY` in the list of environment variables.
68+
69+
### 3. Chroma DB Initialization
70+
71+
The [Chroma DB](https://www.trychroma.com/) is a vector store that is used to store embeddings of the chatbot's context.
72+
73+
To initialize the Chroma DB, you need to run the following command:
74+
75+
```shell
76+
docker compose exec app bin/console app:blog:embed -vv
77+
```
78+
79+
Now you should be able to run the test command and get some results:
80+
81+
```shell
82+
docker compose exec app bin/console app:blog:query
83+
```
84+
85+
**Don't forget to set up the project in your favorite IDE or editor.**
86+
87+
## Functionality
88+
89+
* The chatbot application is a simple and small Symfony 7.3 application.
90+
* The UI is coupled to a [Twig LiveComponent](https://symfony.com/bundles/ux-live-component/current/index.html), that integrates different `Chat` implementations on top of the user's session.
91+
* You can reset the chat context by hitting the `Reset` button in the top right corner.
92+
* You find three different usage scenarios in the upper navbar.

demo/assets/app.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import './bootstrap.js';
2+
import 'bootstrap/dist/css/bootstrap.min.css';
3+
import './styles/app.css';
4+
import './styles/audio.css';
5+
import './styles/blog.css';
6+
import './styles/youtube.css';
7+
import './styles/video.css';
8+
import './styles/wikipedia.css';

demo/assets/bootstrap.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { startStimulusApp } from '@symfony/stimulus-bundle';
2+
3+
const app = startStimulusApp();
4+
// register any custom, 3rd party controllers here
5+
// app.register('some_controller_name', SomeImportedController);

0 commit comments

Comments
 (0)