Skip to content
Snippets Groups Projects
Select Git revision
  • 0fc5535838ed601c8be6ad361690726ed7280980
  • main default
  • changeset-release/main
  • tp/remove-lits-server
  • tp/llamacloud-configs
  • tp/replace-python-examples-with-llamadeploy
  • feat/support-file-server-for-python-llamadeploy
  • tp/use-chat-workflow
  • tp/e2e-fail
  • ms/more-cleanup
  • ms/cleanup
  • ms/readd-ask-models
  • tp/stream-not-stop-after-sending-human-input-event
  • tp/fix-hitl-e2e-test
  • tp/hitl-for-ts
  • fix/test-e2e
  • lee/fix-callback-error
  • tp/fix-lint-for-release
  • tp/show-document-artifact-after-generate-report
  • lee/private-file
  • tp/bump-chat-ui-with-inline-artifact
  • @llamaindex/server@0.3.0
  • create-llama@0.6.3
  • create-llama@0.6.2
  • @llamaindex/server@0.2.10
  • @llamaindex/server@0.2.9
  • create-llama@0.6.1
  • create-llama@0.6.0
  • @llamaindex/server@0.2.8
  • create-llama@0.5.22
  • @llamaindex/server@0.2.7
  • create-llama@0.5.21
  • @llamaindex/server@0.2.6
  • create-llama@0.5.20
  • @llamaindex/server@0.2.5
  • @llamaindex/server@0.2.4
  • create-llama@0.5.19
  • @llamaindex/server@0.2.2
  • create-llama@0.5.16
  • create-llama@0.5.15
  • llama-index-server-v0.1.16
41 results

create-llama

  • Open with
  • Download source code
  • Your workspaces

      A workspace is a virtual sandbox environment for your code in GitLab.

      No agents available to create workspaces. Please consult Workspaces documentation for troubleshooting.

  • user avatar
    Thuc Pham authored and GitHub committed
    0fc55358
    History

    Create LlamaIndex App

    The easiest way to get started with LlamaIndex is by using create-llama. This CLI tool enables you to quickly start building a new LlamaIndex application, with everything set up for you.

    Just run

    npx create-llama@latest

    to get started, or see below for more options. Once your app is generated, run

    npm run dev

    to start the development server. You can then visit http://localhost:3000 to see your app.

    What you'll get

    • A Next.js-powered front-end. The app is set up as a chat interface that can answer questions about your data (see below)
      • You can style it with HTML and CSS, or you can optionally use components from shadcn/ui
    • 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 in just a few clicks. This uses LlamaIndex.TS, our TypeScript library.
      • Express: if you want a more traditional Node.js application you can generate an Express backend. This also uses LlamaIndex.TS.
      • Python FastAPI: if you select this option you’ll get a backend powered by the llama-index python package, which you can deploy to a service like Render or fly.io.
    • The back-end has a single endpoint that allows you to send the state of your chat and receive additional responses
    • You can choose whether you want a streaming or non-streaming back-end (if you're not sure, we recommend streaming)
    • You can choose whether you want to use ContextChatEngine or SimpleChatEngine
      • SimpleChatEngine will just talk to the LLM directly without using your data
      • ContextChatEngine will use your data to answer questions (see below).
    • 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.

    Using your data

    If you've enabled ContextChatEngine, you can supply your own data and the app will index it and answer questions. Your generated app will have a folder called data:

    • With the Next.js backend this is ./data
    • With the Express or Python backend this is in ./backend/data

    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.

    Before you can use your data, you need to index it. If you're using the Next.js or Express apps, run:

    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 deleting the ./storage folder and re-starting the app.

    Don't want a front-end?

    It's optional! If you've selected the Python or Express back-ends, just delete the frontend folder and you'll get an API without any front-end code.

    Customizing the LLM

    By default the app will use OpenAI's gpt-3.5-turbo model. If you want to use GPT-4, you can modify this by editing a file:

    • In the Next.js backend, edit ./app/api/chat/route.ts and replace gpt-3.5-turbo with gpt-4
    • In the Express backend, edit ./backend/src/controllers/chat.controller.ts and likewise replace gpt-3.5-turbo with gpt-4
    • In the Python backend, edit ./backend/app/utils/index.py and once again replace gpt-3.5-turbo with gpt-4

    You can also replace OpenAI with one of our dozens of other supported LLMs.

    Example

    The simplest thing to do is run create-llama in interactive mode:

    npx create-llama@latest
    # or
    npm create llama@latest
    # or
    yarn create llama
    # or
    pnpm create llama@latest

    You will be asked for the name of your project, along with other configuration options, something like this:

    >> npm create llama@latest
    Need to install the following packages:
      create-llama@latest
    Ok to proceed? (y) y
    ✔ What is your project named? … my-app
    ✔ Which template would you like to use? › Chat with streaming
    ✔ Which framework would you like to use? › NextJS
    ✔ Which UI would you like to use? › Just HTML
    ✔ Which chat engine would you like to use? › ContextChatEngine
    ✔ Please provide your OpenAI API key (leave blank to skip): …
    ✔ Would you like to use ESLint? … No / Yes
    Creating a new LlamaIndex app in /home/my-app.

    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
    

    LlamaIndex Documentation

    Inspired by and adapted from create-next-app