Section Blog technologique

RAG System and Txtai Part 3: Practical Cases

Written by gbourdin on 22/01/2024
In the first part, we discussed how to converse with a model to obtain dialogue based on untrained information. In our second part, we looked at how to create our indexes and store them. In this final part, through a practical case, we will cover how to create a complete RAG system and initiate a dialogue, giving users the chance to converse with our model enriched with our own data. Just a reminder, all the information is in the documentation available here. Therefore, you do not really ne...

RAG System and TxtAI Part 2: Databases and Vector Indexing

Written by admin on 22/01/2024
In the first part, we discussed how to interact with a model to obtain a dialogue based on information it was not trained on. In summary, you add the desired information to the context. But what if you want to use an entire knowledge base? That would be far too much information to add to the context. For this, we need to put all the information we wish to provide to users into a database. We will break down our content into paragraphs and apply a vector index. This index converts text into ...

RAG System and TxtAi Part 1: Transforming Language Generation with Intelligence

Written by gbourdin on 08/12/2023
For this first part of our series of articles, we're going to base our exploration on this tutorial to implement a RAG process. But what is a RAG? RAG, or "Retrieval-Augmented Generation," is an advanced technique in artificial intelligence, specifically in the field of natural language processing (NLP), which involves enriching the text generation process by incorporating an information retrieval phase. This hybrid method combines the power of deep learning-based language models with the e...

Llama.cpp bringing LLM to your fingertips

Written by gbourdin on 05/12/2023
Llama CPP is a new tool designed to run language models directly in C/C++. This tool is specially optimized for Apple Silicon processors through the use of ARM NEON technology and the Accelerate framework. It also offers AVX2 compatibility for systems based on x86 architectures. Operating mainly on the CPU, Llama CPP also integrates 4-bit quantization capability, further enhancing its efficiency. Its advantage is that it allows for the execution of a language model directly on a personal co...

Introduction to txtai: Simplifying and Empowering LLMs for Developers

Written by admin on 05/12/2023
In the constantly evolving universe of artificial intelligence and natural language processing, txtai emerges as a revolutionary tool, especially for those delving into the world of large language models (LLMs). Imagine a bridge between you and an array of powerful LLMs, where txtai plays the role of a facilitator, simplifying and amplifying your interactions with these complex technologies. Extended Connectivity with LLMs Txtai stands out with its ability to connect to various LLMs. Whethe...

Sonata Page 5: Adding Open Graph Tags with SonataPage and SonataMediaSonata

Written by admin on 02/10/2023
Category:   symfony, Sonata
If you have already used SonataPage and SonataMedia, you know how powerful they are for managing content and media on your site. In this article, I am going to show you how to extend these tools to easily add Open Graph tags to your pages to enhance their sharing on social networks. Why Open Graph tags? Open Graph (OG) tags are meta-tags that you can add to your pages to define titles, descriptions, images, and other information that will be used when the page ...

Sonata Page 5: Hide blocks within shared blocks.

Written by admin on 30/09/2023
Category:   symfony
If you're using the SonataPage bundle, you may have noticed that some of the blocks offered are unnecessary or non-functional.We'll discuss how to hide these blocks from the list cleanly, with a configuration file, and by overriding the admin templates of SonataPage. 1 – The Configuration We need to create a list of services that we don't want to display. This list will naturally go into the parameters of our services file: #con...

Sonata: Add an Admin Panel without an Entity with Sonata Admin 5 and Symfony 6.2

Written by admin on 06/06/2023
Category:   symfony, Sonata
In this article, we will learn how to add an admin panel without entities in a Symfony 6.2 project using Sonata Admin 5. Our project base will be to create a simple file upload interface. But you could make any application. Including adding simple text. 1. Installing Sonata Admin Bundle If you haven't already installed Sonata Admin, you can do so with composer: composer require sonata-project/admin-bundle We invite you to browse our site to install Son...

How to Create a Custom Email Transport with Symfony Mailer

Written by admin on 19/05/2023
Category:   PHP, symfony
Today, we're going to see how to create a custom email transport with Symfony Mailer. For the example, we'll create a transport named “pt”. Prerequisites Before we begin, make sure you have installed and configured Symfony Mailer and HttpClient in your project. You can add them to your project using the following commands: composer require symfony/mailer composer require symfony/http-client Creating the Transport Class The first thing to do is...

PHP FFI: Creating a Bind with a Library, QuickJS – Part 5

Written by admin on 24/01/2023
Category:   PHP, PHP / FFI
To conclude this mini technical file on PHP's foreign functions interface, I set out to simply connect to a lib. A kind of challenge that could at the same time help me progress on the topic. So I had to come up with a project idea. Something not too small or too simple but also not too big. Failed, I found an idea but this turns out to be much more complex than I imagined. No matter, I still tried. So for our article, I thought I would attempt...

Symfony: Forcing an entity to use a different database connection than the default configured one

Written by admin on 19/01/2023
Category:   PHP, symfony
It is not uncommon to have multiple databases for a single project. Normally, when two databases are used, entities can be organized into specific directories that are declared in your configuration. In this case, the system will use the connection configured for the entity directory. You can see an example of multiple connections here Symfony 4 / Sonata: managing a multi-server admin interface Let's assume that we want to point to a read-only database (a ...

Use composer and bin/console from your Docker image directly within PHPSTORM

Written by on 19/01/2023
Category:   PHP, symfony, phpstorm, Divers
Okay, you are like me. Your machine has nothing installed locally. Not even composer nor PHP in CLI!While you use PHP and maybe even Symfony (or not), you need to use composer daily. You use PhpStorm every day and think it's a shame not to benefit from all the options of your IDE, especially everything related to composer and the Symfony console. So how do you configure PhpStorm to specify that the composer for your project is located in the docker image?Here is an example of docker-compose.y...

Sonata Custom Actions

Written by admin on 19/01/2023
Category:   PHP, symfony, Sonata
Following the article written by Thomas Bourdin SYMFONY / SONATA: ADDING A CLONE FUNCTION TO A CRUD, we are going to show how, in a very simple way, we can add custom actions to an interface. On the Dashboard: But we are also going to see how to simply and generically customize the custom actions of the listing, your CRUD’s header and finally how to add actions for batch processing. For my example, I started with a very simple table called ...

Debug with PhpStorm and Symfony in a Docker Image

Written by admin on 19/01/2023
Category:   PHP, PHP / FFI, symfony, phpstorm
PHP/Docker Configuration If you are developing with Symfony, installed in a docker compose and still not using the debugger, then this article is for you. We are going to show you how to prepare your environment so you no longer have to do dd() or var_dump. Once you have tasted the joys of debugging, you won't be able to do without it, as it will greatly enhance your comfort. For this article you need to have a Symfony app powered by apache/php (or nginx and...

Create a library with composer

Written by on 04/01/2023
Category:   PHP, Divers
What is Composer? Just as NPM is to JavaScript, Composer is the dedicated tool for PHP that allows you to manage library dependencies for your applications. If you've used a framework like Symfony, you've definitely used it. In reality, every PHP developer uses it on a daily basis. If you're on this page, you're probably wondering how to create a library that can be easily redistributed and shared with the community. That's what I'll try to show you. For the sake of our tutorial, I'll take a ...

PHPSTORM Configuration of 'Quality Tools' in a Docker Image

Written by on 15/12/2022
Category:   PHP, symfony, phpstorm
Here's a question I recently pondered. Usually, I install QA tools directly on my host or in the Docker image. If tools are installed on my host, there's no problem configuring PhpStorm. If the tools are directly configured in the Docker image, there's also no problem using them within the image. However, how can one combine the power of PhpStorm and Docker to link the two? So, here’s how to proceed with the installation of php_codesniffer, Mess Detector, CS Fixer, PSalm, PhpStan. ...

Configure Exim to send emails with Gmail

Written by on 12/12/2022
We will see how to configure Exim4 to send system emails with Gmail. This will ensure that your emails sent with your CRON are correctly routed and do not end up in spam. Let's install Exim4 apt-get install exim4 Configuration dpkg-reconfigure exim4-config Choose: mail sent by smarthost; no local mail Then answer the questions as follows: System mail name: YOUR_HOSTNAME IP-addresses to listen on for incoming SMTP connections: 127.0.0.1 ; ::1 Other destinations fo...

Sonata DataMapper and Autowiring

Written by on 08/12/2022
Category:   PHP, symfony, Sonata
If you have a specific need to transform data between the form and the recording of your entity and think that this transformation code should be located in a service because it makes more sense, you can use the dataMapper by utilizing the dependency injection provided by Symfony. But how to implement it? A small reminder about the DataMapper. If we agree with the official Symfony documentation regarding DataMapper and DataTransformer, a dataMapper has the responsibility to read and write an ...

SF6 / Sonata 5: Managing a OneToMany interface in a CRUD with Sonata's CollectionType

Written by admin on 27/11/2022
Category:   PHP, symfony, Sonata
Tags:   sonata, symfony, admin
In this example, we will take the concrete case of a simple interface that includes multiple elements. We have chosen to use a "Projects" table in which we will assign documents. Therefore, for a project, we can assign several documents. And to facilitate administration, we will ensure that we can manage our nested interface directly within the edit view of our project.We need to create the schema. Firstly, we import our current schema into MysqlWorbench usi...

PHP FFI: Using a Kotlin Multiplatform Library – Part 4

Written by on 11/11/2022
Category:   PHP, PHP / FFI
With Stéphane Péchard https://www.linkedin.com/in/stephanepechard/, Android expert and KMP guru, we wondered if developing an algorithm under KMP and executing it directly in PHP would be feasible. The specifications were simple: the Android dev (Stéphane) provides me with a header file, a .so file and I handle it. With the header file, the contract, we should be able to come up with something... So we managed to make our function call. But to be honest, I still strug...

PHP FFI: Callback - Part 3

Written by on 11/11/2022
Category:   PHP, PHP / FFI
The CallbackDuring the preparation of this article, I noticed that many resources on the internet directly use the libc for their examples. You can easily find fairly demonstrative and simple examples. But to do something cool and original, I thought to myself "let's find something to show with this libc too". After all… if it's just passing a structure as most examples do, it won't be useful. And then I came across a function in a forum where people were ...

PHP FFI: Passing Parameters – Part 2

Written by on 11/11/2022
Category:   PHP, PHP / FFI
Calling the PHP library directly?What if we had fun writing a piece of code that is useless? Come on!!! Come on!! Come on!!!Alright OK. I propose we do something useless by using PHP to call a C library that uses the Zend Engine.Actually, this paragraph is not as useless as it seems. Its purpose is to show you a particular behavior 😊PHP-FFI has a few limitations: you can't pass a PHP variable directly to retrieve its dynamic value from the external library.You only have access to passing C la...

PHP FFI: Introduction – Part 1

Written by on 11/11/2022
Category:   PHP, PHP / FFI
IntroductionSince version 7.4 of PHP, we finally have access to interoperability functions between different languages and PHP: the FFI or Foreign Function Interface.What is FFI? It is simply the ability to use an external library (.dll or .so) directly in PHP, without having to create a PHP extension. Yes, with just a PHP script! It is, among other things, what has made Python so famous and allowed it to have so many features.The great thing about FFI is that a PHP developer who is not an e...

Symfony 6 / Sonata 5: Installing SonataClassification.

Written by on 14/03/2022
Category:   PHP, symfony, Sonata
We have seen in previous articles how to initialize a Symfony 6 + Sonata 5 project with media and users in a secure admin. We then looked at how to manage user localizations.Now we will see how to install and manage classifications. We proceed with the installation of the latest version to date. php8.1 composer.phar require sonata-project/classification-bundle:5.x-dev Apparently, we have a configuration error. Unrecognized option "media" under "sonata_classification.class". Availabl...

Symfony 6 / Sonata 5: Link locales and timezone to user preferences.

Written by admin on 10/03/2022
Category:   PHP, symfony, Sonata
We saw in a previous article how to install Symfony 6 + Sonata Admin 5 with user and media management. We will continue this installation with the configuration of languages and time zones. We will install intlBundle which allows to manage localized display. php8.1 composer.phar require sonata-project/intl-bundle We take this opportunity to add a timezone and locale field to the user.To do this, we will extend userBundle and add a field in the admin...