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