### Run LocalGPT Music Guru with Ollama Provider Source: https://github.com/jtsternberg/localgpt/blob/main/examples/README.md This example sets up a music streaming specialist GPT, leveraging the Ollama provider and the `llama3:latest` model. Prior to use, ensure Ollama is installed and actively running on your system, as no API key is required. The command provided will start an interactive chat session with the Music Guru. ```bash localgpt chat music-guru-ollama-llama3-latest ``` -------------------------------- ### Run LocalGPT Burger Expert with OpenAI Provider Source: https://github.com/jtsternberg/localgpt/blob/main/examples/README.md This example demonstrates a food-expert GPT using the OpenAI provider and the `gpt-3.5-turbo` model. It requires your `OPENAI_API_KEY` to be configured in the `.env` file. The first command starts an interactive chat, while the second illustrates how to query the GPT using a reference file for specific information. ```bash localgpt chat burger-expert-openai-gpt-3.5-turbo ``` ```bash localgpt chat burger-expert-openai-gpt-3.5-turbo --message "Can you share with me one of your top secret recipes?" --verbose ``` -------------------------------- ### Run LocalGPT Pizza Pro with Gemini Provider Source: https://github.com/jtsternberg/localgpt/blob/main/examples/README.md This example configures a simple GPT expert on pizza, utilizing the Gemini provider and the `gemini-2.5-flash` model. To use it, ensure your `GEMINI_API_KEY` is set in the `.env` file. The provided command initiates an interactive chat session with the Pizza Pro GPT. ```bash localgpt chat pizza-pro-gemini-2.5-flash ``` -------------------------------- ### Chat with an Example LocalGPT Configuration Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Initiate a chat session using one of the pre-configured example GPTs provided with the tool. This demonstrates how to interact with existing configurations and can be used for testing or learning purposes. ```bash localgpt chat examples/pizza-pro-gemini-2.5-flash ``` -------------------------------- ### localgpt: Example Interactive Chat Session Walkthrough Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Demonstrates a typical interactive chat session with a configured GPT, showing the loading process and a sample user interaction. This example illustrates the command-line interface and AI response format. It helps new users understand the basic workflow. ```bash $ localgpt chat examples/pizza-pro-gemini-2.5-flash Loading GPT: Pizza Pro - Lover of all things pizza Provider: gemini Model: gemini-2.5-flash You can start chatting now. (type 'exit' to quit) > What is the best pizza in the world? 🤖 The best pizza in the world is the Margherita pizza. > ``` -------------------------------- ### Run LocalGPT Real-estate Guru with Anthropic Provider Source: https://github.com/jtsternberg/localgpt/blob/main/examples/README.md This example showcases a regional real-estate expert GPT, powered by the Anthropic provider and the `claude-3-5-sonnet-20240620` model. You must configure your `ANTHROPIC_API_KEY` in the `.env` file to use this example. The command queries the GPT to determine its specialized geographic region. ```bash localgpt chat real-estate-anthropic-claude-3-5-sonnet-20240620 -m "What region is your speciality?" --verbose ``` -------------------------------- ### LocalGPT Dynamic System Prompt Template (SYSTEM_PROMPT.md) Source: https://github.com/jtsternberg/localgpt/blob/main/ROADMAP.md Example `SYSTEM_PROMPT.md` content showing the use of double curly brace `{{key}}` syntax for dynamic placeholders. These placeholders are replaced at runtime with values from `gpt.json` or command-line arguments. ```Markdown You are PizzaGPT, the ultimate pizza enthusiast and culinary expert, especially in regards to the specific region of {{pizza_region}}. ``` -------------------------------- ### LocalGPT Dynamic System Prompt Configuration (gpt.json) Source: https://github.com/jtsternberg/localgpt/blob/main/ROADMAP.md Example `gpt.json` configuration demonstrating how to define `custom_fields` for dynamic system prompt replacements. Fields include `name`, `key`, `type`, `default`, and `options` for interactive user input or predefined values. ```JSON { "title": "Pizza Pro", "system_prompt": "./SYSTEM_PROMPT.md", "custom_fields": [ { "name": "Pizza Region", "key": "pizza_region", "type": "dropdown", "default": "Chicago", "options": [ "Chicago", "New York", "San Francisco" ] } ] } ``` -------------------------------- ### Install LocalGPT CLI with Composer Source: https://github.com/jtsternberg/localgpt/blob/main/README.md This command globally installs the LocalGPT command-line interface using Composer. Ensure your Composer global bin directory is included in your system's PATH to execute `localgpt` commands directly. ```bash composer global require jtsternberg/localgpt ``` -------------------------------- ### Configure API Keys for LocalGPT Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Set up your API keys by copying the example environment file and then adding your specific API keys for Gemini, OpenAI, and Anthropic. The CLI automatically loads the correct key based on the provider specified in your GPT's configuration. ```bash cp .env.example .env ``` ```dotenv # .env GEMINI_API_KEY="your_gemini_api_key_here" OPENAI_API_KEY="your_openai_api_key_here" ANTHROPIC_API_KEY="your_anthropic_api_key_here" ``` -------------------------------- ### Create a New LocalGPT Configuration Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Initiate the interactive wizard to create a new custom GPT configuration. This command generates a new directory containing `gpt.json`, `SYSTEM_PROMPT.md`, and a `reference-files/` directory, guiding you through setting up its title, description, provider, model, and system prompt. ```bash localgpt new my-first-gpt ``` -------------------------------- ### Start an Interactive Chat Session with LocalGPT Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Begin an interactive chat session with your previously created custom GPT. This allows for continuous dialogue directly from your terminal, enabling real-time interaction with your configured AI model. ```bash localgpt chat my-first-gpt ``` -------------------------------- ### localgpt: Start Interactive Chat Session with GPT Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Initiates an interactive chat session with a specified GPT model. Users can converse directly with the AI, typing 'exit' to quit. This command requires the GPT's name as an argument. ```bash localgpt chat my-first-gpt ``` -------------------------------- ### localgpt: Send Single Message to GPT (Non-Interactive) Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Sends a single message to a specified GPT without starting an interactive session. The AI's response is printed directly to stdout. This mode is ideal for scripting or quick, one-off queries. ```bash localgpt chat my-first-gpt --message "What is the capital of France?" ``` -------------------------------- ### localgpt: Configure GPT Reference Files in gpt.json Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Shows how to add local files as reference material to a GPT via its gpt.json configuration. The reference_files array specifies paths to documents. Their content is included in the system prompt, providing context to the LLM. ```json { "reference_files": [ "./reference-files/my-file-1.txt", "./reference-files/my-file-2.md" ] } ``` -------------------------------- ### LocalGPT: LLPhant Integration Enhancements Roadmap Source: https://github.com/jtsternberg/localgpt/blob/main/TODO.md This section outlines future enhancements for LocalGPT leveraging the LLPhant library. These integrations aim to expand provider support, expose a public PHP API, introduce an AI-powered system prompt builder, and implement advanced features like reference file handling and chat history persistence. ```APIDOC LLPhant Integration Enhancements: - Add support for more LLM providers: - Groq - DeepSeek - Grok - Grok 2 - Expose a public PHP API for using LocalGPT, with LLPhant as the backend. - Create a "System Prompt Builder" agent using LLPhant to interactively define a GPT's persona. - Implement reference file handling by using LLPhant's embedding and retrieval features. - Implement chat history persistence using LLPhant's chat history features. ``` -------------------------------- ### APIDOC: `localgpt new` Command Reference Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Documents the `localgpt new` command, which creates a new GPT configuration through an interactive wizard. It details the parameters requested during the wizard, including title, description, provider, model, and system prompt, and explains the resulting file structure. ```bash localgpt new ``` ```APIDOC Command: new Description: Creates a new GPT configuration via an interactive wizard. Parameters (Interactive Wizard): - "Title": string - A name for your GPT. - "Description": string - A short description of what it does. - "Provider": enum (gemini, openai, anthropic) - Select a provider from a list of supported options. - "Model": string - Select a model from the chosen provider's available list. - "System Prompt": string - The core instructions for the GPT. Stored in `SYSTEM_PROMPT.md`. Output: - Creates a new directory named after the provided slug (e.g., `my-first-gpt/`). - Directory contains: `gpt.json` (configuration file), `SYSTEM_PROMPT.md` (system prompt), and `reference-files/` (directory for reference files). ``` -------------------------------- ### PHP: Implement Dynamic Field Replacement in BaseProvider Source: https://github.com/jtsternberg/localgpt/blob/main/TODO.md This snippet outlines the necessary changes to `BaseProvider.php` to support dynamic system prompt replacements. It involves storing custom field values and using them to substitute placeholders within the system prompt string. This ensures that the generated prompts are tailored based on runtime configurations. ```APIDOC namespace LocalGPT\Provider; use LocalGPT\Models\Config; abstract class BaseProvider { /** * @var array Stores resolved custom field values for prompt replacement. */ protected array $customFieldValues = []; /** * Sets the custom field values to be used for prompt replacements. * @param array $values An associative array of custom field keys and their resolved values. */ public function setCustomFieldValues(array $values): void; /** * Configures the provider, including setting custom field values from the Config object. * @param Config $config The configuration object. */ public function setConfig(Config $config): void; /** * Builds the system prompt, replacing '{{key}}' placeholders with values from $customFieldValues. * @return string The dynamically built system prompt. */ protected function buildSystemPrompt(): string; } ``` -------------------------------- ### localgpt: List Available AI Models from Providers Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Displays all available AI models from configured providers. For the 'ollama' provider, it lists locally pulled models. This helps users identify compatible models for their GPT configurations. ```bash localgpt models ``` -------------------------------- ### localgpt: GPT Configuration File Schema (gpt.json) Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Defines the structure of the gpt.json file used for manual GPT configuration. This schema outlines properties like reference_files and implicitly other core GPT settings. It enables advanced customization of GPT behavior. ```APIDOC { "name": "string", "provider": "string", "model": "string", "reference_files": [ "string" ] } ``` -------------------------------- ### PHP: Enhance Config Model for Dynamic Fields Source: https://github.com/jtsternberg/localgpt/blob/main/TODO.md This snippet details the planned modifications to the `Config.php` model. The goal is to enable the storage and retrieval of custom field configurations, allowing for dynamic system prompt adjustments based on user-defined values. It involves adding properties and methods to manage these fields. ```APIDOC namespace LocalGPT\Models; class Config { /** * @var array Custom fields configuration, parsed from gpt.json. */ public array $custom_fields; /** * Retrieves the configured custom fields. * @return array An associative array of custom field definitions. */ public function getCustomFields(): array; /** * Sets or updates a specific custom field value at runtime. * This value might override defaults or values from gpt.json. * @param string $key The key of the custom field. * @param string $value The value to set for the custom field. */ public function setCustomFieldValue(string $key, string $value): void; /** * Constructor or loading method should correctly parse 'custom_fields' array from gpt.json. */ public function __construct(/* ... */); } ``` -------------------------------- ### PHP: Handle Dynamic Field Arguments in ChatCommand Source: https://github.com/jtsternberg/localgpt/blob/main/TODO.md This snippet details the enhancements for `ChatCommand.php` to manage dynamic custom field values. It covers parsing command-line arguments, resolving field values based on a defined priority, and interactively prompting the user for missing values. The final resolved values are then passed to the provider for prompt generation. ```APIDOC namespace LocalGPT\Command; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Question\ChoiceQuestion; class ChatCommand extends Command { /** * Configures the command, defining the '--set' option. * The '--set' option accepts key-value pairs (e.g., --set pizza_region="New York") and can be repeated. */ protected function configure(): void; /** * Executes the chat command, handling custom field value resolution. * @param InputInterface $input The input interface. * @param OutputInterface $output The output interface. * @return int The command exit code. */ protected function execute(InputInterface $input, OutputInterface $output): int { // 1. Parse all '--set' command-line arguments and store them. // 2. Load the GPT configuration (including custom field definitions). // 3. Determine the final value for each custom field based on priority: // a. Value from '--set' command-line argument. // b. Pre-defined 'value' in 'gpt.json'. // c. Value from interactive prompt. // d. 'default' value from 'gpt.json'. // 4. For each custom field that still needs a value, prompt the user interactively: // - Use Symfony Question Helper's 'Question' for 'text' type fields. // - Use Symfony Question Helper's 'ChoiceQuestion' for 'dropdown' type fields. // 5. Collect all final custom field values. // 6. Pass these collected values to the provider instance using setCustomFieldValues(). } } ``` -------------------------------- ### localgpt: Send File Content to GPT (Non-Interactive) Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Sends the content of a local file as a message to a GPT. This allows for providing extensive or pre-formatted input from a file. The GPT's response is outputted directly to stdout. ```bash localgpt chat my-first-gpt --messageFile "path/to/your/message.md" ``` -------------------------------- ### Send a Single Message to LocalGPT Source: https://github.com/jtsternberg/localgpt/blob/main/README.md Send a one-time message to your custom GPT without entering an interactive session. This is useful for quick queries or integrating into scripts, and can also accept file content as the message input. ```bash localgpt chat my-first-gpt --message "What is the capital of France?" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.