<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Josh Embling</title>
    <description>The latest articles on DEV Community by Josh Embling (@joshembling).</description>
    <link>https://dev.to/joshembling</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1268892%2F12b1cd97-b878-43e8-a2f5-66d82cad3fbe.jpeg</url>
      <title>DEV Community: Josh Embling</title>
      <link>https://dev.to/joshembling</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joshembling"/>
    <language>en</language>
    <item>
      <title>Meet Laragenie: The AI 'Colleague' That Understands Your Codebases</title>
      <dc:creator>Josh Embling</dc:creator>
      <pubDate>Tue, 30 Jan 2024 07:55:00 +0000</pubDate>
      <link>https://dev.to/joshembling/meet-laragenie-the-ai-colleague-that-understands-your-codebases-4me6</link>
      <guid>https://dev.to/joshembling/meet-laragenie-the-ai-colleague-that-understands-your-codebases-4me6</guid>
      <description>&lt;p&gt;Ever wondered what it would be like to have instant, contextual answers to questions about projects, without having to wait on others for responses?&lt;/p&gt;

&lt;p&gt;Perhaps you want to onboard members of the team, but don't have a budget that covers the full cost of the pairing journey over a period of days, weeks or months.&lt;/p&gt;

&lt;p&gt;Maybe you're a solo developer that wants to get a second opinion on a feature from someone that knows the project as well as you do, but you don't want to share the context with strangers online.&lt;/p&gt;

&lt;p&gt;If you're a Laravel developer you're in luck…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Meet Laragenie:&lt;/strong&gt; The AI colleague made for the command line, ready to revolutionise your coding experience. After a few simple setup steps, you'll transform your projects to a level that was previously impossible. Onboarding, developer assistance and daily support has never been so easy.&lt;/p&gt;

&lt;p&gt;Don't fret if you're not a Laravel dev either. Even though Laragenie is a tool that runs on a Laravel app, you can still use it to &lt;strong&gt;integrate with any project in any language&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgijsduukjpkn1hcjyfz0.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgijsduukjpkn1hcjyfz0.gif" alt="Laragenie example gif" width="600" height="397"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's get setup
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;This package uses Laravel Prompts which supports macOS, Linux, and Windows with WSL. Due to limitations in the Windows version of PHP, it is not currently possible to use Laravel Prompts on Windows outside of WSL.&lt;br&gt;
For this reason, Laravel Prompts supports falling back to an alternative implementation such as the Symfony Console Question Helper.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You'll need a few things to get started: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Laravel app running version 10 or greater&lt;/li&gt;
&lt;li&gt;PHP 8.1 or greater&lt;/li&gt;
&lt;li&gt;An &lt;a href="https://openai.com/"&gt;OpenAI&lt;/a&gt; developer account&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://www.pinecone.io/"&gt;Pinecone&lt;/a&gt; developer account&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you already have a Laravel 10+ app running, great. If you don't, you can &lt;a href="https://laravel.com/docs/10.x"&gt;follow the instructions here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  OpenAI
&lt;/h2&gt;

&lt;p&gt;Laragenie uses OpenAI for embeddings and AI responses.&lt;/p&gt;

&lt;p&gt;If you don't have an OpenAI account, create one and generate an API key. You'll also need to add some credits to use the API; $5.00–10.00 will be enough to last a short while and should give you around 500–1000 AI responses. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you still think that's expensive, think of the time, cost and effort it would take to ask that many questions in forums, to co-workers etc.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Once you've completed your OpenAI setup, add the following to your &lt;code&gt;.env&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OPENAI_API_KEY=your-open-ai-key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Pinecone
&lt;/h2&gt;

&lt;p&gt;Laragenie uses Pinecone to store vectors from your indexed files.&lt;/p&gt;

&lt;p&gt;The easiest way to start is with a free account. Create an environment with 1536 dimensions and name it whatever you'd like. Go ahead and generate an API key and add these details to your &lt;code&gt;.env&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PINECONE_API_KEY=your-pinecone-api-key
PINECONE_ENVIRONMENT=gcp-starter
PINECONE_INDEX=your-index
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Installation in your Laravel app
&lt;/h2&gt;

&lt;p&gt;Install the Laragenie package via Composer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;composer&lt;/span&gt; &lt;span class="k"&gt;require&lt;/span&gt; &lt;span class="n"&gt;joshembling&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;laragenie&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can publish and run the migrations with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;vendor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;publish&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"laragenie-migrations"&lt;/span&gt;
&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;migrate&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This will add a table to your database to save your AI responses.&lt;/em&gt;&lt;br&gt;
 &lt;br&gt;
You can publish the config file with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;vendor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;publish&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"laragenie-config"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Your published config will look something like this:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'bot'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Laragenie'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// The name of your chatbot&lt;/span&gt;
        &lt;span class="s1"&gt;'welcome'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Hello, I am Laragenie, how may I assist you today?'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Your welcome message&lt;/span&gt;
        &lt;span class="s1"&gt;'instructions'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Write in markdown format. Try to only use factual data that can be pulled from indexed chunks.'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// The chatbot instructions&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;

    &lt;span class="s1"&gt;'chunks'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'size'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Maximum number of caracters to separate chunks&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;

    &lt;span class="s1"&gt;'database'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'fetch'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Fetch saved answers from previous questions&lt;/span&gt;
        &lt;span class="s1"&gt;'save'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Save answers to the database&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;

    &lt;span class="s1"&gt;'extensions'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="c1"&gt;// The file types you want to index&lt;/span&gt;
        &lt;span class="s1"&gt;'php'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'blade.php'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'js'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;

    &lt;span class="s1"&gt;'indexes'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'directories'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="c1"&gt;// The directores you want to index e.g. ['App/Models', 'App/Http/Controllers', '../frontend/src']&lt;/span&gt;
        &lt;span class="s1"&gt;'files'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="c1"&gt;// The files you want to index e.g. ['tests/Feature/MyTest.php']&lt;/span&gt;
        &lt;span class="s1"&gt;'removal'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'strict'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// User prompt on deletion requests of indexes&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;

    &lt;span class="s1"&gt;'openai'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'embedding'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'model'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'text-embedding-ada-002'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Text embedding model &lt;/span&gt;
            &lt;span class="s1"&gt;'max_tokens'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Maximum tokens to use when embedding&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="s1"&gt;'chat'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'model'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'gpt-4-1106-preview'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Your OpenAI GPT model&lt;/span&gt;
            &lt;span class="s1"&gt;'temperature'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Set temperature on the model&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;

    &lt;span class="s1"&gt;'pinecone'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'topK'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Pinecone indexes to fetch&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you've completed the steps above you're ready to start using Laragenie. Open a terminal and run the following command from the root directory of your Laravel app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;laragenie&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will be greeted by Laragenie and see four options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ask a question&lt;/li&gt;
&lt;li&gt;Index files&lt;/li&gt;
&lt;li&gt;Remove indexed files&lt;/li&gt;
&lt;li&gt;Something else&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use the arrow keys to toggle through the options and enter to select the command.&lt;/p&gt;




&lt;h2&gt;
  
  
  Ask a question
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fryswzmvjy0oxs4zz9j2j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fryswzmvjy0oxs4zz9j2j.png" alt="Ask a question" width="800" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note: you can only run this action once you have files indexed in your Pinecone vector database (skip to the 'Index Files' section if you wish to find out how to start indexing).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When your vector database has indexes you'll be able to ask any questions relating to your codebase. &lt;/p&gt;

&lt;p&gt;Answers can be generated in markdown format with code examples, or any format of your choosing. Use the &lt;code&gt;bot.instructions&lt;/code&gt; config to write AI instructions as detailed as you need to.&lt;/p&gt;

&lt;p&gt;Beneath each response you will see the generated cost (in US dollars), which will help keep close track of the expense. Cost of the response is added to your database, if migrations are enabled.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Costs can vary, but small responses will be less than $0.01. Much larger responses can be between $0.02–0.05.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Force AI
&lt;/h3&gt;

&lt;p&gt;As previously mentioned, when you have migrations enabled your questions will save to your database. &lt;/p&gt;

&lt;p&gt;However, you may want to force AI usage (prevent fetching from the database) if you are unsatisfied with the initial answer. This will overwrite the answer already saved to the database.&lt;/p&gt;

&lt;p&gt;To force an AI response, you will need to end all questions with an &lt;code&gt;--ai&lt;/code&gt; flag e.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Tell me how users are saved to the database --ai
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will ensure the AI model will re-assess your request, and outputs another answer (this could be the same answer depending on the GPT model you are using).&lt;/p&gt;

&lt;h2&gt;
  
  
  Index files
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1e7uxzo36bsdg65pxx8o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1e7uxzo36bsdg65pxx8o.png" alt="Index files" width="800" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The quickest way to index files is to pass in singular values to the directories and/or files array in the Laragenie config. When you run the 'Index Files' command you will always have the option to index/reindex these files. This will help in keeping your Laragenie up to date.&lt;/p&gt;

&lt;p&gt;Select 'yes', when prompted with Do you want to index your directories and files saved in your config?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="s1"&gt;'indexes'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'directories'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'App/Models'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'App/Http/Controllers'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="s1"&gt;'files'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'tests/Feature/MyTest.php'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="s1"&gt;'removal'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'strict'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;],&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you select 'no', you can also index files in the following ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input a file name with its namespace e.g. &lt;code&gt;App/Models/User.php&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Input a full directory, e.g. &lt;code&gt;Services&lt;/code&gt;
-- If you pass in a directory, Laragenie can only index files within this directory, and not its subdirectories.
-- To index subdirectories you must explicitly pass the path e.g. &lt;code&gt;App/Models&lt;/code&gt; to index all of your models&lt;/li&gt;
&lt;li&gt;Input multiple files or directories in a comma separated list e.g. &lt;code&gt;App/Models, tests/Feature, App/Http/Controllers/Controller.php&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Input multiple directories with wildcards e.g. &lt;code&gt;App/Models/*.php&lt;/code&gt;
-- Please note that the wildcards must still match the file extensions in your Laragenie config file.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Indexing files outside of your Laravel project
&lt;/h3&gt;

&lt;p&gt;You may use Laragenie in any way that you wish; you are not limited to indexing Laravel files based in this directory.&lt;/p&gt;

&lt;p&gt;For example, your Laravel project may live in a monorepo with two root entries such as frontend and backend. In this instance, you could move up one level to index more directories and files e.g. &lt;code&gt;../frontend/src/&lt;/code&gt; or &lt;code&gt;../frontend/components/Component.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can add these to your directories and files in the Laragenie config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="s1"&gt;'indexes'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'directories'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'App/Models'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'App/Http/Controllers'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'../frontend/src/'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="s1"&gt;'files'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'tests/Feature/MyTest.php'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'../frontend/components/Component.js'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="s1"&gt;'removal'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'strict'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;],&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using this same method, you could technically index any files or directories you have access to on your server or local machine.&lt;br&gt;
 &lt;br&gt;
&lt;strong&gt;Ensure your extensions in your Laragenie config match all the file types that you want to index.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="s1"&gt;'extensions'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'php'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'blade.php'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'js'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'jsx'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'ts'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'tsx'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// etc...&lt;/span&gt;
&lt;span class="p"&gt;],&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: if your directories, paths or file names change, Laragenie will not be able to find the index if you decide to update/remove it later on (unless you truncate your entire vector database, or go into Pinecone and delete them manually).&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Removing indexed files
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp3lbhlwui0aqci4w33ae.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp3lbhlwui0aqci4w33ae.png" alt="Removing indexed files" width="800" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can remove indexed files using the same methods listed above, except from using your directories or files array in the Laragenie config - this is currently for indexing purposes only.&lt;/p&gt;

&lt;p&gt;If you want to remove all files you may do so by selecting &lt;code&gt;Remove all chunked data&lt;/code&gt;. Be warned that this will truncate your entire vector database and cannot be reversed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl6582z795aoavfhib0ra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl6582z795aoavfhib0ra.png" alt="Truncate" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To remove a comma separated list of files/directories, select the &lt;code&gt;Remove data associated with a directory or specific file&lt;/code&gt; prompt as an option.&lt;/p&gt;

&lt;p&gt;Strict removal, i.e. warning messages before files are removed, can be turned on/off by changing the 'strict' attribute in your config.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="s1"&gt;'indexes'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'removal'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'strict'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;],&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Stopping Laragenie
&lt;/h2&gt;

&lt;p&gt;You can stop Laragenie using the following methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ctrl + c&lt;/code&gt; (Linux/Mac)&lt;/li&gt;
&lt;li&gt;Selecting &lt;code&gt;No thanks, goodbye&lt;/code&gt; in the user menu after at least 1 prompt has run.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;It's as simple as that! Accelerate your workflow instantly and collaborate seamlessly with the quickest and most knowledgeable 'colleague' you've ever had.&lt;/p&gt;

&lt;p&gt;Have fun using Laragenie! 🤖&lt;/p&gt;

&lt;p&gt;👉 You can follow me on Github here: &lt;a href="https://github.com/joshembling"&gt;@joshembling&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⭐ If you've enjoyed this article, please star and share the Laragenie project: &lt;a href="https://github.com/joshembling/laragenie"&gt;https://github.com/joshembling/laragenie&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>ai</category>
      <category>openai</category>
      <category>pinecone</category>
    </item>
  </channel>
</rss>
