symfony / ai-demo
Symfony AI Demo Application
Fund package maintenance!
fabpot
Tidelift
symfony.com/sponsor
Requires
- php: >=8.4
- ext-ctype: *
- ext-iconv: *
- codewithkyrian/chromadb-php: ^0.4.0
- league/commonmark: ^2.7
- mrmysql/youtube-transcript: ^0.0.5
- php-http/discovery: ^1.20
- runtime/frankenphp-symfony: ^0.2.0
- symfony/ai-bundle: @dev
- symfony/asset: 7.3.*
- symfony/asset-mapper: 7.3.*
- symfony/clock: 7.3.*
- symfony/console: 7.3.*
- symfony/css-selector: 7.3.*
- symfony/dom-crawler: 7.3.*
- symfony/dotenv: 7.3.*
- symfony/flex: ^2.5
- symfony/framework-bundle: 7.3.*
- symfony/http-client: 7.3.*
- symfony/monolog-bundle: ^3.10
- symfony/runtime: 7.3.*
- symfony/twig-bundle: 7.3.*
- symfony/uid: 7.3.*
- symfony/ux-icons: ^2.25
- symfony/ux-live-component: ^2.25
- symfony/ux-turbo: ^2.25
- symfony/ux-typed: ^2.25
- symfony/yaml: 7.3.*
- twig/extra-bundle: ^3.21
- twig/markdown-extra: ^3.21
- twig/twig: ^3.21
Requires (Dev)
- nyholm/nsa: ^1.3
- php-cs-fixer/shim: ^3.75
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- symfony/browser-kit: 7.3.*
- symfony/debug-bundle: 7.3.*
- symfony/stopwatch: 7.3.*
- symfony/web-profiler-bundle: 7.3.*
Conflicts
This package is auto-updated.
Last update: 2025-07-11 11:26:54 UTC
README
Symfony application demoing Symfony AI components.
Examples
Requirements
What you need to run this demo:
- Internet Connection
- Terminal & Browser
- Git & GitHub Account
- Docker with Docker Compose Plugin
- Your Favorite IDE or Editor
- An OpenAI API Key
Technology
This small demo sits on top of following technologies:
- PHP >= 8.4
- Symfony 7.3 incl. Twig, Asset Mapper & UX
- Bootstrap 5
- OpenAI's GPT & Embeddings
- ChromaDB Vector Store
- FrankenPHP
Setup
The setup is split into three parts, the Symfony application, the OpenAI configuration, and initializing the Chroma DB.
1. Symfony App
Checkout the repository, start the docker environment and install dependencies:
git clone git@github.com:symfony/ai-demo.git
cd ai-demo
docker compose up -d
docker compose run composer install
Now you should be able to open https://localhost/ in your browser, and the chatbot UI should be available for you to start chatting.
Note
You might have to bypass the security warning of your browser with regard to self-signed certificates.
2. OpenAI Configuration
For using GPT and embedding models from OpenAI, you need to configure an OpenAI API key as environment variable.
This requires you to have an OpenAI account, create a valid API key and set it as OPENAI_API_KEY
in .env.local
file.
echo "OPENAI_API_KEY='sk-...'" > .env.local
Verify the success of this step by running the following command:
docker compose exec app bin/console debug:dotenv
You should be able to see the OPENAI_API_KEY
in the list of environment variables.
3. Chroma DB Initialization
The Chroma DB is a vector store that is used to store embeddings of the chatbot's context.
To initialize the Chroma DB, you need to run the following command:
docker compose exec app bin/console app:blog:embed -vv
Now you should be able to run the test command and get some results:
docker compose exec app bin/console app:blog:query
Don't forget to set up the project in your favorite IDE or editor.
Functionality
- The chatbot application is a simple and small Symfony 7.3 application.
- The UI is coupled to a Twig LiveComponent, that integrates different
Chat
implementations on top of the user's session. - You can reset the chat context by hitting the
Reset
button in the top right corner. - You find three different usage scenarios in the upper navbar.