Skip to content

Commit 810700d

Browse files
authored
docs: update docs/readme.md
1 parent 939dcb1 commit 810700d

File tree

1 file changed

+194
-1
lines changed

1 file changed

+194
-1
lines changed

docs/readme.md

Lines changed: 194 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,197 @@ products:
1515
urlFragment: llama-index-javascript
1616
name: "Serverless Azure OpenAI Quick Start with LlamaIndex"
1717
description: A sample project that showcases how to use and deploy LlamaIndex application on Azure using azd.
18-
---
18+
---
19+
20+
## Features
21+
22+
This project demonstrates how to build a simple LlamaIndex application using Azure OpenAI. The app is set up as a chat interface that can answer questions about your data. You can add arbitrary data sources to your chat, like local files, websites, or data retrieved from a database. The app will ingest any supported files you put in `./data/` directory. This sample app uses LlamaIndex.TS that is able to ingest any PDF, text, CSV, Markdown, Word and HTML files.
23+
24+
## Architecture Diagram
25+
26+
<div align="center">
27+
<img src="./docs/architecture-diagram-llama-index-javascript.png" alt="Screenshot showing the chatgpt app high level diagram" width="640px" />
28+
</div>
29+
30+
This application is built around a single component:
31+
32+
- A full-stack Next.js application that is hosted on [Azure Container Apps](https://learn.microsoft.com/azure/container-apps/) in just a few commands. This app uses [LlamaIndex.TS](https://github.com/run-llama/LlamaIndexTS), a TypeScript library that can ingest any PDF, text, CSV, Markdown, Word and HTML files.
33+
34+
- The app uses [Azure OpenAI](https://learn.microsoft.com/azure/ai-services/openai/overview) to answer questions about the data you provide. The app is set up to use the `gpt-35-turbo` model and embeddings to provide the best and fastest answers to your questions.
35+
36+
## Getting Started
37+
38+
You have a few options for getting started with this template. The quickest way to get started is [GitHub Codespaces](#github-codespaces), since it will setup all the tools for you, but you can also [set it up locally](#local-environment). You can also use a [VS Code dev container](#vs-code-dev-containers)
39+
40+
This template uses `gpt-35-turbo` version `1106` which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly
41+
42+
* We recommend using `swedencentral`
43+
44+
### GitHub Codespaces
45+
46+
You can run this template virtually by using GitHub Codespaces. The button will open a web-based VS Code instance in your browser:
47+
48+
1. Open the template (this may take several minutes)
49+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/llama-index-javascript?hide_repo_select=true&ref&quickstart=true)
50+
2. Open a terminal window
51+
3. Sign into your Azure account:
52+
53+
```shell
54+
azd auth login
55+
```
56+
4. Provision the Azure resources and deploy your code:
57+
58+
```shell
59+
azd up
60+
```
61+
5. Install the app dependencies:
62+
63+
```bash
64+
npm install
65+
```
66+
67+
### VS Code Dev Containers
68+
69+
A related option is VS Code Dev Containers, which will open the project in your local VS Code using the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers):
70+
71+
1. Start Docker Desktop (install it if not already installed)
72+
2. Open the project:
73+
[![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/llama-index-javascript)
74+
3. In the VS Code window that opens, once the project files show up (this may take several minutes), open a terminal window.
75+
4. Sign into your Azure account:
76+
77+
```shell
78+
azd auth login
79+
```
80+
5. Provision the Azure resources and deploy your code:
81+
82+
```shell
83+
azd up
84+
```
85+
6. Install the app dependencies:
86+
87+
```bash
88+
npm install
89+
```
90+
7. Configure a CI/CD pipeline:
91+
92+
```shell
93+
azd pipeline config
94+
```
95+
96+
To start the web app, run the following command:
97+
98+
```bash
99+
npm run dev
100+
```
101+
102+
Open the URL `http://localhost:3000` in your browser to interact with the bot.
103+
104+
### Local Environment
105+
106+
#### Prerequisites
107+
108+
You need to install following tools to work on your local machine:
109+
110+
- [Docker](https://docs.docker.com/get-docker)
111+
- [Node.js LTS](https://nodejs.org/download/)
112+
- [Azure Developer CLI](https://aka.ms/azure-dev/install)
113+
- [Git](https://git-scm.com/downloads)
114+
- [PowerShell 7+](https://github.com/powershell/powershell) _(for Windows users only)_
115+
- **Important**: Ensure you can run `pwsh.exe` from a PowerShell command. If this fails, you likely need to upgrade PowerShell.
116+
- Instead of Powershell, you can also use Git Bash or WSL to run the Azure Developer CLI commands.
117+
- This template uses `gpt-35-turbo` version `1106` which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly
118+
* We recommend using `swedencentral`
119+
120+
Then you can get the project code:
121+
122+
1. [**Fork**](https://github.com/Azure-Samples/llama-index-javascript/fork) the project to create your own copy of this repository.
123+
2. On your forked repository, select the **Code** button, then the **Local** tab, and copy the URL of your forked repository.
124+
3. Open a terminal and run this command to clone the repo: <code> git clone &lt;your-repo-url&gt; </code>
125+
126+
#### Quickstart (with Azure OpenAI models)
127+
128+
1. Bring down the template code:
129+
130+
```shell
131+
azd init --template llama-index-javascript
132+
```
133+
134+
This will perform a git clone
135+
136+
2. Sign into your Azure account:
137+
138+
```shell
139+
azd auth login
140+
```
141+
142+
3. Install all dependencies:
143+
144+
```bash
145+
npm install
146+
```
147+
4. Provision and deploy the project to Azure:
148+
149+
```shell
150+
azd up
151+
```
152+
4. Configure a CI/CD pipeline:
153+
154+
```shell
155+
azd pipeline config
156+
```
157+
158+
Once your deployment is complete, you should see a `.env` file at the root of the project. This file contains the environment variables needed to run the application using Azure resources.
159+
160+
#### Local Development
161+
162+
To run the sample, run the following commands, which will start the Next.js app.
163+
164+
1. Open a terminal and navigate to the root of the project, then run app:
165+
166+
```bash
167+
npm run dev
168+
169+
Open the URL `http://localhost:3000` in your browser to interact with the Assistant.
170+
171+
## Guidance
172+
173+
### Region Availability
174+
175+
This template uses `gpt-35-turbo` version `1106` which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly
176+
* We recommend using `swedencentral`
177+
178+
### Costs
179+
180+
Pricing varies per region and usage, so it isn't possible to predict exact costs for your usage.
181+
However, you can use the [Azure pricing calculator](https://azure.com/e/bf51ef20b57a4da08e47511938ad5415) for the resources below to get an estimate.
182+
183+
- Azure Container Apps: Consumption plan, Free for the first 2M executions. Pricing per execution and memory used. [Pricing](https://azure.microsoft.com/en-us/pricing/details/container-apps/)
184+
- Azure OpenAI: Standard tier, GPT and Ada models. Pricing per 1K tokens used, and at least 1K tokens are used per question. [Pricing](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/)
185+
186+
> [!WARNING]
187+
> To avoid unnecessary costs, remember to take down your app if it's no longer in use, either by deleting the resource group in the Portal or running `azd down --purge`.
188+
189+
### Security
190+
191+
> [!NOTE]
192+
> When implementing this template please specify whether the template uses Managed Identity or Key Vault
193+
194+
This template has either [Managed Identity](https://learn.microsoft.com/entra/identity/managed-identities-azure-resources/overview) or Key Vault built in to eliminate the need for developers to manage these credentials. Applications can use managed identities to obtain Microsoft Entra tokens without having to manage any credentials. Additionally, we have added a [GitHub Action tool](https://github.com/microsoft/security-devops-action) that scans the infrastructure-as-code files and generates a report containing any detected issues. To ensure best practices in your repo we recommend anyone creating solutions based on our templates ensure that the [Github secret scanning](https://docs.github.com/code-security/secret-scanning/about-secret-scanning) setting is enabled in your repos.
195+
196+
197+
## Resources
198+
199+
Here are some resources to learn more about the technologies used in this sample:
200+
201+
- [LlamaIndexTS Documentation](https://ts.llamaindex.ai) - learn about LlamaIndex (Typescript features).
202+
- [Generative AI For Beginners](https://github.com/microsoft/generative-ai-for-beginners)
203+
- [Azure OpenAI Service](https://learn.microsoft.com/azure/ai-services/openai/overview)
204+
- [Azure OpenAI Assistant Builder](https://github.com/Azure-Samples/azure-openai-assistant-builder)
205+
- [Chat + Enterprise data with Azure OpenAI and Azure AI Search](https://github.com/Azure-Samples/azure-search-openai-javascript)
206+
207+
You can also find [more Azure AI samples here](https://github.com/Azure-Samples/azureai-samples).
208+
209+
## Troubleshooting
210+
211+
If you can't find a solution to your problem, please [open an issue](https://github.com/Azure-Samples/llama-index-javascript/issues) in this repository.

0 commit comments

Comments
 (0)