Skip to content
Snippets Groups Projects
README.md 5.73 KiB
Newer Older
  • Learn to ignore specific revisions
  • Marcus Schiesser's avatar
    Marcus Schiesser committed
    # Create Llama
    
    The easiest way to get started with [LlamaIndex](https://www.llamaindex.ai/) is by using `create-llama`. This CLI tool enables you to quickly start building a new LlamaIndex application, with everything set up for you.
    
    Logan Markewich's avatar
    Logan Markewich committed
    
    
    Marcus Schiesser's avatar
    Marcus Schiesser committed
    ## Get started
    
    
    Laurie Voss's avatar
    Laurie Voss committed
    Just run
    
    Logan Markewich's avatar
    Logan Markewich committed
    
    
    Laurie Voss's avatar
    Laurie Voss committed
    ```bash
    npx create-llama@latest
    ```
    
    
    Marcus Schiesser's avatar
    Marcus Schiesser committed
    to get started, or watch this video for a demo session:
    
    https://github.com/user-attachments/assets/dd3edc36-4453-4416-91c2-d24326c6c167
    
    Once your app is generated, run
    
    Laurie Voss's avatar
    Laurie Voss committed
    
    ```bash
    npm run dev
    ```
    
    to start the development server. You can then visit [http://localhost:3000](http://localhost:3000) to see your app.
    
    ## What you'll get
    
    
    Marcus Schiesser's avatar
    Marcus Schiesser committed
    - A Next.js-powered front-end using components from [shadcn/ui](https://ui.shadcn.com/). The app is set up as a chat interface that can answer questions about your data or interact with your agent
    
    Laurie Voss's avatar
    Laurie Voss committed
    - Your choice of 3 back-ends:
    
      - **Next.js**: if you select this option, you’ll have a full-stack Next.js application that you can deploy to a host like [Vercel](https://vercel.com/) in just a few clicks. This uses [LlamaIndex.TS](https://www.npmjs.com/package/llamaindex), our TypeScript library.
    
    Laurie Voss's avatar
    Laurie Voss committed
      - **Express**: if you want a more traditional Node.js application you can generate an Express backend. This also uses LlamaIndex.TS.
    
    Marcus Schiesser's avatar
    Marcus Schiesser committed
      - **Python FastAPI**: if you select this option, you’ll get a backend powered by the [llama-index Python package](https://pypi.org/project/llama-index/), which you can deploy to a service like Render or fly.io.
    
    - The back-end has two endpoints (one streaming, the other one non-streaming) that allow you to send the state of your chat and receive additional responses
    - You add arbitrary data sources to your chat, like local files, websites, or data retrieved from a database.
    - Turn your chat into an AI agent by adding tools (functions called by the LLM).
    
    Laurie Voss's avatar
    Laurie Voss committed
    - The app uses OpenAI by default, so you'll need an OpenAI API key, or you can customize it to use any of the dozens of LLMs we support.
    
    
    Marcus Schiesser's avatar
    Marcus Schiesser committed
    Here's how it looks like:
    
    https://github.com/user-attachments/assets/d57af1a1-d99b-4e9c-98d9-4cbd1327eff8
    
    
    Laurie Voss's avatar
    Laurie Voss committed
    ## Using your data
    
    
    You can supply your own data; the app will index it and answer questions. Your generated app will have a folder called `data` (If you're using Express or Python and generate a frontend, it will be `./backend/data`).
    
    Logan Markewich's avatar
    Logan Markewich committed
    
    
    Laurie Voss's avatar
    Laurie Voss committed
    The app will ingest any supported files you put in this directory. Your Next.js and Express apps use LlamaIndex.TS so they will be able to ingest any PDF, text, CSV, Markdown, Word and HTML files. The Python backend can read even more types, including video and audio files.
    
    Laurie Voss's avatar
    Laurie Voss committed
    Before you can use your data, you need to index it. If you're using the Next.js or Express apps, run:
    
    Laurie Voss's avatar
    Laurie Voss committed
    ```bash
    npm run generate
    ```
    
    
    Then re-start your app. Remember you'll need to re-run `generate` if you add new files to your `data` folder.
    
    If you're using the Python backend, you can trigger indexing of your data by calling:
    
    ```bash
    
    poetry run generate
    
    Laurie Voss's avatar
    Laurie Voss committed
    
    
    Laurie Voss's avatar
    Laurie Voss committed
    
    
    Optionally generate a frontend if you've selected the Python or Express back-ends. If you do so, `create-llama` will generate two folders: `frontend`, for your Next.js-based frontend code, and `backend` containing your API.
    
    Laurie Voss's avatar
    Laurie Voss committed
    
    
    ## Customizing the AI models
    
    Laurie Voss's avatar
    Laurie Voss committed
    
    
    Marcus Schiesser's avatar
    Marcus Schiesser committed
    The app will default to OpenAI's `gpt-4o-mini` LLM and `text-embedding-3-large` embedding model.
    
    Laurie Voss's avatar
    Laurie Voss committed
    
    
    If you want to use different OpenAI models, add the `--ask-models` CLI parameter.
    
    Laurie Voss's avatar
    Laurie Voss committed
    
    You can also replace OpenAI with one of our [dozens of other supported LLMs](https://docs.llamaindex.ai/en/stable/module_guides/models/llms/modules.html).
    
    
    To do so, you have to manually change the generated code (edit the `settings.ts` file for Typescript projects or the `settings.py` file for Python projects)
    
    
    Laurie Voss's avatar
    Laurie Voss committed
    ## Example
    
    The simplest thing to do is run `create-llama` in interactive mode:
    
    npx create-llama@latest
    
    npm create llama@latest
    
    yisding's avatar
    yisding committed
    yarn create llama
    # or
    
    pnpm create llama@latest
    
    Laurie Voss's avatar
    Laurie Voss committed
    You will be asked for the name of your project, along with other configuration options, something like this:
    
    >> npm create llama@latest
    
    Logan Markewich's avatar
    Logan Markewich committed
    Need to install the following packages:
    
      create-llama@latest
    
    Logan Markewich's avatar
    Logan Markewich committed
    Ok to proceed? (y) y
    ✔ What is your project named? … my-app
    
    Marcus Schiesser's avatar
    Marcus Schiesser committed
    ✔ Which template would you like to use? › Agentic RAG (single agent)
    
    Marcus Schiesser's avatar
    Marcus Schiesser committed
    ✔ Which framework would you like to use? › NextJS
    
    ✔ Would you like to set up observability? › No
    
    ✔ Please provide your OpenAI API key (leave blank to skip): …
    
    ✔ Which data source would you like to use? › Use an example PDF
    ✔ Would you like to add another data source? › No
    ✔ Would you like to use LlamaParse (improved parser for RAG - requires API key)? … no / yes
    ✔ Would you like to use a vector database? › No, just store the data in the file system
    
    Marcus Schiesser's avatar
    Marcus Schiesser committed
    ✔ Would you like to build an agent using tools? If so, select the tools here, otherwise just press enter › Weather
    
    ? How would you like to proceed? › - Use arrow-keys. Return to submit.
       Just generate code (~1 sec)
    ❯  Start in VSCode (~1 sec)
       Generate code and install dependencies (~2 min)
       Generate code, install dependencies, and run the app (~2 min)
    
    Laurie Voss's avatar
    Laurie Voss committed
    ### Running non-interactively
    
    
    You can also pass command line arguments to set up a new project
    
    non-interactively. See `create-llama --help`:
    
    create-llama <project-directory> [options]
    
    
    Options:
      -V, --version                      output the version number
    
      --use-npm
    
        Explicitly tell the CLI to bootstrap the app using npm
    
      --use-pnpm
    
        Explicitly tell the CLI to bootstrap the app using pnpm
    
      --use-yarn
    
        Explicitly tell the CLI to bootstrap the app using Yarn
    
    ```
    
    
    Logan Markewich's avatar
    Logan Markewich committed
    ## LlamaIndex Documentation
    
    - [TS/JS docs](https://ts.llamaindex.ai/)
    - [Python docs](https://docs.llamaindex.ai/en/stable/)
    
    
    Inspired by and adapted from [create-next-app](https://github.com/vercel/next.js/tree/canary/packages/create-next-app)