/php-ai

A PHP demo application consuming OpenAI GPT API and implementing memory-training through embeddings

Primary LanguagePHPApache License 2.0Apache-2.0

PhpAi

This is a demo application to show how to implement OpenAI's GPT API into a PHP Symfony application, training the AI with some documents via embeddings to give it some custom knowledge and context, and long-term memory.

This is a work-in-progress.

To start working,

  1. Clone this repo locally:
git clone git@github.com:obokaman-com/php-ai.git
  1. Copy .env into .env.local and complete with your OpenAI API Key.
cd php-ai && cp .env .env.local
  1. Install all dependencies
composer install
  1. Put any required documents in /public/docs_to_ingest folder (now only works with PDFs)
  2. Ingest them into memory:
bin/console memory:ingest
  1. Ask a question:
bin/console ai:question

For interactive question, or

bin/console ai:question --question "My question"

For direct questioning the AI.