Installation
You can install it using Composer:NOTE: Polyglot is distributed as part of the Instructor PHP package, so if you have it installed, you don’t need to install Polyglot separately.
Requirements
- PHP 8.2 or higher
- Composer
- Valid API keys for at least one supported LLM provider
Configuration
Setting Up API Keys
Polyglot requires API keys to authenticate with LLM providers. The recommended approach is to use environment variables:- Create a
.envfile in your project root (or use your existing one) - Add your API keys:
Configuration Files
Polyglot loads its configuration from PHP files. The default configuration files are located in the Instructor package, but you can publish and customize them:- Create a
configdirectory in your project if it doesn’t exist - Copy the configuration files from the Instructor package:
- Customize the configuration files as needed
LLM Configuration
Thellm.php configuration file contains settings for LLM providers:
Embeddings Configuration
Theembed.php configuration file contains settings for embeddings providers:
Custom Configuration Location
By default, Polyglot looks for custom configuration files in theconfig directory relative to your project root. You can specify a different location by setting the INSTRUCTOR_CONFIG_PATHS environment variable:
Overriding Configuration Location
You can useSettings class static setPath() method to override the value of config path set in environment variable with your own value.
Troubleshooting
Common Installation Issues
- Composer Dependencies: Make sure you have PHP 8.2+ installed and Composer correctly configured.
- API Keys: Verify that your API keys are correctly set in your environment variables.
- Configuration Files: Check that your configuration files are properly formatted and accessible.